Compliance Rules API

The rules scripts are checked against. Base path /api/db-devops/compliance-rules, needs an active license, signed-in callers. Reading is open to any role; creating, changing, deleting and trying a rule need a Release Manager or admin (403 otherwise). Errors answer { "error", "code" }.

Rule shape

{ "id": "uuid",
  "name": "No DROP TABLE",
  "description": "Tables are renamed, never dropped",
  "severity": "info" | "warning" | "error",
  "isActive": true,
  "kind": "regex" | "llm" | "hybrid",
  "pattern": "\\\\bDROP\\\\s+TABLE\\\\b",
  "patternNegate": false,
  "patternFlags": "i",
  "category": "destructive",
  "appliesToDialects": ["postgresql"] | null,
  "appliesToEnvironments": ["Production"] | null,
  "remediation": "Rename the table instead of dropping it",
  "createdBy": "email",
  "createdAt": "ISO", "updatedAt": "ISO" }

Endpoints

MethodEndpointDescription
GET/compliance-rulesEvery rule, ordered by name
GET/compliance-rules/engines{ engines }: the engine names appliesToDialects accepts, each engine once
GET/compliance-rules/:idOne rule
POST/compliance-rulesCreate a rule (Release Manager or admin). Answers 201 with the rule
PUT/compliance-rules/:idReplace a rule with the same body (Release Manager or admin). Fields left out take their defaults
DELETE/compliance-rules/:idDelete a rule (Release Manager or admin). Answers { success: true }. To stop a rule but keep it, set isActive: false
POST/compliance-rules/testTry a rule without saving it (Release Manager or admin): { "rule": { kind, pattern, patternFlags, patternNegate }, "script": "SQL" }, the SQL at most 200,000 characters. Answers { evaluator, pass, reason, evidence?, needsModel? }; for an llm rule pass is null and evaluator is model; for a hybrid rule that fails, needsModel is true
GET/api/db-devops/scripts/:id/complianceA script checked against the active pattern rules: { scriptId, scriptName, engine, environment, pass, checks, skipped, byAgent }. engine is the type of the script's target connection; without one, rules limited to engines are skipped. byAgent lists the llm and hybrid rules, which the Compliance Check decides

Creating, changing and deleting a rule is written to the audit log (CREATE_COMPLIANCE_RULE, UPDATE_COMPLIANCE_RULE, DELETE_COMPLIANCE_RULE). Each entry of checks is { ruleId, ruleName, pass, severity, category, evaluator, evidence?, reason, remediation }; each entry of skipped is { ruleId, ruleName, reason }.

The approval gate

While an active regex rule of severity error fails, these answer 409 with code COMPLIANCE_FAILED and a message naming the failing rules (and, for a release, the scripts):

Errors

StatusCodeWhen
400INVALID_RULEThe rule breaks a limit above; the message lists every problem
400INVALID_RULE_TESTNo SQL to try, SQL over the limit, or the rule's kind, flags or pattern is invalid
404RULE_NOT_FOUNDNo rule has that id
404SCRIPT_NOT_FOUNDNo script has that id
409RULE_NAME_TAKENAnother rule has that name
409COMPLIANCE_FAILEDApproval is blocked by failing rules