rename(547): the server is grimoire — package, image, DB defaults, backups
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 56s
CI & Build / integration (push) Successful in 1m4s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 44s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 56s
CI & Build / integration (push) Successful in 1m4s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 44s
Step 2 of the Scribe -> Grimoire rename. - src/scribe -> src/grimoire, and every import, patch target, module path, hypercorn entry point and `python -m grimoire.restore` with it; pyproject, uv.lock and the frontend package are named grimoire. - Image git.fabledsword.com/bvandeusen/fabledgrimoire; CI's Postgres service runs as grimoire / grimoire_test. - Compose files default the DB user, database and (prod) volume to grimoire, each overridable from .env, so an install created as Scribe keeps its data by setting POSTGRES_USER, POSTGRES_DB and PGDATA_VOLUME. - Backups are written as grimoire-<ts>.tar with format grimoire-backup-tar. Archives named scribe-* with the scribe-backup-tar manifest still restore and are still counted at the destination (folder and S3), with tests. - Exports, the MCP auth realm, the ASGI scope key and the persistent logger carry the new name. Kept on purpose: the secret-sealing key label stays "scribe.secrets.v1", because every stored secret was derived under it. Plugin identity (plugin name, hooks, env vars, .scribe marker, skills) is step 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
"""Canonical-system routes — the GLOBAL area vocabulary, and the mapping of a
|
||||
project's Systems onto it.
|
||||
|
||||
Two shapes live here because they are two halves of one idea:
|
||||
|
||||
- `/api/canonical-systems` — the catalog itself. Readable by any signed-in
|
||||
user (it is shared vocabulary, not user data); writable only by an admin,
|
||||
since a global list anyone can extend stops being a shared list.
|
||||
- the mapping endpoints — authorised by the PROJECT, because mapping writes a
|
||||
project's own System row. The service enforces both; these are thin wrappers.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from quart import Blueprint, jsonify, request
|
||||
|
||||
from grimoire.auth import admin_required, get_current_user_id, login_required
|
||||
from grimoire.routes.utils import not_found
|
||||
from grimoire.services import canonical_systems as canonical_svc
|
||||
from grimoire.services.projects import get_project_for_user
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
canonical_systems_bp = Blueprint("canonical_systems", __name__, url_prefix="/api")
|
||||
|
||||
|
||||
@canonical_systems_bp.route("/canonical-systems", methods=["GET"])
|
||||
@login_required
|
||||
async def list_canonical_systems_route():
|
||||
entries = await canonical_svc.list_canonical_systems()
|
||||
return jsonify({"canonical_systems": [e.to_dict() for e in entries]})
|
||||
|
||||
|
||||
@canonical_systems_bp.route("/canonical-systems", methods=["POST"])
|
||||
@admin_required
|
||||
async def create_canonical_system_route():
|
||||
uid = get_current_user_id()
|
||||
data = await request.get_json() or {}
|
||||
if not (data.get("name") or "").strip():
|
||||
return jsonify({"error": "name is required"}), 400
|
||||
entry = await canonical_svc.create_canonical_system(
|
||||
uid, data["name"], description=data.get("description"),
|
||||
)
|
||||
if entry is None:
|
||||
return jsonify({"error": "Permission denied"}), 403
|
||||
# The slug duplicate gate answers with the entry that already covers the
|
||||
# area rather than minting a second spelling of it — 409, not a silent
|
||||
# second row (the whole point of the table).
|
||||
if isinstance(entry, dict):
|
||||
return jsonify(entry), 409
|
||||
return jsonify(entry.to_dict()), 201
|
||||
|
||||
|
||||
@canonical_systems_bp.route("/canonical-systems/<int:canonical_id>", methods=["PATCH"])
|
||||
@admin_required
|
||||
async def update_canonical_system_route(canonical_id: int):
|
||||
uid = get_current_user_id()
|
||||
data = await request.get_json() or {}
|
||||
fields = {k: v for k, v in data.items() if k in ("name", "description", "order_index")}
|
||||
entry = await canonical_svc.update_canonical_system(uid, canonical_id, **fields)
|
||||
if entry is None:
|
||||
return not_found("Canonical system")
|
||||
return jsonify(entry.to_dict())
|
||||
|
||||
|
||||
@canonical_systems_bp.route(
|
||||
"/projects/<int:project_id>/canonical-proposals", methods=["GET"]
|
||||
)
|
||||
@login_required
|
||||
async def propose_canonical_mappings_route(project_id: int):
|
||||
"""Proposals only — this endpoint writes nothing. The PUT below applies one."""
|
||||
uid = get_current_user_id()
|
||||
if await get_project_for_user(uid, project_id) is None:
|
||||
return not_found("Project")
|
||||
return jsonify({"proposals": await canonical_svc.propose_mappings(uid, project_id)})
|
||||
|
||||
|
||||
@canonical_systems_bp.route("/systems/<int:system_id>/canonical", methods=["PUT"])
|
||||
@login_required
|
||||
async def map_system_to_canonical_route(system_id: int):
|
||||
"""Map or unmap one System. Body: {"canonical_id": <id>|null}.
|
||||
|
||||
Sets that column and nothing else — no rename, no change to which records
|
||||
are tagged to the System.
|
||||
"""
|
||||
uid = get_current_user_id()
|
||||
data = await request.get_json() or {}
|
||||
canonical_id = data.get("canonical_id")
|
||||
if canonical_id is not None and not isinstance(canonical_id, int):
|
||||
return jsonify({"error": "canonical_id must be an integer or null"}), 400
|
||||
system = await canonical_svc.set_system_canonical(uid, system_id, canonical_id)
|
||||
if system is None:
|
||||
return not_found("System or canonical system")
|
||||
return jsonify(system.to_dict())
|
||||
Reference in New Issue
Block a user