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" }
kind:regexis decided by the pattern alone;llmby the AI model;hybridby the pattern, with the model confirming a failure. Omitted, it isllm.pattern: a JavaScript regular expression, required forregexandhybridand stored asnullforllm. It must compile with its flags. Inline flags such as(?i)do not compile; usepatternFlags.patternFlags: any ofi,m,s,u, each at most once, stored in that order. Omitted, it isi;""means none.patternNegate:falsefails the rule when the pattern is found;truefails it when the pattern is missing.severity: omitted, it iswarning. Only failingerrorrules fail a check or block approval.appliesToDialects: engines with a connection adapter (seeGET /engines), stored in lower case;sqlserveris accepted and stored asmssql, the one name for SQL Server.appliesToEnvironments: existing environment names, matched without regard to case and stored as the environment is spelled. Empty ornullmeans every engine or environment.- Limits:
name128 characters,category64,description,remediationandpattern2000 each.nameanddescriptionare required; names are unique regardless of case.isActiveandpatternNegatemust betrueorfalse.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /compliance-rules | Every rule, ordered by name |
| GET | /compliance-rules/engines | { engines }: the engine names appliesToDialects accepts, each engine once |
| GET | /compliance-rules/:id | One rule |
| POST | /compliance-rules | Create a rule (Release Manager or admin). Answers 201 with the rule |
| PUT | /compliance-rules/:id | Replace a rule with the same body (Release Manager or admin). Fields left out take their defaults |
| DELETE | /compliance-rules/:id | Delete a rule (Release Manager or admin). Answers { success: true }. To stop a rule but keep it, set isActive: false |
| POST | /compliance-rules/test | Try 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/compliance | A 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):
POST /api/db-devops/approvalsfor a script or a release; the environment of the request, or else each script's own, decides which rules apply;POST /api/db-devops/approvals/:id/sign, checked again when signing;POST /api/db-devops/scripts/:id/approve.
Errors
| Status | Code | When |
|---|---|---|
| 400 | INVALID_RULE | The rule breaks a limit above; the message lists every problem |
| 400 | INVALID_RULE_TEST | No SQL to try, SQL over the limit, or the rule's kind, flags or pattern is invalid |
| 404 | RULE_NOT_FOUND | No rule has that id |
| 404 | SCRIPT_NOT_FOUND | No script has that id |
| 409 | RULE_NAME_TAKEN | Another rule has that name |
| 409 | COMPLIANCE_FAILED | Approval is blocked by failing rules |