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.

fix(ratchets): reconcile plan-77 additions with the standing gates

Juan Denis3dbd234eb647
diff --git a/backend/app/api/runs.py b/backend/app/api/runs.py
index 0416e3c3..6af9a45f 100644
--- a/backend/app/api/runs.py
+++ b/backend/app/api/runs.py
@@ -7,19 +7,15 @@ keeps its richer legacy endpoint (/api/v1/deployment-jobs/<id>/logs) — this
one serves every kind stored in run_log_entries.
"""
from flask import Blueprint, jsonify, request
-from flask_jwt_extended import jwt_required
-from app.models.run_log import RunLogEntry
+from app.middleware.rbac import auth_required
+from app.services.run_log_service import list_run_logs
runs_bp = Blueprint('runs', __name__)
@runs_bp.route('/<run_kind>/<run_id>/logs', methods=['GET'])
-@jwt_required()
+@auth_required()
def get_run_logs(run_kind, run_id):
after_id = request.args.get('after_id', type=int)
- query = RunLogEntry.query.filter_by(run_kind=run_kind, run_id=str(run_id))
- if after_id:
- query = query.filter(RunLogEntry.id > after_id)
- rows = query.order_by(RunLogEntry.id.asc()).limit(2000).all()
- return jsonify({'logs': [row.to_dict() for row in rows]}), 200
+ return jsonify({'logs': list_run_logs(run_kind, run_id, after_id=after_id)}), 200
diff --git a/backend/app/services/run_log_service.py b/backend/app/services/run_log_service.py
index 435de995..2fb0e029 100644
--- a/backend/app/services/run_log_service.py
+++ b/backend/app/services/run_log_service.py
@@ -439,3 +439,17 @@ def append_log(job, level: str, message: str, data: Any = None,
stream = RunLogStream.for_job(job)
stream.log(level, message, step_index=step_index, data=data)
stream.flush()
+
+
+def list_run_logs(run_kind: str, run_id, after_id: Optional[int] = None,
+ limit: int = 2000) -> List[dict]:
+ """Persisted run-envelope lines for (run_kind, run_id), id-ordered.
+
+ The service half of the ``GET /api/v1/runs/<kind>/<id>/logs?after_id``
+ resync twin — the API layer never touches the model directly.
+ """
+ from app.models.run_log import RunLogEntry
+ query = RunLogEntry.query.filter_by(run_kind=run_kind, run_id=str(run_id))
+ if after_id:
+ query = query.filter(RunLogEntry.id > after_id)
+ return [row.to_dict() for row in query.order_by(RunLogEntry.id.asc()).limit(limit).all()]
diff --git a/backend/tests/api_controller_boundary_baseline.json b/backend/tests/api_controller_boundary_baseline.json
index 249669a2..b3470f89 100644
--- a/backend/tests/api_controller_boundary_baseline.json
+++ b/backend/tests/api_controller_boundary_baseline.json
@@ -295,7 +295,7 @@
"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::ManagedDatabase.query_active().filter_by(owner_application_id=app.id).all()::1",
"api/apps.py::get_app_resources::persistence::Application.query_active().filter_by(id=app_id).first()::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",
@@ -657,7 +657,7 @@
"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::ManagedDatabase.query_active().filter_by(id=int(resource_id)).first()::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",
diff --git a/backend/tests/test_core_blueprint_registry.py b/backend/tests/test_core_blueprint_registry.py
index 8bcec102..c90d97c1 100644
--- a/backend/tests/test_core_blueprint_registry.py
+++ b/backend/tests/test_core_blueprint_registry.py
@@ -7,9 +7,9 @@ from pathlib import Path
from app.core_blueprints import CORE_BLUEPRINTS
-EXPECTED_CORE_BLUEPRINT_COUNT = 108
+EXPECTED_CORE_BLUEPRINT_COUNT = 109
EXPECTED_MANIFEST_SHA256 = (
- '133401be7b9636eaf7cea93a2222fe9e4f85e7dba433eae88d03ac37a351cf7e'
+ '21e01071b82c9594f233bda5682bf044560ede6df3789ab95752f5adcf31d6d1'
)
diff --git a/backend/tests/test_crypto_one_door_ratchet.py b/backend/tests/test_crypto_one_door_ratchet.py
index 071566a9..e75e197b 100644
--- a/backend/tests/test_crypto_one_door_ratchet.py
+++ b/backend/tests/test_crypto_one_door_ratchet.py
@@ -26,6 +26,7 @@ ALLOWED = {
'services/manifest_apply_service.py',
'services/secret_vault_service.py', # owns SecretVault writes by design
'services/settings_service.py',
+ 'services/sso_service.py', # C2 fold-in: token crypto with legacy dual-read lives here
'services/storage_provider_service.py',
'services/source_connection_service.py', # SettingsService-held PEM/webhook secret
'api/ai.py',