"""Design-system surface — what the rulebook expects of the stylesheet. The client owns the other half of the comparison: it reads live token values from the browser (see `utils/designTokens.ts`), which is the only place they exist resolved. This endpoint supplies the claims to check them against. """ from quart import Blueprint, jsonify from scribe.auth import get_current_user_id, login_required from scribe.services import design_system as design_svc design_bp = Blueprint("design", __name__, url_prefix="/api/design") @design_bp.get("/expectations") @login_required async def get_expectations(): """Checkable claims from the rulebook this install designated as its design system. Returns `{"rulebook_id": int|null, "expectations": [...]}`. `rulebook_id: null` is the NORMAL case, not an error — an install that has not designated a design rulebook has nothing to compare against, and the client shows an explanatory empty state (rule #115). Distinguishing it from "designated but empty" is why the id is returned alongside the list. """ uid = get_current_user_id() result = await design_svc.design_expectations(uid) return jsonify(result.as_dict())