Files
moloapp/src/governance/surface/SurfaceRules.h
T
retoor 3c4334cec9 feat: implement MoloApp plans 01-15 with integration
Full C++23 framework tree: runtime, observability, security,
data, app, realtime, supervisor, clients, CLI, example plus
enterprise tenancy, audit, operability, governance,
supplychain. Postgres via docker compose for tests.
2026-10-23 18:20:04 +02:00

47 lines
1.7 KiB
C++

#pragma once
#include <string>
#include <string_view>
#include <vector>
namespace molo::govern::surface {
// Route surface rules S1-S10. Metadata only; RouteLinter enforces them.
// S1 plural nouns, S2 method semantics, S3 status set, S4 problem body,
// S5 pagination envelope, S6 query-only filters, S7 auth declared,
// S8 Idempotency-Key, S9 summary plus example, S10 version prefix.
class SurfaceRules {
public:
struct Finding {
std::string rule;
std::string severity; // "ERR" or "WARN"
std::string target;
std::string message;
};
[[nodiscard]] static std::vector<std::string> RuleIds() {
return {"S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", "S10"};
}
[[nodiscard]] static std::string_view Describe(std::string_view id) {
if (id == "S1") return "collection segments use plural nouns";
if (id == "S2") return "method semantics: known method, no body on GET/HEAD/DELETE";
if (id == "S3") return "status set: at least one 2xx, only known codes";
if (id == "S4") return "error statuses declare a problem body";
if (id == "S5") return "paginated routes use page/per_page plus {data,meta,links}";
if (id == "S6") return "filters travel in query params only";
if (id == "S7") return "auth declared: none|key|key+scopes|session";
if (id == "S8") return "POST/PUT/PATCH accept Idempotency-Key";
if (id == "S9") return "route has summary and example";
if (id == "S10") return "path carries a /v{n} prefix";
return "unknown rule";
}
[[nodiscard]] static std::string_view SeverityOf(std::string_view id) {
if (id == "S2" || id == "S3" || id == "S5" || id == "S7" || id == "S10") return "ERR";
return "WARN";
}
};
} // namespace molo::govern::surface