Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

test(api): ratchet controller boundary debt

Juan Denis69fda215b4a1
diff --git a/backend/app/api/invitations.py b/backend/app/api/invitations.py
index 9d09fe96..b3dad98f 100644
--- a/backend/app/api/invitations.py
+++ b/backend/app/api/invitations.py
@@ -1,7 +1,6 @@
"""Invitation API endpoints for team invitations."""
from flask import Blueprint, request, jsonify
from flask_jwt_extended import get_jwt_identity
-from app import db
from app.models import AuditLog
from app.middleware.rbac import admin_required
from app.services.invitation_service import InvitationService
@@ -70,7 +69,6 @@ def create_invitation():
target_id=invitation.id,
details={'email': email, 'role': role, 'email_sent': email_sent}
)
- db.session.commit()
return jsonify({
'message': 'Invitation created successfully',
@@ -97,7 +95,6 @@ def revoke_invitation(invitation_id):
target_type='invitation',
target_id=invitation_id,
)
- db.session.commit()
return jsonify({'message': 'Invitation revoked'}), 200
@@ -106,16 +103,11 @@ def revoke_invitation(invitation_id):
@admin_required
def resend_invitation(invitation_id):
"""Resend invitation email."""
- from app.models import Invitation
- invitation = Invitation.query.get(invitation_id)
- if not invitation:
- return jsonify({'error': 'Invitation not found'}), 404
-
- if invitation.status != Invitation.STATUS_PENDING:
- return jsonify({'error': 'Can only resend pending invitations'}), 400
-
- if not invitation.email:
- return jsonify({'error': 'Invitation has no email address'}), 400
+ candidate = InvitationService.get_resend_candidate(invitation_id)
+ if not candidate['success']:
+ status = 404 if candidate['reason'] == 'not_found' else 400
+ return jsonify({'error': candidate['error']}), status
+ invitation = candidate['invitation']
base_url = request.host_url.rstrip('/')
result = InvitationService.send_invitation_email(invitation, base_url)
diff --git a/backend/app/services/invitation_service.py b/backend/app/services/invitation_service.py
index e6d5aca9..71082e3b 100644
--- a/backend/app/services/invitation_service.py
+++ b/backend/app/services/invitation_service.py
@@ -90,6 +90,37 @@ class InvitationService:
return {'success': True}
+ @staticmethod
+ def get_resend_candidate(invitation_id):
+ """Return an invitation that is eligible for another email delivery.
+
+ Keeping the lookup and invitation-state rules here prevents transport
+ handlers from reaching into the ORM just to prepare a resend.
+ """
+ invitation = db.session.get(Invitation, invitation_id)
+ if not invitation:
+ return {
+ 'success': False,
+ 'reason': 'not_found',
+ 'error': 'Invitation not found',
+ }
+
+ if invitation.status != Invitation.STATUS_PENDING:
+ return {
+ 'success': False,
+ 'reason': 'not_pending',
+ 'error': 'Can only resend pending invitations',
+ }
+
+ if not invitation.email:
+ return {
+ 'success': False,
+ 'reason': 'missing_email',
+ 'error': 'Invitation has no email address',
+ }
+
+ return {'success': True, 'invitation': invitation}
+
@staticmethod
def list_invitations(status=None):
"""List invitations, optionally filtered by status."""
diff --git a/backend/tests/api_controller_boundary_baseline.json b/backend/tests/api_controller_boundary_baseline.json
new file mode 100644
index 00000000..5eedd10b
--- /dev/null
+++ b/backend/tests/api_controller_boundary_baseline.json
@@ -0,0 +1,885 @@
+{
+ "schema_version": 1,
+ "policy": "Exact reviewed inventory of direct persistence, subprocess, and filesystem mutation calls in Flask API controllers. New calls are forbidden; remove entries as controllers delegate to services.",
+ "counts": {
+ "filesystem": 11,
+ "persistence": 595,
+ "subprocess": 6
+ },
+ "owners": {
+ "api/admin.py": {
+ "owner": "ServerKit backend / admin domain",
+ "rationale": "Legacy admin controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/advanced_ssl.py": {
+ "owner": "ServerKit backend / advanced ssl domain",
+ "rationale": "Legacy advanced ssl controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/agent_plugins.py": {
+ "owner": "ServerKit backend / agent plugins domain",
+ "rationale": "Legacy agent plugins controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/ai.py": {
+ "owner": "ServerKit backend / ai domain",
+ "rationale": "Legacy ai controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/app_volumes.py": {
+ "owner": "ServerKit backend / app volumes domain",
+ "rationale": "Legacy app volumes controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/apps.py": {
+ "owner": "ServerKit backend / apps domain",
+ "rationale": "Legacy apps controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/auth.py": {
+ "owner": "ServerKit backend / auth domain",
+ "rationale": "Legacy auth controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/backups.py": {
+ "owner": "ServerKit backend / backups domain",
+ "rationale": "Legacy backups controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/bandwidth.py": {
+ "owner": "ServerKit backend / bandwidth domain",
+ "rationale": "Legacy bandwidth controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/buildpacks.py": {
+ "owner": "ServerKit backend / buildpacks domain",
+ "rationale": "Legacy buildpacks controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/builds.py": {
+ "owner": "ServerKit backend / builds domain",
+ "rationale": "Legacy builds controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/cron.py": {
+ "owner": "ServerKit backend / cron domain",
+ "rationale": "Legacy cron controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/database_engines.py": {
+ "owner": "ServerKit backend / database engines domain",
+ "rationale": "Legacy database engines controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/databases.py": {
+ "owner": "ServerKit backend / databases domain",
+ "rationale": "Legacy databases controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/ddns.py": {
+ "owner": "ServerKit backend / ddns domain",
+ "rationale": "Legacy ddns controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/deploy.py": {
+ "owner": "ServerKit backend / deploy domain",
+ "rationale": "Legacy deploy controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/deployment_jobs.py": {
+ "owner": "ServerKit backend / deployment jobs domain",
+ "rationale": "Legacy deployment jobs controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/deployments.py": {
+ "owner": "ServerKit backend / deployments domain",
+ "rationale": "Legacy deployments controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/dns_cutover.py": {
+ "owner": "ServerKit backend / dns cutover domain",
+ "rationale": "Legacy dns cutover controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/dns_zones.py": {
+ "owner": "ServerKit backend / dns zones domain",
+ "rationale": "Legacy dns zones controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/docker.py": {
+ "owner": "ServerKit backend / docker domain",
+ "rationale": "Legacy docker controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/domains.py": {
+ "owner": "ServerKit backend / domains domain",
+ "rationale": "Legacy domains controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/env_vars.py": {
+ "owner": "ServerKit backend / env vars domain",
+ "rationale": "Legacy env vars controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/environments.py": {
+ "owner": "ServerKit backend / environments domain",
+ "rationale": "Legacy environments controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/files.py": {
+ "owner": "ServerKit backend / files domain",
+ "rationale": "Legacy files controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/fleet.py": {
+ "owner": "ServerKit backend / fleet domain",
+ "rationale": "Legacy fleet controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/git.py": {
+ "owner": "ServerKit backend / git domain",
+ "rationale": "Legacy git controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/image_updates.py": {
+ "owner": "ServerKit backend / image updates domain",
+ "rationale": "Legacy image updates controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/jobs.py": {
+ "owner": "ServerKit backend / jobs domain",
+ "rationale": "Legacy jobs controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/managed_db_users.py": {
+ "owner": "ServerKit backend / managed db users domain",
+ "rationale": "Legacy managed db users controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/manifests.py": {
+ "owner": "ServerKit backend / manifests domain",
+ "rationale": "Legacy manifests controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/marketplace.py": {
+ "owner": "ServerKit backend / marketplace domain",
+ "rationale": "Legacy marketplace controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/migrations.py": {
+ "owner": "ServerKit backend / migrations domain",
+ "rationale": "Legacy migrations controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/mobile.py": {
+ "owner": "ServerKit backend / mobile domain",
+ "rationale": "Legacy mobile controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/modules.py": {
+ "owner": "ServerKit backend / modules domain",
+ "rationale": "Legacy modules controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/nginx_advanced.py": {
+ "owner": "ServerKit backend / nginx advanced domain",
+ "rationale": "Legacy nginx advanced controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/notifications.py": {
+ "owner": "ServerKit backend / notifications domain",
+ "rationale": "Legacy notifications controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/performance.py": {
+ "owner": "ServerKit backend / performance domain",
+ "rationale": "Legacy performance controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/plugins.py": {
+ "owner": "ServerKit backend / plugins domain",
+ "rationale": "Legacy plugins controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/previews.py": {
+ "owner": "ServerKit backend / previews domain",
+ "rationale": "Legacy previews controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/private_urls.py": {
+ "owner": "ServerKit backend / private urls domain",
+ "rationale": "Legacy private urls controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/projects.py": {
+ "owner": "ServerKit backend / projects domain",
+ "rationale": "Legacy projects controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/proxy.py": {
+ "owner": "ServerKit backend / proxy domain",
+ "rationale": "Legacy proxy controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/python.py": {
+ "owner": "ServerKit backend / python domain",
+ "rationale": "Legacy python controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/queue_bus.py": {
+ "owner": "ServerKit backend / queue bus domain",
+ "rationale": "Legacy queue bus controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/registrars.py": {
+ "owner": "ServerKit backend / registrars domain",
+ "rationale": "Legacy registrars controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/search.py": {
+ "owner": "ServerKit backend / search domain",
+ "rationale": "Legacy search controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/secrets_webhooks.py": {
+ "owner": "ServerKit backend / secrets webhooks domain",
+ "rationale": "Legacy secrets webhooks controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/security.py": {
+ "owner": "ServerKit backend / security domain",
+ "rationale": "Legacy security controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/server_templates.py": {
+ "owner": "ServerKit backend / server templates domain",
+ "rationale": "Legacy server templates controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/servers.py": {
+ "owner": "ServerKit backend / servers domain",
+ "rationale": "Legacy servers controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/shared_resources.py": {
+ "owner": "ServerKit backend / shared resources domain",
+ "rationale": "Legacy shared resources controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/site_imports.py": {
+ "owner": "ServerKit backend / site imports domain",
+ "rationale": "Legacy site imports controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/snapshots.py": {
+ "owner": "ServerKit backend / snapshots domain",
+ "rationale": "Legacy snapshots controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/source_connections.py": {
+ "owner": "ServerKit backend / source connections domain",
+ "rationale": "Legacy source connections controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/sso.py": {
+ "owner": "ServerKit backend / sso domain",
+ "rationale": "Legacy sso controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/survey.py": {
+ "owner": "ServerKit backend / survey domain",
+ "rationale": "Legacy survey controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/system.py": {
+ "owner": "ServerKit backend / system domain",
+ "rationale": "Legacy system controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/telemetry.py": {
+ "owner": "ServerKit backend / telemetry domain",
+ "rationale": "Legacy telemetry controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/templates.py": {
+ "owner": "ServerKit backend / templates domain",
+ "rationale": "Legacy templates controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/themes.py": {
+ "owner": "ServerKit backend / themes domain",
+ "rationale": "Legacy themes controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/two_factor.py": {
+ "owner": "ServerKit backend / two factor domain",
+ "rationale": "Legacy two factor controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/waf.py": {
+ "owner": "ServerKit backend / waf domain",
+ "rationale": "Legacy waf controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/webhooks.py": {
+ "owner": "ServerKit backend / webhooks domain",
+ "rationale": "Legacy webhooks controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ },
+ "api/workspaces.py": {
+ "owner": "ServerKit backend / workspaces domain",
+ "rationale": "Legacy workspaces controllers still cross a persistence or host-operation boundary; move each call into an app.services use case before removing it."
+ }
+ },
+ "violations": [
+ "api/admin.py::_daily_action_counts::persistence::db.session.query(day_bucket.label('day'), func.count(AuditLog.id))::1",
+ "api/admin.py::create_user::persistence::User.query.filter(func.lower(User.email) == func.lower(email)).first()::1",
+ "api/admin.py::create_user::persistence::User.query.filter_by(username=username).first()::1",
+ "api/admin.py::create_user::persistence::db.session.add(user)::1",
+ "api/admin.py::create_user::persistence::db.session.commit()::1",
+ "api/admin.py::create_user::persistence::db.session.commit()::2",
+ "api/admin.py::delete_user::persistence::User.query.filter_by(role=User.ROLE_ADMIN).count()::1",
+ "api/admin.py::delete_user::persistence::User.query.get(user_id)::1",
+ "api/admin.py::delete_user::persistence::db.session.commit()::1",
+ "api/admin.py::delete_user::persistence::db.session.commit()::2",
+ "api/admin.py::delete_user::persistence::db.session.delete(user)::1",
+ "api/admin.py::get_activity_summary::persistence::User.query.filter(User.id.in_(ranked_ids)).all()::1",
+ "api/admin.py::get_activity_summary::persistence::User.query.filter_by(is_active=True).count()::1",
+ "api/admin.py::get_activity_summary::persistence::db.session.query(AuditLog.user_id, func.count(AuditLog.id).label('action_count'))::1",
+ "api/admin.py::get_activity_summary::persistence::db.session.query(func.count(AuditLog.id))::1",
+ "api/admin.py::get_activity_summary::persistence::db.session.query(func.count(func.distinct(AuditLog.user_id)))::1",
+ "api/admin.py::get_admin_stats::persistence::AuditLog.query.filter_by(action=AuditLog.ACTION_LOGIN).order_by(AuditLog.created_at.desc()).limit(10).all()::1",
+ "api/admin.py::get_admin_stats::persistence::User.query.count()::1",
+ "api/admin.py::get_admin_stats::persistence::User.query.filter_by(is_active=True).count()::1",
+ "api/admin.py::get_admin_stats::persistence::User.query.filter_by(role=User.ROLE_ADMIN).count()::1",
+ "api/admin.py::get_admin_stats::persistence::User.query.filter_by(role=User.ROLE_DEVELOPER).count()::1",
+ "api/admin.py::get_admin_stats::persistence::User.query.filter_by(role=User.ROLE_VIEWER).count()::1",
+ "api/admin.py::get_audit_log_actions::persistence::db.session.query(AuditLog.action)::1",
+ "api/admin.py::get_user::persistence::User.query.get(user_id)::1",
+ "api/admin.py::list_users::persistence::User.query.order_by(User.created_at.desc()).all()::1",
+ "api/admin.py::reset_user_permissions::persistence::db.session.commit()::1",
+ "api/admin.py::set_canonical_domain::persistence::db.session.commit()::1",
+ "api/admin.py::set_canonical_domain::persistence::db.session.commit()::2",
+ "api/admin.py::update_setting::persistence::db.session.commit()::1",
+ "api/admin.py::update_settings::persistence::db.session.commit()::1",
+ "api/admin.py::update_user::persistence::User.query.filter(func.lower(User.email) == func.lower(data['email'])).first()::1",
+ "api/admin.py::update_user::persistence::User.query.filter_by(role=User.ROLE_ADMIN).count()::1",
+ "api/admin.py::update_user::persistence::User.query.filter_by(username=data['username']).first()::1",
+ "api/admin.py::update_user::persistence::User.query.get(user_id)::1",
+ "api/admin.py::update_user::persistence::db.session.commit()::1",
+ "api/admin.py::update_user::persistence::db.session.commit()::2",
+ "api/admin.py::update_user_permissions::persistence::db.session.commit()::1",
+ "api/advanced_ssl.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/agent_plugins.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/ai.py::_load_or_create::persistence::db.session.add(row)::1",
+ "api/ai.py::_load_or_create::persistence::db.session.commit()::1",
+ "api/ai.py::_owned_conversation::persistence::db.session.get(AiConversation, conversation_id)::1",
+ "api/ai.py::_persist_assistant_message::persistence::db.session.add(msg)::1",
+ "api/ai.py::_persist_assistant_message::persistence::db.session.commit()::1",
+ "api/ai.py::_persist_assistant_message::persistence::db.session.rollback()::1",
+ "api/ai.py::_persist_user_message::persistence::db.session.add(AiMessage(conversation_id=row.id, role=AiMessage.ROLE_USER, content=content))::1",
+ "api/ai.py::_persist_user_message::persistence::db.session.commit()::1",
+ "api/ai.py::_persist_user_message::persistence::db.session.rollback()::1",
+ "api/ai.py::chat_confirm::persistence::db.session.get(AiPendingAction, token)::1",
+ "api/ai.py::chat_stream.producer::persistence::db.session.get(AiConversation, conversation_id)::1",
+ "api/ai.py::chat_stream.producer::persistence::db.session.get(AiConversation, conversation_id)::2",
+ "api/ai.py::chat_stream.producer::persistence::db.session.get(User, user_id)::1",
+ "api/ai.py::create_conversation::persistence::db.session.add(row)::1",
+ "api/ai.py::create_conversation::persistence::db.session.commit()::1",
+ "api/ai.py::delete_conversation::persistence::db.session.commit()::1",
+ "api/ai.py::delete_conversation::persistence::db.session.delete(row)::1",
+ "api/ai.py::list_conversations::persistence::AiConversation.query.filter_by(user_id=user.id).order_by(AiConversation.updated_at.desc()).limit(100).all()::1",
+ "api/ai.py::rename_conversation::persistence::db.session.commit()::1",
+ "api/app_volumes.py::_load_app_for::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/app_volumes.py::_load_app_for::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::_ensure_local_image_compose::filesystem::open(os.path.join(app_path, 'docker-compose.yml'), 'w')::1",
+ "api/apps.py::_ensure_local_image_compose::filesystem::os.makedirs(app_path, exist_ok=True)::1",
+ "api/apps.py::_ensure_local_image_compose::persistence::db.session.commit()::1",
+ "api/apps.py::_load_app_for_backup::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::_load_app_for_backup::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::_resolve_project_env::persistence::Environment.query.get(environment_id)::1",
+ "api/apps.py::_resolve_project_env::persistence::Project.query.get(project_id)::1",
+ "api/apps.py::_sync_manual_app_status::persistence::db.session.commit()::1",
+ "api/apps.py::_wp_site_for_app::persistence::WordPressSite.query.filter_by(application_id=app.id).first()::1",
+ "api/apps.py::apply_image_update::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::apply_image_update::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::apply_image_update::persistence::db.session.commit()::1",
+ "api/apps.py::create_app::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::create_app::persistence::db.session.add(app)::1",
+ "api/apps.py::create_app::persistence::db.session.commit()::1",
+ "api/apps.py::create_app_db_snapshot::persistence::db.session.add(snapshot)::1",
+ "api/apps.py::create_app_db_snapshot::persistence::db.session.commit()::1",
+ "api/apps.py::create_app_from_repository::filesystem::shutil.rmtree(app_path, ignore_errors=True)::1",
+ "api/apps.py::create_app_from_repository::persistence::Application.query.filter_by(name=name, server_id=None).first()::1",
+ "api/apps.py::create_app_from_repository::persistence::Application.query.get(app.id)::1",
+ "api/apps.py::create_app_from_repository::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::create_app_from_repository::persistence::db.session.add(app)::1",
+ "api/apps.py::create_app_from_repository::persistence::db.session.commit()::1",
+ "api/apps.py::create_app_from_repository::persistence::db.session.commit()::2",
+ "api/apps.py::create_app_from_repository::persistence::db.session.delete(existing_app)::1",
+ "api/apps.py::create_app_from_repository::persistence::db.session.rollback()::1",
+ "api/apps.py::create_manual_app::persistence::Application.query.filter_by(name=name).first()::1",
+ "api/apps.py::create_manual_app::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::create_manual_app::persistence::db.session.add(app)::1",
+ "api/apps.py::create_manual_app::persistence::db.session.commit()::1",
+ "api/apps.py::delete_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::delete_app::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::delete_app_db_snapshot::persistence::DatabaseSnapshot.query.filter_by(id=snapshot_id, site_id=site.id).first()::1",
+ "api/apps.py::delete_app_db_snapshot::persistence::db.session.commit()::1",
+ "api/apps.py::delete_app_db_snapshot::persistence::db.session.delete(snapshot)::1",
+ "api/apps.py::evaluate_scale::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::evaluate_scale::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::get_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_app::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::get_app_containers::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_app_containers::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::get_app_logs::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_app_logs::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::get_app_related::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_app_related::persistence::BackupPolicy.query.filter_by(target_type='application', target_id=app.id).first()::1",
+ "api/apps.py::get_app_related::persistence::Deployment.query.filter_by(app_id=app.id).count()::1",
+ "api/apps.py::get_app_related::persistence::Domain.query_active().filter_by(application_id=app.id).all()::1",
+ "api/apps.py::get_app_related::persistence::ManagedDatabase.query.filter_by(owner_application_id=app.id).all()::1",
+ "api/apps.py::get_app_related::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::get_app_resources::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_app_resources::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::get_app_status::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_app_status::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::get_app_status::persistence::db.session.commit()::1",
+ "api/apps.py::get_app_versions::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_app_versions::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::get_apps::persistence::Application.query_active()::1",
+ "api/apps.py::get_apps::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::get_compose_services::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_compose_services::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::get_container_logs::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_container_logs::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::get_linked_apps::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_linked_apps::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::get_scale_policy::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_scale_policy::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::get_sleep_policy::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::get_sleep_policy::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::grant_app_access::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::grant_app_access::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::grant_app_access::persistence::User.query.get(grantee_id)::1",
+ "api/apps.py::link_apps::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::link_apps::persistence::Application.query_active().filter_by(id=target_app_id).first()::1",
+ "api/apps.py::link_apps::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::link_apps::persistence::db.session.commit()::1",
+ "api/apps.py::list_app_db_snapshots::persistence::DatabaseSnapshot.query.filter_by(site_id=site.id).order_by(DatabaseSnapshot.created_at.desc()).all()::1",
+ "api/apps.py::list_app_grants::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::list_app_grants::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::move_apps_to_project::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::move_apps_to_project::persistence::Environment.query.get(environment_id)::1",
+ "api/apps.py::move_apps_to_project::persistence::Project.query.get(req_project_id)::1",
+ "api/apps.py::move_apps_to_project::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::move_apps_to_project::persistence::db.session.commit()::1",
+ "api/apps.py::purge_micro_cache::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::purge_micro_cache::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::restart_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::restart_app::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::restart_app::persistence::db.session.commit()::1",
+ "api/apps.py::revoke_app_access::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::revoke_app_access::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::rollback_app_version::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::rollback_app_version::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::rollback_app_version::persistence::db.session.commit()::1",
+ "api/apps.py::scale_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::scale_app::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::scale_sweep::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::set_app_workspace::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::set_app_workspace::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::set_app_workspace::persistence::Workspace.query.get(target)::1",
+ "api/apps.py::set_app_workspace::persistence::db.session.commit()::1",
+ "api/apps.py::set_micro_cache::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::set_micro_cache::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::set_micro_cache::persistence::db.session.commit()::1",
+ "api/apps.py::sleep_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::sleep_app::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::start_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::start_app::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::start_app::persistence::db.session.commit()::1",
+ "api/apps.py::stop_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::stop_app::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::stop_app::persistence::db.session.commit()::1",
+ "api/apps.py::sweep_idle_apps::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::unlink_apps::persistence::Application.query.get(app.linked_app_id)::1",
+ "api/apps.py::unlink_apps::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::unlink_apps::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::unlink_apps::persistence::db.session.commit()::1",
+ "api/apps.py::update_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::update_app::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::update_app::persistence::db.session.commit()::1",
+ "api/apps.py::update_app_resources::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::update_app_resources::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::update_app_resources::persistence::db.session.commit()::1",
+ "api/apps.py::update_environment::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::update_environment::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::update_environment::persistence::db.session.commit()::1",
+ "api/apps.py::update_scale_policy::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::update_scale_policy::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::update_sleep_policy::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::update_sleep_policy::persistence::User.query.get(get_jwt_identity())::1",
+ "api/apps.py::upload_app_archive::filesystem::os.makedirs(temp_dir, exist_ok=True)::1",
+ "api/apps.py::upload_app_archive::filesystem::os.remove(zippath)::1",
+ "api/apps.py::upload_app_archive::filesystem::os.remove(zippath)::2",
+ "api/apps.py::upload_app_archive::filesystem::os.remove(zippath)::3",
+ "api/apps.py::upload_app_archive::filesystem::os.remove(zippath)::4",
+ "api/apps.py::upload_app_archive::persistence::Application.query.filter_by(name=name).first()::1",
+ "api/apps.py::upload_app_archive::persistence::Application.query_active().filter_by(name=name).first()::1",
+ "api/apps.py::upload_app_archive::persistence::User.query.get(current_user_id)::1",
+ "api/apps.py::upload_app_archive::persistence::db.session.add(app)::1",
+ "api/apps.py::upload_app_archive::persistence::db.session.commit()::1",
+ "api/apps.py::upload_app_archive::persistence::db.session.commit()::2",
+ "api/apps.py::wake_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/apps.py::wake_app::persistence::User.query.get(get_jwt_identity())::1",
+ "api/auth.py::complete_onboarding::persistence::User.query.get(current_user_id)::1",
+ "api/auth.py::create_login_link::persistence::User.query.get(target_id)::1",
+ "api/auth.py::create_login_link::persistence::db.session.commit()::1",
+ "api/auth.py::demo_info::persistence::User.query.filter_by(username='demo').first()::1",
+ "api/auth.py::demo_info::persistence::db.session.add(user)::1",
+ "api/auth.py::demo_info::persistence::db.session.commit()::1",
+ "api/auth.py::demo_info::persistence::db.session.commit()::2",
+ "api/auth.py::get_current_user::persistence::User.query.get(current_user_id)::1",
+ "api/auth.py::login::persistence::User.query.filter((func.lower(User.email) == func.lower(login_id)) | (User.username == login_id)).first()::1",
+ "api/auth.py::login::persistence::db.session.commit()::1",
+ "api/auth.py::login::persistence::db.session.commit()::2",
+ "api/auth.py::login::persistence::db.session.commit()::3",
+ "api/auth.py::login::persistence::db.session.commit()::4",
+ "api/auth.py::passkey_auth_options::persistence::User.query.get(user_id)::1",
+ "api/auth.py::passkey_authenticate::persistence::User.query.get(user_id)::1",
+ "api/auth.py::passkey_authenticate::persistence::db.session.commit()::1",
+ "api/auth.py::passkey_authenticate::persistence::db.session.commit()::2",
+ "api/auth.py::passkey_register::persistence::User.query.get(user_id)::1",
+ "api/auth.py::passkey_register_options::persistence::User.query.get(user_id)::1",
+ "api/auth.py::redeem_login_link::persistence::db.session.commit()::1",
+ "api/auth.py::redeem_login_link::persistence::db.session.commit()::2",
+ "api/auth.py::refresh::persistence::User.query.get(current_user_id)::1",
+ "api/auth.py::register::persistence::User.query.count()::1",
+ "api/auth.py::register::persistence::User.query.filter(func.lower(User.email) == func.lower(email)).first()::1",
+ "api/auth.py::register::persistence::User.query.filter_by(username=username).first()::1",
+ "api/auth.py::register::persistence::db.session.add(user)::1",
+ "api/auth.py::register::persistence::db.session.commit()::1",
+ "api/auth.py::register::persistence::db.session.commit()::2",
+ "api/auth.py::revoke_login_link::persistence::LoginLink.query.get(link_id)::1",
+ "api/auth.py::revoke_login_link::persistence::db.session.commit()::1",
+ "api/auth.py::revoke_login_link::persistence::db.session.delete(link)::1",
+ "api/auth.py::update_current_user::persistence::User.query.filter(func.lower(User.email) == func.lower(data['email'])).first()::1",
+ "api/auth.py::update_current_user::persistence::User.query.filter_by(username=data['username']).first()::1",
+ "api/auth.py::update_current_user::persistence::User.query.get(current_user_id)::1",
+ "api/auth.py::update_current_user::persistence::db.session.commit()::1",
+ "api/backups.py::backup_application::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/backups.py::cost_summary::persistence::BackupPolicy.query.all()::1",
+ "api/backups.py::cost_summary::persistence::BackupRun.query.filter_by(policy_id=policy.id, status='success').order_by(BackupRun.started_at.desc()).limit(5).all()::1",
+ "api/backups.py::cost_summary::persistence::db.session.query(func.coalesce(func.sum(BackupRun.size_local), 0), func.coalesce(func.sum(BackupRun.size_remote), 0), func.count(BackupRun.id))::1",
+ "api/backups.py::list_runs::persistence::db.session.query(BackupRun, BackupPolicy)::1",
+ "api/bandwidth.py::get_app_bandwidth::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/bandwidth.py::get_app_bandwidth::persistence::User.query.get(get_jwt_identity())::1",
+ "api/buildpacks.py::detect::filesystem::shutil.rmtree(workdir, ignore_errors=True)::1",
+ "api/builds.py::configure_build::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::deploy_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::deploy_app::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::detect_build_method::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::detect_build_method::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::get_build_config::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::get_build_config::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::get_build_log_detail::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::get_build_log_detail::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::get_build_logs::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::get_build_logs::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::get_current_deployment::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::get_current_deployment::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::get_deployment::persistence::Application.query_active().filter_by(id=deployment.app_id).first()::1",
+ "api/builds.py::get_deployment::persistence::Deployment.query.get(deployment_id)::1",
+ "api/builds.py::get_deployment::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::get_deployment_diff::persistence::Application.query_active().filter_by(id=deployment.app_id).first()::1",
+ "api/builds.py::get_deployment_diff::persistence::Deployment.query.get(deployment_id)::1",
+ "api/builds.py::get_deployment_diff::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::get_deployments::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::get_deployments::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::get_nixpacks_plan::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::get_nixpacks_plan::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::rollback::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::rollback::persistence::User.query.get(current_user_id)::1",
+ "api/builds.py::trigger_build::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/builds.py::trigger_build::persistence::User.query.get(current_user_id)::1",
+ "api/cron.py::_attach_attribution::persistence::Application.query.filter(Application.id.in_(ids)).all()::1",
+ "api/cron.py::_attach_attribution::persistence::Workspace.query.filter(Workspace.id.in_(ws_ids)).all()::1",
+ "api/cron.py::_notify_run_transition::persistence::Application.query.get(int(aid))::1",
+ "api/cron.py::_notify_run_transition::persistence::Workspace.query.get(app.workspace_id)::1",
+ "api/cron.py::_validate_application_id::persistence::Application.query_active().filter_by(id=aid).first()::1",
+ "api/database_engines.py::_require_app_access::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/database_engines.py::_require_app_access::persistence::User.query.get(get_jwt_identity())::1",
+ "api/databases.py::_persist_provisioned::persistence::User.query.get(get_jwt_identity())::1",
+ "api/databases.py::_workspace_id::persistence::User.query.get(get_jwt_identity())::1",
+ "api/databases.py::execute_docker_query::persistence::User.query.get(current_user_id)::1",
+ "api/databases.py::execute_mysql_query::persistence::User.query.get(current_user_id)::1",
+ "api/databases.py::execute_pg_query::persistence::User.query.get(current_user_id)::1",
+ "api/databases.py::execute_sqlite_query::persistence::User.query.get(current_user_id)::1",
+ "api/databases.py::get_app_databases::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/databases.py::get_app_databases::persistence::User.query.get(current_user_id)::1",
+ "api/databases.py::list_all_docker_databases::persistence::Application.query_active().filter_by(app_type='docker')::1",
+ "api/databases.py::list_all_docker_databases::persistence::User.query.get(current_user_id)::1",
+ "api/ddns.py::_admin::persistence::User.query.get(get_jwt_identity())::1",
+ "api/deploy.py::configure_deployment::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deploy.py::get_branches::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deploy.py::get_branches::persistence::User.query.get(current_user_id)::1",
+ "api/deploy.py::get_commit_info::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deploy.py::get_commit_info::persistence::User.query.get(current_user_id)::1",
+ "api/deploy.py::get_deploy_config::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deploy.py::get_deploy_config::persistence::User.query.get(current_user_id)::1",
+ "api/deploy.py::get_deployment_history::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deploy.py::get_deployment_history::persistence::User.query.get(current_user_id)::1",
+ "api/deploy.py::get_git_status::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deploy.py::get_git_status::persistence::User.query.get(current_user_id)::1",
+ "api/deploy.py::get_webhook_logs::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deploy.py::get_webhook_logs::persistence::User.query.get(current_user_id)::1",
+ "api/deploy.py::pull_changes::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deploy.py::pull_changes::persistence::User.query.get(current_user_id)::1",
+ "api/deploy.py::trigger_deploy::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deploy.py::trigger_deploy::persistence::User.query.get(current_user_id)::1",
+ "api/deployment_jobs.py::_job_operable_by::persistence::Application.query_active().filter_by(id=job.app_id).first()::1",
+ "api/deployment_jobs.py::_job_visible_to::persistence::Application.query_active().filter_by(id=job.app_id).first()::1",
+ "api/deployment_jobs.py::get_deployment_job::persistence::DeploymentJob.query.get(job_id)::1",
+ "api/deployment_jobs.py::get_deployment_job::persistence::User.query.get(get_jwt_identity())::1",
+ "api/deployment_jobs.py::get_deployment_job_logs::persistence::DeploymentJob.query.get(job_id)::1",
+ "api/deployment_jobs.py::get_deployment_job_logs::persistence::DeploymentJobLog.query.filter_by(job_id=job_id)::1",
+ "api/deployment_jobs.py::get_deployment_job_logs::persistence::User.query.get(get_jwt_identity())::1",
+ "api/deployment_jobs.py::list_deployment_jobs::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deployment_jobs.py::list_deployment_jobs::persistence::User.query.get(current_user_id)::1",
+ "api/deployment_jobs.py::retry_deployment_job::persistence::DeploymentJob.query.get(job_id)::1",
+ "api/deployment_jobs.py::retry_deployment_job::persistence::User.query.get(get_jwt_identity())::1",
+ "api/deployments.py::_access::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/deployments.py::_access::persistence::User.query.get(get_jwt_identity())::1",
+ "api/deployments.py::app_history::persistence::Deployment.query.filter_by(app_id=app_id).order_by(Deployment.created_at.desc()).limit(limit).all()::1",
+ "api/deployments.py::app_history::persistence::GitDeployment.query.filter_by(app_id=app_id).order_by(GitDeployment.created_at.desc()).limit(limit).all()::1",
+ "api/deployments.py::get_deployment::persistence::Deployment.query.get(deployment_id)::1",
+ "api/dns_cutover.py::_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/dns_zones.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/dns_zones.py::list_managed_records::persistence::Application.query.all()::1",
+ "api/docker.py::cleanup_all_apps::filesystem::shutil.rmtree(app.root_path)::1",
+ "api/docker.py::cleanup_all_apps::persistence::Application.query_active().filter_by(app_type='docker').all()::1",
+ "api/docker.py::cleanup_all_apps::persistence::db.session.commit()::1",
+ "api/docker.py::cleanup_all_apps::persistence::db.session.delete(app)::1",
+ "api/docker.py::cleanup_all_apps::persistence::db.session.rollback()::1",
+ "api/docker.py::create_docker_app::persistence::db.session.add(app)::1",
+ "api/docker.py::create_docker_app::persistence::db.session.commit()::1",
+ "api/docker.py::docker_cleanup::subprocess::subprocess.run(['docker', 'image', 'prune', '-f'], capture_output=True, text=True)::1",
+ "api/docker.py::docker_cleanup::subprocess::subprocess.run(['docker', 'network', 'prune', '-f'], capture_output=True, text=True)::1",
+ "api/docker.py::docker_cleanup::subprocess::subprocess.run(['docker', 'ps', '-a', '--format', '{{.ID}} {{.Names}}'], capture_output=True, text=True)::1",
+ "api/docker.py::docker_cleanup::subprocess::subprocess.run(['docker', 'ps', '-a', '-q', '-f', 'status=exited'], capture_output=True, text=True)::1",
+ "api/docker.py::docker_cleanup::subprocess::subprocess.run(['docker', 'rm'] + stopped_ids, capture_output=True, text=True)::1",
+ "api/docker.py::docker_cleanup::subprocess::subprocess.run(['docker', 'volume', 'prune', '-f'], capture_output=True, text=True)::1",
+ "api/domains.py::create_domain::persistence::Application.query_active().filter_by(id=application_id).first()::1",
+ "api/domains.py::create_domain::persistence::Domain.query_active().filter_by(application_id=application_id, is_primary=True).update({'is_primary': False}, synchronize_session=False)::1",
+ "api/domains.py::create_domain::persistence::Domain.query_active().filter_by(name=name).first()::1",
+ "api/domains.py::create_domain::persistence::User.query.get(current_user_id)::1",
+ "api/domains.py::create_domain::persistence::db.session.add(domain)::1",
+ "api/domains.py::create_domain::persistence::db.session.commit()::1",
+ "api/domains.py::delete_domain::persistence::Application.query_active().filter_by(id=domain.application_id).first()::1",
+ "api/domains.py::delete_domain::persistence::Domain.query_active().filter_by(application_id=application_id).count()::1",
+ "api/domains.py::delete_domain::persistence::Domain.query_active().filter_by(id=domain_id).first()::1",
+ "api/domains.py::delete_domain::persistence::User.query.get(current_user_id)::1",
+ "api/domains.py::delete_domain::persistence::db.session.commit()::1",
+ "api/domains.py::diagnose_app_routing::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/domains.py::diagnose_app_routing::persistence::Domain.query_active().filter_by(application_id=app_id).all()::1",
+ "api/domains.py::disable_ssl::persistence::Application.query_active().filter_by(id=domain.application_id).first()::1",
+ "api/domains.py::disable_ssl::persistence::Domain.query_active().filter_by(id=domain_id).first()::1",
+ "api/domains.py::disable_ssl::persistence::User.query.get(current_user_id)::1",
+ "api/domains.py::disable_ssl::persistence::db.session.commit()::1",
+ "api/domains.py::enable_ssl::persistence::Application.query_active().filter_by(id=domain.application_id).first()::1",
+ "api/domains.py::enable_ssl::persistence::Domain.query_active().filter_by(id=domain_id).first()::1",
+ "api/domains.py::enable_ssl::persistence::User.query.get(current_user_id)::1",
+ "api/domains.py::enable_ssl::persistence::db.session.commit()::1",
+ "api/domains.py::get_domain::persistence::Application.query_active().filter_by(id=domain.application_id).first()::1",
+ "api/domains.py::get_domain::persistence::Domain.query_active().filter_by(id=domain_id).first()::1",
+ "api/domains.py::get_domain::persistence::User.query.get(current_user_id)::1",
+ "api/domains.py::get_domains::persistence::Application.query_active()::1",
+ "api/domains.py::get_domains::persistence::Domain.query_active().filter(Domain.application_id.in_(app_ids)).all()::1",
+ "api/domains.py::get_domains::persistence::User.query.get(current_user_id)::1",
+ "api/domains.py::give_subdomain::persistence::Application.query_active().filter_by(id=data.get('application_id')).first()::1",
+ "api/domains.py::give_subdomain::persistence::User.query.get(current_user_id)::1",
+ "api/domains.py::regenerate_nginx_config::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/domains.py::regenerate_nginx_config::persistence::Domain.query_active().filter_by(application_id=app_id).all()::1",
+ "api/domains.py::renew_ssl::persistence::Application.query_active().filter_by(id=domain.application_id).first()::1",
+ "api/domains.py::renew_ssl::persistence::Domain.query_active().filter_by(id=domain_id).first()::1",
+ "api/domains.py::renew_ssl::persistence::User.query.get(current_user_id)::1",
+ "api/domains.py::suggest_subdomain::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/domains.py::test_app_routing::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/domains.py::test_app_routing::persistence::Domain.query_active().filter_by(application_id=app_id).first()::1",
+ "api/domains.py::test_app_routing::persistence::Domain.query_active().filter_by(application_id=app_id, is_primary=True).first()::1",
+ "api/domains.py::update_domain::persistence::Application.query_active().filter_by(id=domain.application_id).first()::1",
+ "api/domains.py::update_domain::persistence::Domain.query_active().filter_by(application_id=domain.application_id, is_primary=True).update({'is_primary': False}, synchronize_session=False)::1",
+ "api/domains.py::update_domain::persistence::Domain.query_active().filter_by(id=domain_id).first()::1",
+ "api/domains.py::update_domain::persistence::User.query.get(current_user_id)::1",
+ "api/domains.py::update_domain::persistence::db.session.commit()::1",
+ "api/domains.py::verify_domain::persistence::Domain.query_active().filter_by(id=domain_id).first()::1",
+ "api/env_vars.py::check_app_access::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/env_vars.py::check_app_access::persistence::User.query.get(user_id)::1",
+ "api/env_vars.py::update_env_var::persistence::db.session.commit()::1",
+ "api/environments.py::_accessible_workspace_ids::persistence::Workspace.query.all()::1",
+ "api/environments.py::_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/environments.py::create_environment::persistence::db.session.commit()::1",
+ "api/files.py::upload_file::filesystem::os.makedirs(parent)::1",
+ "api/fleet.py::list_targets::persistence::Server.query.get(server_id)::1",
+ "api/git.py::_webhook_visible_to::persistence::Application.query.get(webhook.app_id)::1",
+ "api/git.py::get_deployment::persistence::Application.query_active().filter_by(id=deployment.app_id).first()::1",
+ "api/git.py::get_deployment::persistence::GitDeployment.query.get(deployment_id)::1",
+ "api/git.py::get_webhook::persistence::GitWebhook.query.get(webhook_id)::1",
+ "api/git.py::get_webhook_deployments::persistence::GitDeployment.query.filter_by(webhook_id=webhook_id).order_by(GitDeployment.created_at.desc()).limit(limit).all()::1",
+ "api/git.py::get_webhook_deployments::persistence::GitWebhook.query.get(webhook_id)::1",
+ "api/git.py::get_webhook_logs::persistence::GitWebhook.query.get(webhook_id)::1",
+ "api/git.py::list_webhooks::persistence::GitWebhook.query.get(w.get('id'))::1",
+ "api/image_updates.py::_admin::persistence::User.query.get(get_jwt_identity())::1",
+ "api/image_updates.py::latest::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/image_updates.py::latest::persistence::User.query.get(get_jwt_identity())::1",
+ "api/jobs.py::_require_admin::persistence::User.query.get(get_jwt_identity())::1",
+ "api/managed_db_users.py::delete_managed_db_user::persistence::ManagedDatabaseUser.query.filter_by(id=user_id, managed_database_id=managed.id).first()::1",
+ "api/manifests.py::_load_normalized::persistence::ApplicationManifest.query.filter_by(project_id=project_id).first()::1",
+ "api/manifests.py::_require_admin::persistence::User.query.get(get_jwt_identity())::1",
+ "api/manifests.py::apply_manifest::persistence::Project.query.get(data.get('project_id'))::1",
+ "api/manifests.py::apply_manifest::persistence::db.session.commit()::1",
+ "api/manifests.py::get_manifest::persistence::ApplicationManifest.query.filter_by(project_id=project_id).first()::1",
+ "api/manifests.py::plan_manifest::persistence::Project.query.get(data.get('project_id'))::1",
+ "api/manifests.py::reset_bootstrap::persistence::Application.query_active().filter_by(id=data.get('app_id')).first()::1",
+ "api/manifests.py::reset_bootstrap::persistence::db.session.commit()::1",
+ "api/manifests.py::scaffold_manifest::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/marketplace.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/migrations.py::apply_migrations::persistence::User.query.get(get_jwt_identity())::1",
+ "api/migrations.py::create_backup::persistence::User.query.get(get_jwt_identity())::1",
+ "api/migrations.py::get_migration_history::persistence::User.query.get(get_jwt_identity())::1",
+ "api/mobile.py::get_mobile_summary::persistence::SecurityAlert.query.filter_by(resolved=False).count()::1",
+ "api/mobile.py::get_mobile_summary::persistence::Server.query.count()::1",
+ "api/mobile.py::get_offline_data::persistence::Server.query.limit(50).all()::1",
+ "api/mobile.py::register_push::persistence::User.query.get(user_id)::1",
+ "api/mobile.py::register_push::persistence::db.session.commit()::1",
+ "api/modules.py::_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/nginx_advanced.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/notifications.py::get_user_preferences::persistence::User.query.get(current_user_id)::1",
+ "api/notifications.py::test_user_notification::persistence::User.query.get(current_user_id)::1",
+ "api/notifications.py::unmute_own_email::persistence::User.query.get(current_user_id)::1",
+ "api/notifications.py::update_user_preferences::persistence::db.session.commit()::1",
+ "api/notifications.py::update_user_preferences::persistence::db.session.rollback()::1",
+ "api/performance.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/plugins.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/previews.py::_get_app_or_404::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/previews.py::_get_app_or_404::persistence::User.query.get(get_jwt_identity())::1",
+ "api/previews.py::destroy_preview::persistence::ApplicationPreview.query.filter_by(id=preview_id, application_id=app_id).first()::1",
+ "api/previews.py::list_previews::persistence::ApplicationPreview.query.filter(ApplicationPreview.application_id == app_id, ApplicationPreview.status != ApplicationPreview.STATUS_DESTROYED).order_by(ApplicationPreview.pr_number.desc()).all()::1",
+ "api/previews.py::redeploy_preview::persistence::ApplicationPreview.query.filter_by(id=preview_id, application_id=app_id).first()::1",
+ "api/private_urls.py::disable_private_url::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/private_urls.py::disable_private_url::persistence::User.query.get(current_user_id)::1",
+ "api/private_urls.py::disable_private_url::persistence::db.session.commit()::1",
+ "api/private_urls.py::enable_private_url::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/private_urls.py::enable_private_url::persistence::User.query.get(current_user_id)::1",
+ "api/private_urls.py::enable_private_url::persistence::db.session.commit()::1",
+ "api/private_urls.py::get_private_url::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/private_urls.py::get_private_url::persistence::User.query.get(current_user_id)::1",
+ "api/private_urls.py::regenerate_private_url::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/private_urls.py::regenerate_private_url::persistence::User.query.get(current_user_id)::1",
+ "api/private_urls.py::regenerate_private_url::persistence::db.session.commit()::1",
+ "api/private_urls.py::resolve_private_url::persistence::Application.query_active().filter_by(private_slug=slug, private_url_enabled=True).first()::1",
+ "api/private_urls.py::update_private_url::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/private_urls.py::update_private_url::persistence::User.query.get(current_user_id)::1",
+ "api/private_urls.py::update_private_url::persistence::db.session.commit()::1",
+ "api/projects.py::_accessible_workspace_ids::persistence::Workspace.query.all()::1",
+ "api/projects.py::_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/proxy.py::_require_server::persistence::Server.query.get(server_id)::1",
+ "api/python.py::create_django_app::persistence::db.session.add(app)::1",
+ "api/python.py::create_django_app::persistence::db.session.commit()::1",
+ "api/python.py::create_flask_app::persistence::db.session.add(app)::1",
+ "api/python.py::create_flask_app::persistence::db.session.commit()::1",
+ "api/python.py::delete_app::persistence::db.session.commit()::1",
+ "api/python.py::delete_app::persistence::db.session.delete(app)::1",
+ "api/python.py::get_app_or_404::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/python.py::get_app_or_404::persistence::User.query.get(current_user_id)::1",
+ "api/python.py::restart_app::persistence::db.session.commit()::1",
+ "api/python.py::start_app::persistence::db.session.commit()::1",
+ "api/python.py::stop_app::persistence::db.session.commit()::1",
+ "api/queue_bus.py::_current_user::persistence::User.query.get(int(uid))::1",
+ "api/registrars.py::_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/search.py::search::persistence::User.query.get(get_jwt_identity())::1",
+ "api/secrets_webhooks.py::_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/secrets_webhooks.py::_resolve_ws::persistence::User.query.get(get_jwt_identity())::1",
+ "api/secrets_webhooks.py::create_vault::persistence::User.query.get(get_jwt_identity())::1",
+ "api/secrets_webhooks.py::create_vault::persistence::Workspace.query.get(explicit_ws)::1",
+ "api/security.py::get_application_sboms::persistence::SbomArtifact.query.filter_by(application_id=application_id).order_by(SbomArtifact.created_at.desc()).limit(50).all()::1",
+ "api/security.py::get_image_scan::persistence::ImageVulnerabilityScan.query.get(scan_id)::1",
+ "api/security.py::get_sbom::persistence::SbomArtifact.query.get(sbom_id)::1",
+ "api/server_templates.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/servers.py::acknowledge_alert::persistence::SecurityAlert.query.get(alert_id)::1",
+ "api/servers.py::add_agent_version::persistence::db.session.add(version)::1",
+ "api/servers.py::add_agent_version::persistence::db.session.commit()::1",
+ "api/servers.py::compare_server_metrics::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::compare_server_metrics::persistence::ServerMetrics.query.filter_by(server_id=server_id).order_by(ServerMetrics.timestamp.desc()).limit(limit).all()::1",
+ "api/servers.py::create_group::persistence::db.session.add(group)::1",
+ "api/servers.py::create_group::persistence::db.session.commit()::1",
+ "api/servers.py::create_server::persistence::Server.query.filter_by(workspace_id=ws_id).count()::1",
+ "api/servers.py::create_server::persistence::User.query.get(user_id)::1",
+ "api/servers.py::create_server::persistence::db.session.add(server)::1",
+ "api/servers.py::create_server::persistence::db.session.commit()::1",
+ "api/servers.py::create_server::persistence::db.session.commit()::2",
+ "api/servers.py::delete_group::persistence::ServerGroup.query.get(group_id)::1",
+ "api/servers.py::delete_group::persistence::db.session.commit()::1",
+ "api/servers.py::delete_group::persistence::db.session.delete(group)::1",
+ "api/servers.py::delete_server::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::delete_server::persistence::db.session.commit()::1",
+ "api/servers.py::delete_server::persistence::db.session.delete(server)::1",
+ "api/servers.py::get_allowed_ips::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::get_command_history::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::get_command_history::persistence::ServerCommand.query.filter_by(server_id=server_id).order_by(ServerCommand.created_at.desc()).limit(limit).all()::1",
+ "api/servers.py::get_connection_info::persistence::AgentSession.query.filter_by(server_id=server_id, is_active=True).first()::1",
+ "api/servers.py::get_connection_info::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::get_group::persistence::ServerGroup.query.get(group_id)::1",
+ "api/servers.py::get_install_instructions::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::get_server::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::get_server::persistence::db.session.commit()::1",
+ "api/servers.py::get_server::persistence::db.session.rollback()::1",
+ "api/servers.py::get_server_metrics::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::get_server_metrics::persistence::ServerMetrics.query.filter_by(server_id=server_id)::1",
+ "api/servers.py::get_server_onboarding_status::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::get_server_security_alerts::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::get_server_status::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::get_servers_overview::persistence::Server.query.all()::1",
+ "api/servers.py::list_agent_versions::persistence::AgentVersion.query.order_by(AgentVersion.version.desc()).all()::1",
+ "api/servers.py::list_groups::persistence::ServerGroup.query.all()::1",
+ "api/servers.py::list_servers::persistence::ServerMetrics.query.filter(ServerMetrics.id.in_(newest)).all()::1",
+ "api/servers.py::list_servers::persistence::User.query.get(get_jwt_identity())::1",
+ "api/servers.py::list_servers::persistence::db.session.query(db.func.max(ServerMetrics.id))::1",
+ "api/servers.py::ping_server::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::regenerate_token::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::regenerate_token::persistence::db.session.commit()::1",
+ "api/servers.py::register_agent::persistence::Server.query.filter(Server.registration_token_hash.isnot(None)).all()::1",
+ "api/servers.py::register_agent::persistence::db.session.commit()::1",
+ "api/servers.py::resolve_alert::persistence::SecurityAlert.query.get(alert_id)::1",
+ "api/servers.py::retry_server_onboarding::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::rotate_api_key::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::rotate_api_key::persistence::db.session.commit()::1",
+ "api/servers.py::set_server_workspace::persistence::Server.query.filter_by(workspace_id=ws.id).count()::1",
+ "api/servers.py::set_server_workspace::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::set_server_workspace::persistence::User.query.get(get_jwt_identity())::1",
+ "api/servers.py::set_server_workspace::persistence::Workspace.query.get(target)::1",
+ "api/servers.py::set_server_workspace::persistence::db.session.commit()::1",
+ "api/servers.py::start_server_onboarding::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::trigger_agent_update::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::update_allowed_ips::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::update_allowed_ips::persistence::db.session.commit()::1",
+ "api/servers.py::update_group::persistence::ServerGroup.query.get(group_id)::1",
+ "api/servers.py::update_group::persistence::db.session.commit()::1",
+ "api/servers.py::update_server::persistence::Server.query.get(server_id)::1",
+ "api/servers.py::update_server::persistence::db.session.commit()::1",
+ "api/servers.py::upgrade_fleet::persistence::Server.query.filter_by(status='online').all()::1",
+ "api/shared_resources.py::_check_resource_write::persistence::ManagedDatabase.query.get(int(resource_id))::1",
+ "api/shared_resources.py::_check_resource_write::persistence::Server.query.get(str(resource_id))::1",
+ "api/shared_resources.py::_resolve_app::persistence::Application.query_active().filter_by(id=rid).first()::1",
+ "api/shared_resources.py::_resolve_app::persistence::Application.query_active().filter_by(id=site.application_id).first()::1",
+ "api/shared_resources.py::_resolve_app::persistence::WordPressSite.query.get(rid)::1",
+ "api/shared_resources.py::_scope_workspace_id::persistence::Environment.query.get(sid)::1",
+ "api/shared_resources.py::_scope_workspace_id::persistence::Project.query.get(env.project_id)::1",
+ "api/shared_resources.py::_scope_workspace_id::persistence::Project.query.get(sid)::1",
+ "api/shared_resources.py::_scope_workspace_id::persistence::Workspace.query.get(sid)::1",
+ "api/shared_resources.py::delete_variable::persistence::SharedVariable.query.get(variable_id)::1",
+ "api/shared_resources.py::update_variable::persistence::SharedVariable.query.get(variable_id)::1",
+ "api/site_imports.py::run_import::persistence::db.session.commit()::1",
+ "api/snapshots.py::_get_app_or_404::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/snapshots.py::_get_snapshot_or_404::persistence::DeploymentSnapshot.query.filter_by(id=snap_id, application_id=app_id).first()::1",
+ "api/snapshots.py::diff_snapshot::persistence::DeploymentSnapshot.query.filter(DeploymentSnapshot.application_id == app_id, DeploymentSnapshot.created_at < snap.created_at).order_by(DeploymentSnapshot.created_at.desc(), DeploymentSnapshot.id.desc()).first()::1",
+ "api/snapshots.py::list_snapshots::persistence::DeploymentSnapshot.query.filter_by(application_id=app_id).order_by(DeploymentSnapshot.created_at.desc(), DeploymentSnapshot.id.desc()).limit(limit).all()::1",
+ "api/source_connections.py::complete_github_app_manifest::persistence::User.query.get(get_jwt_identity())::1",
+ "api/source_connections.py::update_bitbucket_admin_config::persistence::User.query.get(get_jwt_identity())::1",
+ "api/source_connections.py::update_github_admin_config::persistence::User.query.get(get_jwt_identity())::1",
+ "api/source_connections.py::update_gitlab_admin_config::persistence::User.query.get(get_jwt_identity())::1",
+ "api/sso.py::_complete_sso_login::persistence::db.session.commit()::1",
+ "api/sso.py::_complete_sso_login::persistence::db.session.commit()::2",
+ "api/sso.py::get_sso_config::persistence::User.query.get(get_jwt_identity())::1",
+ "api/sso.py::link_provider::persistence::OAuthIdentity.query.filter_by(provider=provider, provider_user_id=profile['provider_user_id']).first()::1",
+ "api/sso.py::list_identities::persistence::OAuthIdentity.query.filter_by(user_id=user_id).all()::1",
+ "api/sso.py::update_general_settings::persistence::User.query.get(get_jwt_identity())::1",
+ "api/sso.py::update_provider_config::persistence::User.query.get(get_jwt_identity())::1",
+ "api/survey.py::diff_surveys._load::persistence::ServerSurvey.query.filter_by(id=int(raw), server_id=server_id).first()::1",
+ "api/survey.py::get_survey::persistence::ServerSurvey.query.filter_by(id=survey_id, server_id=server_id).first()::1",
+ "api/survey.py::list_surveys::persistence::Server.query.get(server_id)::1",
+ "api/survey.py::observed_status::persistence::Server.query.get(server_id)::1",
+ "api/survey.py::run_survey::persistence::Server.query.get(server_id)::1",
+ "api/survey.py::set_management_mode::persistence::Server.query.get(server_id)::1",
+ "api/survey.py::set_management_mode::persistence::db.session.commit()::1",
+ "api/system.py::get_capacity::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_cpu_metrics::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_disk_metrics::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_host_snapshot::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_host_snapshot_history::persistence::HostSnapshot.query.order_by(HostSnapshot.captured_at.desc(), HostSnapshot.id.desc()).limit(limit).all()::1",
+ "api/system.py::get_host_snapshot_history::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_memory_metrics::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_metrics::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_network_metrics::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_processes::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_resource_tier::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_services::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_system_info::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_system_notices::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::get_timezones::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::set_capacity_profile::persistence::User.query.get(current_user_id)::1",
+ "api/system.py::set_timezone::persistence::User.query.get(current_user_id)::1",
+ "api/telemetry.py::list_event_types::persistence::db.session.query(SystemEvent.event_type)::1",
+ "api/telemetry.py::list_sources::persistence::db.session.query(SystemEvent.source)::1",
+ "api/templates.py::check_app_update::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/templates.py::check_app_update::persistence::User.query.get(current_user_id)::1",
+ "api/templates.py::get_app_template_info::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/templates.py::get_app_template_info::persistence::User.query.get(current_user_id)::1",
+ "api/templates.py::update_app::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/templates.py::validate_installation::persistence::Application.query.filter_by(name=app_name).first()::1",
+ "api/themes.py::_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/two_factor.py::confirm_2fa_setup::persistence::User.query.get(current_user_id)::1",
+ "api/two_factor.py::disable_2fa::persistence::User.query.get(current_user_id)::1",
+ "api/two_factor.py::get_2fa_status::persistence::User.query.get(current_user_id)::1",
+ "api/two_factor.py::initiate_2fa_setup::persistence::User.query.get(current_user_id)::1",
+ "api/two_factor.py::regenerate_backup_codes::persistence::User.query.get(current_user_id)::1",
+ "api/two_factor.py::verify_2fa_code::persistence::User.query.get(user_id)::1",
+ "api/two_factor.py::verify_2fa_code::persistence::db.session.commit()::1",
+ "api/two_factor.py::verify_2fa_code::persistence::db.session.commit()::2",
+ "api/two_factor.py::verify_2fa_code::persistence::db.session.commit()::3",
+ "api/waf.py::_get_application_or_404::persistence::Application.query_active().filter_by(id=app_id).first()::1",
+ "api/waf.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1",
+ "api/webhooks.py::receive_pull_request::persistence::ApplicationPreview.query.filter_by(application_id=webhook.app_id, pr_number=pr.get('pr_number')).first()::1",
+ "api/webhooks.py::receive_pull_request::persistence::GitWebhook.query.filter_by(webhook_token=token).first()::1",
+ "api/workspaces.py::get_current_user::persistence::User.query.get(get_jwt_identity())::1"
+ ]
+}
diff --git a/backend/tests/api_controller_boundary_scan.py b/backend/tests/api_controller_boundary_scan.py
new file mode 100644
index 00000000..de447245
--- /dev/null
+++ b/backend/tests/api_controller_boundary_scan.py
@@ -0,0 +1,282 @@
+"""Inventory architectural boundary crossings in Flask API controllers.
+
+The scanner deliberately uses the Python AST instead of text matching so
+comments and strings do not become debt. A call-site fingerprint excludes line
+numbers, which keeps the baseline stable when surrounding code moves, while
+still recording the controller function and normalized call expression.
+
+Run this file with ``--write-baseline`` after intentionally removing boundary
+crossings. Any newly discovered call site should first be moved behind a
+service; accepting one into the baseline requires an explicit reviewed diff.
+"""
+
+from __future__ import annotations
+
+import argparse
+import ast
+import json
+import re
+from collections import Counter
+from dataclasses import dataclass
+from pathlib import Path
+
+
+BACKEND_ROOT = Path(__file__).resolve().parents[1]
+API_ROOT = BACKEND_ROOT / 'app' / 'api'
+BASELINE_PATH = Path(__file__).with_name('api_controller_boundary_baseline.json')
+
+SUBPROCESS_CALLS = {
+ 'subprocess.call',
+ 'subprocess.check_call',
+ 'subprocess.check_output',
+ 'subprocess.Popen',
+ 'subprocess.run',
+}
+OS_MUTATIONS = {
+ 'chmod', 'chown', 'lchmod', 'link', 'makedirs', 'mkdir', 'mknod',
+ 'remove', 'removedirs', 'rename', 'renames', 'replace', 'rmdir',
+ 'symlink', 'truncate', 'unlink',
+}
+SHUTIL_MUTATIONS = {
+ 'copy', 'copy2', 'copyfile', 'copymode', 'copystat', 'copytree',
+ 'move', 'rmtree',
+}
+PATH_MUTATIONS = {
+ 'chmod', 'hardlink_to', 'link_to', 'mkdir', 'rename', 'replace',
+ 'rmdir', 'symlink_to', 'touch', 'unlink', 'write_bytes', 'write_text',
+}
+WRITE_OPEN_MODES = {'a', 'w', 'x', '+'}
+
+
+@dataclass(frozen=True)
+class BoundaryCall:
+ fingerprint: str
+ category: str
+ file: str
+ function: str
+ expression: str
+
+
+def _dotted_name(node: ast.AST, aliases: dict[str, str] | None = None) -> str | None:
+ if isinstance(node, ast.Name):
+ return (aliases or {}).get(node.id, node.id)
+ if isinstance(node, ast.Attribute):
+ parent = _dotted_name(node.value, aliases)
+ return f'{parent}.{node.attr}' if parent else None
+ return None
+
+
+def _import_aliases(tree: ast.Module) -> dict[str, str]:
+ aliases = {}
+ for node in tree.body:
+ if isinstance(node, ast.Import):
+ for imported in node.names:
+ local = imported.asname or imported.name.split('.')[0]
+ aliases[local] = imported.name
+ elif isinstance(node, ast.ImportFrom) and node.module:
+ for imported in node.names:
+ if imported.name == '*':
+ continue
+ local = imported.asname or imported.name
+ aliases[local] = f'{node.module}.{imported.name}'
+ return aliases
+
+
+def _is_controller(tree: ast.Module, aliases: dict[str, str]) -> bool:
+ return any(
+ isinstance(node, ast.Call)
+ and _dotted_name(node.func, aliases) in {'Blueprint', 'flask.Blueprint'}
+ for node in ast.walk(tree)
+ )
+
+
+def _contains_model_query(node: ast.AST) -> bool:
+ """Recognize Flask-SQLAlchemy ``Model.query*`` entry points."""
+ return any(
+ isinstance(child, ast.Attribute)
+ and isinstance(child.value, ast.Name)
+ and child.value.id[:1].isupper()
+ and (child.attr == 'query' or child.attr.startswith('query_'))
+ for child in ast.walk(node)
+ )
+
+
+def _open_writes(call: ast.Call, aliases: dict[str, str]) -> bool:
+ if _dotted_name(call.func, aliases) not in {'open', 'Path.open', 'pathlib.Path.open'}:
+ return False
+ mode_node = call.args[1] if len(call.args) > 1 else next(
+ (keyword.value for keyword in call.keywords if keyword.arg == 'mode'),
+ None,
+ )
+ return (
+ isinstance(mode_node, ast.Constant)
+ and isinstance(mode_node.value, str)
+ and any(marker in mode_node.value for marker in WRITE_OPEN_MODES)
+ )
+
+
+def _path_constructor_mutation(call: ast.Call, aliases: dict[str, str]) -> bool:
+ if not isinstance(call.func, ast.Attribute) or call.func.attr not in PATH_MUTATIONS:
+ return False
+ receiver = call.func.value
+ return (
+ isinstance(receiver, ast.Call)
+ and _dotted_name(receiver.func, aliases) in {'Path', 'pathlib.Path'}
+ )
+
+
+def _category(call: ast.Call, aliases: dict[str, str]) -> str | None:
+ dotted = _dotted_name(call.func, aliases)
+ direct_session = dotted and (
+ dotted.startswith('db.session.') or '.db.session.' in dotted
+ )
+ if direct_session or _contains_model_query(call.func):
+ return 'persistence'
+ if dotted in SUBPROCESS_CALLS:
+ return 'subprocess'
+ if dotted and (
+ (dotted.startswith('os.') and dotted.rsplit('.', 1)[-1] in OS_MUTATIONS)
+ or (dotted.startswith('shutil.') and dotted.rsplit('.', 1)[-1] in SHUTIL_MUTATIONS)
+ ):
+ return 'filesystem'
+ if _path_constructor_mutation(call, aliases) or _open_writes(call, aliases):
+ return 'filesystem'
+ return None
+
+
+def _enclosing_function(node: ast.AST, parents: dict[ast.AST, ast.AST]) -> str:
+ names = []
+ current = parents.get(node)
+ while current is not None:
+ if isinstance(current, (ast.FunctionDef, ast.AsyncFunctionDef)):
+ names.append(current.name)
+ current = parents.get(current)
+ return '.'.join(reversed(names)) if names else '<module>'
+
+
+def _normalized_expression(call: ast.Call) -> str:
+ return re.sub(r'\s+', ' ', ast.unparse(call)).strip()
+
+
+def scan_source(source: str, relative_path: str = 'api/example.py') -> list[BoundaryCall]:
+ """Scan one controller source string; primarily useful for detector tests."""
+ tree = ast.parse(source, filename=relative_path)
+ aliases = _import_aliases(tree)
+ if not _is_controller(tree, aliases):
+ return []
+
+ parents: dict[ast.AST, ast.AST] = {}
+ for parent in ast.walk(tree):
+ for child in ast.iter_child_nodes(parent):
+ parents[child] = parent
+
+ categorized = {
+ node: category
+ for node in ast.walk(tree)
+ if isinstance(node, ast.Call)
+ if (category := _category(node, aliases)) is not None
+ }
+
+ def nested_in_same_call_chain(node: ast.Call, category: str) -> bool:
+ current: ast.AST = node
+ parent = parents.get(current)
+ while parent is not None:
+ follows_receiver = (
+ isinstance(parent, ast.Attribute) and parent.value is current
+ )
+ follows_function = isinstance(parent, ast.Call) and parent.func is current
+ if not (follows_receiver or follows_function):
+ return False
+ if isinstance(parent, ast.Call) and categorized.get(parent) == category:
+ return True
+ current, parent = parent, parents.get(parent)
+ return False
+
+ discovered = []
+ occurrences: Counter[tuple[str, str, str]] = Counter()
+ for node, category in categorized.items():
+ if nested_in_same_call_chain(node, category):
+ continue
+ function = _enclosing_function(node, parents)
+ expression = _normalized_expression(node)
+ occurrence_key = (function, category, expression)
+ occurrences[occurrence_key] += 1
+ ordinal = occurrences[occurrence_key]
+ fingerprint = (
+ f'{relative_path}::{function}::{category}::{expression}::{ordinal}'
+ )
+ discovered.append(BoundaryCall(
+ fingerprint=fingerprint,
+ category=category,
+ file=relative_path,
+ function=function,
+ expression=expression,
+ ))
+ return sorted(discovered, key=lambda item: item.fingerprint)
+
+
+def scan_api_controllers() -> list[BoundaryCall]:
+ discovered = []
+ for path in sorted(API_ROOT.glob('*.py')):
+ relative = path.relative_to(BACKEND_ROOT / 'app').as_posix()
+ discovered.extend(scan_source(path.read_text(encoding='utf-8'), relative))
+ return sorted(discovered, key=lambda item: item.fingerprint)
+
+
+def _default_owner(relative_path: str) -> dict[str, str]:
+ domain = Path(relative_path).stem.replace('_', ' ')
+ return {
+ 'owner': f'ServerKit backend / {domain} domain',
+ 'rationale': (
+ f'Legacy {domain} controllers still cross a persistence or host-operation '
+ 'boundary; move each call into an app.services use case before removing it.'
+ ),
+ }
+
+
+def write_baseline(path: Path = BASELINE_PATH) -> dict:
+ calls = scan_api_controllers()
+ previous = {}
+ if path.exists():
+ previous = json.loads(path.read_text(encoding='utf-8')).get('owners', {})
+ files = sorted({call.file for call in calls})
+ payload = {
+ 'schema_version': 1,
+ 'policy': (
+ 'Exact reviewed inventory of direct persistence, subprocess, and filesystem '
+ 'mutation calls in Flask API controllers. New calls are forbidden; remove '
+ 'entries as controllers delegate to services.'
+ ),
+ 'counts': dict(sorted(Counter(call.category for call in calls).items())),
+ 'owners': {
+ file: previous.get(file, _default_owner(file))
+ for file in files
+ },
+ # The fingerprint itself contains the file, controller function,
+ # category, normalized expression, and duplicate ordinal. Keeping the
+ # compact string makes a 600-call legacy inventory reviewable in git.
+ 'violations': [call.fingerprint for call in calls],
+ }
+ path.write_text(json.dumps(payload, indent=2) + '\n', encoding='utf-8')
+ return payload
+
+
+def main() -> int:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ '--write-baseline',
+ action='store_true',
+ help='replace the reviewed baseline with the current exact inventory',
+ )
+ args = parser.parse_args()
+ if args.write_baseline:
+ payload = write_baseline()
+ print(f'wrote {len(payload["violations"])} calls to {BASELINE_PATH}')
+ return 0
+ calls = scan_api_controllers()
+ print(json.dumps(dict(sorted(Counter(call.category for call in calls).items())), indent=2))
+ return 0
+
+
+if __name__ == '__main__':
+ raise SystemExit(main())
diff --git a/backend/tests/test_api_controller_boundaries.py b/backend/tests/test_api_controller_boundaries.py
new file mode 100644
index 00000000..ca71f54f
--- /dev/null
+++ b/backend/tests/test_api_controller_boundaries.py
@@ -0,0 +1,88 @@
+"""Architecture ratchet for thin Flask API controllers."""
+
+import json
+from collections import Counter
+
+from api_controller_boundary_scan import (
+ BASELINE_PATH,
+ scan_api_controllers,
+ scan_source,
+)
+
+
+def test_controller_boundary_inventory_is_exact_and_owned():
+ baseline = json.loads(BASELINE_PATH.read_text(encoding='utf-8'))
+ discovered = scan_api_controllers()
+ actual = {call.fingerprint for call in discovered}
+ expected = set(baseline['violations'])
+
+ added = sorted(actual - expected)
+ stale = sorted(expected - actual)
+ assert not added and not stale, (
+ 'API controller boundary inventory changed. Move new crossings behind '
+ 'a service. After an intentional debt reduction, run '
+ '`python backend/tests/api_controller_boundary_scan.py '
+ '--write-baseline` and review the baseline diff.\n'
+ f'new={added[:20]}\nstale={stale[:20]}'
+ )
+
+ counts = dict(sorted(Counter(call.category for call in discovered).items()))
+ assert counts == baseline['counts']
+ assert baseline['schema_version'] == 1
+ assert baseline['policy'].strip()
+
+ files = {call.file for call in discovered}
+ assert set(baseline['owners']) == files
+ for file, decision in baseline['owners'].items():
+ assert decision['owner'].strip(), file
+ assert decision['rationale'].strip(), file
+
+
+def test_boundary_detector_covers_supported_crossings():
+ source = '''
+import os
+import shutil
+import subprocess
+from app import db as database
+from flask import Blueprint
+from os import unlink as remove_alias
+from pathlib import Path
+from subprocess import run as run_alias
+
+bp = Blueprint("sample", __name__)
+
+def sample():
+ User.query.filter_by(active=True).first()
+ Application.query_active().first()
+ database.session.commit()
+ subprocess.run(["true"])
+ run_alias(["true"])
+ os.remove("one")
+ remove_alias("alias")
+ shutil.rmtree("two")
+ Path("three").write_text("value")
+ open("four", "wb")
+ open("read-only", "rb")
+'''
+ calls = scan_source(source)
+ categories = Counter(call.category for call in calls)
+
+ assert categories == {
+ 'persistence': 3,
+ 'subprocess': 2,
+ 'filesystem': 5,
+ }
+ assert not any('read-only' in call.expression for call in calls)
+
+
+def test_non_controller_modules_are_outside_the_controller_ratchet():
+ assert scan_source('db.session.commit()') == []
+
+
+def test_invitations_controller_has_converged_on_its_service_boundary():
+ calls = [
+ call for call in scan_api_controllers()
+ if call.file == 'api/invitations.py'
+ ]
+ assert calls == []
diff --git a/backend/tests/test_invitation_service_boundary.py b/backend/tests/test_invitation_service_boundary.py
new file mode 100644
index 00000000..60c761af
--- /dev/null
+++ b/backend/tests/test_invitation_service_boundary.py
@@ -0,0 +1,96 @@
+"""Coverage for invitation use cases moved out of the HTTP controller."""
+
+import pytest
+
+
+def _invitation(db, inviter_id, *, email='[email protected]', status='pending'):
+ from app.models import Invitation
+
+ invitation = Invitation(
+ email=email,
+ role='developer',
+ invited_by=inviter_id,
+ status=status,
+ )
+ db.session.add(invitation)
+ db.session.commit()
+ return invitation
+
+
+ ('email', 'status', 'reason'),
+ [
+ ('[email protected]', 'accepted', 'not_pending'),
+ (None, 'pending', 'missing_email'),
+ ],
+)
+def test_resend_candidate_rules_live_in_service(
+ app, db_session, auth_headers, email, status, reason):
+ from app.models import User
+ from app.services.invitation_service import InvitationService
+
+ inviter = User.query.filter_by(username='testadmin').one()
+ invitation = _invitation(
+ db_session,
+ inviter.id,
+ email=email,
+ status=status,
+ )
+
+ result = InvitationService.get_resend_candidate(invitation.id)
+
+ assert result == {
+ 'success': False,
+ 'reason': reason,
+ 'error': (
+ 'Can only resend pending invitations'
+ if reason == 'not_pending'
+ else 'Invitation has no email address'
+ ),
+ }
+
+
+def test_resend_candidate_returns_pending_email_invitation(
+ app, db_session, auth_headers):
+ from app.models import User
+ from app.services.invitation_service import InvitationService
+
+ inviter = User.query.filter_by(username='testadmin').one()
+ invitation = _invitation(db_session, inviter.id)
+
+ result = InvitationService.get_resend_candidate(invitation.id)
+
+ assert result['success'] is True
+ assert result['invitation'].id == invitation.id
+
+
+def test_resend_endpoint_delegates_candidate_lookup_and_delivery(
+ client, auth_headers, monkeypatch):
+ from app.services.invitation_service import InvitationService
+
+ candidate = type('InvitationStub', (), {'email': '[email protected]'})()
+ monkeypatch.setattr(
+ InvitationService,
+ 'get_resend_candidate',
+ staticmethod(lambda invitation_id: {
+ 'success': True,
+ 'invitation': candidate,
+ }),
+ )
+ delivered = []
+ monkeypatch.setattr(
+ InvitationService,
+ 'send_invitation_email',
+ staticmethod(lambda invitation, base_url: delivered.append(
+ (invitation, base_url)
+ ) or {'success': True}),
+ )
+
+ response = client.post(
+ '/api/v1/admin/invitations/resend/42',
+ headers=auth_headers,
+ )
+
+ assert response.status_code == 200
+ assert response.get_json() == {'message': 'Invitation email resent'}
+ assert delivered and delivered[0][0] is candidate