<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[DVARA]]></title><description><![CDATA[DVARA]]></description><link>https://dvarahq.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 27 Oct 2026 09:42:41 GMT</lastBuildDate><atom:link href="https://dvarahq.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[A Policy Rule Describes the Violation, Not the Goal: LLM Policy Enforcement in Practice]]></title><description><![CDATA[How an LLM policy decides, what the caller sees, and what the audit record proves.]]></description><link>https://dvarahq.hashnode.dev/a-policy-rule-describes-the-violation-not-the-goal-llm-policy-enforcement-in-practice</link><guid isPermaLink="true">https://dvarahq.hashnode.dev/a-policy-rule-describes-the-violation-not-the-goal-llm-policy-enforcement-in-practice</guid><category><![CDATA[AI]]></category><category><![CDATA[llm]]></category><category><![CDATA[Security]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[DVARA]]></dc:creator><pubDate>Sat, 10 Oct 2026 01:46:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6ac995a95e349453f8de1b6b/76cc824e-029a-47b6-9a11-8dbdb03d9ede.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A YAML file full of model rules is documentation until something enforces it on every request.</p>
<p>LLM policy as code is useful when three things travel together: a reviewable rule, one shared enforcement point that sees the AI request before the provider does, and an evidence record that names the rule behind each decision. Drop any one and you lose either consistency or proof.</p>
<p>This post covers the part teams most often get wrong: how enforcement actually behaves.</p>
<h2>Conditions describe the violation</h2>
<p>A policy condition says when a rule should <strong>fire</strong>, not what the steady state should be. That distinction catches people out.</p>
<p>In DVARA, a model <code>allowlist</code> condition matches when the requested model is <strong>outside</strong> the list. The <code>DENY</code> action then blocks that violation. Read every condition as "this is the bad case":</p>
<pre><code class="language-yaml">policies:
  - id: approved-models-only
    workspace: default
    status: ACTIVE
    dsl: |
      version: "1"
      rules:
        - id: deny-legacy-model
          priority: 10
          conditions:
            model:
              denylist: [mock/legacy]
          action: DENY
          deny_message: "This model is not approved. Use mock/approved instead."
</code></pre>
<p>Four rules prevent most mistakes:</p>
<ul>
<li><strong>Conditions inside one rule are ANDed.</strong> Put independent reasons to deny in separate rules, so each denial tells the caller exactly what to fix.</li>
<li><strong>Model names are exact and case-sensitive.</strong> They are not prefixes or globs, so list every approved dated model name.</li>
<li><strong>A <code>max_tokens</code> rule checks an explicit request value.</strong> If the request omits <code>max_tokens</code>, the condition does not match, and no default is injected.</li>
<li><strong>Empty conditions are refused.</strong> A policy that looks active but checks nothing is worse than no policy.</li>
</ul>
<h2>The caller needs a contract, not a stack trace</h2>
<p>When the rule fires, the Gateway stops the request before provider dispatch and returns the message the rule's author wrote:</p>
<pre><code class="language-json">{
  "error": {
    "message": "This model is not approved. Use mock/approved instead.",
    "type": "policy_violation",
    "code": "policy_denied",
    "trace_id": "01K4V5R9X21MDN8W5A6E7ZQ3TC"
  }
}
</code></pre>
<p>That is HTTP 403 with a stable code, a trace ID, and a fix. Write denial messages for the caller, not the policy author. "Use <code>mock/approved</code> instead" is useful; "rule 10 failed" is not.</p>
<h2>Deny and warn are different controls</h2>
<p><code>DENY</code> stops the matching request. Use it when a violation must never reach the model provider.</p>
<p><code>WARN_AGENT</code> lets the call continue and attaches a governance warning to the result and the audit trail. It suits a migration period, such as moving callers off a preview model.</p>
<p>A warning is not a softer spelling of enforcement. If nothing consumes the warning, the control is only observational. Decide who reads it, and what they do, before relying on it.</p>
<h2>Evidence is what makes it auditable</h2>
<p>With the local audit file configured, the denied call is recorded as <code>POLICY_DENIED</code>, with the policy ID, rule ID, workspace, reason, and chain-integrity fields. The open-source audit file is tamper-evident through HMAC signing and hash chaining. Someone with filesystem access can still delete it, but changes become detectable rather than silent.</p>
<p>Two limits are worth stating plainly:</p>
<ul>
<li><strong>A central rule governs only traffic that passes through the Gateway.</strong> Restrict direct provider credentials and network paths, or the bypass becomes the real policy.</li>
<li><strong>LLM policy is not application authorization.</strong> A tool rule can stop an application from offering <code>cancel_order</code> to a model. Whether the signed-in human may cancel a given order is still the order service's decision.</li>
</ul>
<h2>Start with one rule and one observable result</h2>
<p>Deny one model. Send one allowed and one denied request. Confirm the error contract and the audit record. Expand only once the team can explain the behaviour and the rollback path.</p>
<p>The full guide covers the rest: what policy should and should not govern, the open-source and Enterprise boundary, and a rollout sequence that avoids outages. Read <strong><a href="https://dvarahq.com/blog/llm-policy-as-code?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=seo_refresh_q4_2026&amp;utm_content=llm_policy_as_code_excerpt">LLM Policy as Code: Rules, Enforcement, and Rollout</a></strong>.</p>
]]></content:encoded></item></channel></rss>