Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(crds): add llmhook crd + host.spec.guardrails block (bucket b slice a)

Andy Pavia1e5c14f803ee
diff --git a/charts/clerum-crds/Chart.yaml b/charts/clerum-crds/Chart.yaml
index f4d216e7f..d71d64ce9 100644
--- a/charts/clerum-crds/Chart.yaml
+++ b/charts/clerum-crds/Chart.yaml
@@ -1,8 +1,8 @@
apiVersion: v2
name: clerum-crds
-description: Custom Resource Definitions for Clerum (CommunicationChannel, Context, Host, McpServer, WorkflowRecipe, WorkflowRecipePolicy). WorkflowRun CRD has been removed; workflow runs are now DB-first in control-postgres.
+description: Custom Resource Definitions for Clerum (CommunicationChannel, Context, Host, LlmHook, McpServer, WorkflowRecipe, WorkflowRecipePolicy). WorkflowRun CRD has been removed; workflow runs are now DB-first in control-postgres.
type: application
-version: 0.7.0
+version: 0.8.0
appVersion: "1"
keywords:
- clerum
@@ -11,6 +11,7 @@ keywords:
- host
- context
- mcp-server
+ - llm-hook
- workload-recipe-policy
maintainers:
- name: Clerum
diff --git a/charts/clerum-crds/README.md b/charts/clerum-crds/README.md
index 6d41013bc..cf0276b69 100644
--- a/charts/clerum-crds/README.md
+++ b/charts/clerum-crds/README.md
@@ -10,6 +10,7 @@ code name; public product name is **evenfire**).
| Host | `hosts.clerum.io` |
| Context | `contexts.clerum.io` |
| McpServer | `mcpservers.clerum.io` |
+| LlmHook | `llmhooks.clerum.io` |
| CommunicationChannel | `communicationchannels.clerum.io` |
| WorkflowRecipe | `workflowrecipes.clerum.io` |
| WorkflowRecipePolicy | `workflowrecipepolicies.clerum.io` |
diff --git a/charts/clerum-crds/crds/host.yaml b/charts/clerum-crds/crds/host.yaml
index 4a22c362d..50b68f83b 100644
--- a/charts/clerum-crds/crds/host.yaml
+++ b/charts/clerum-crds/crds/host.yaml
@@ -339,6 +339,164 @@ spec:
user:
type: string
description: Content of USER.md (system-prompt section "## User Context").
+ guardrails:
+ # Guardrail policy (guardrails spec §5). ADDITIVE, OPT-IN: a Host
+ # with no guardrails block behaves exactly as before — no rules, no
+ # installed hooks, no built-ins (byte-identical to prior behavior).
+ #
+ # ROLLOUT ORDER — CRD FIRST. apiextensions/v1 silently PRUNES
+ # unknown fields: if the runtime writes a Host with `guardrails`
+ # while the OLD CRD (without this schema) is applied, the apiserver
+ # drops it on admission with no error. Apply this CRD before any
+ # component reads or writes spec.guardrails (mcp-host, control-api).
+ # The loosely-typed `rules` and `builtins` entries carry
+ # x-kubernetes-preserve-unknown-fields so their nested shape (which
+ # mcp-host/control-api validate) survives admission rather than
+ # being pruned.
+ type: object
+ description: >-
+ Guardrail policy for this Host: ordered tool-lane rules,
+ installed LlmHook references grouped by lifecycle phase,
+ first-party built-ins, and the capability/trust ceilings that
+ bound the installed hooks.
+ properties:
+ rules:
+ type: array
+ description: >-
+ Ordered tool-lane allow/ask/deny rules, evaluated top-down.
+ Each entry: { id, action: allow|ask|deny, reasonCode,
+ match{ tool, arguments[] } } — shape validated by
+ mcp-host/control-api (§6.1).
+ items:
+ type: object
+ x-kubernetes-preserve-unknown-fields: true
+ hooks:
+ type: object
+ description: >-
+ Installed LlmHook CRs this Host runs, grouped by lifecycle
+ phase. Each entry references an LlmHook CR by name (llm-hooks
+ namespace) plus the expected image digest (§8.2 resolution).
+ properties:
+ preToolUse:
+ type: array
+ items:
+ type: object
+ required:
+ - id
+ properties:
+ id:
+ type: string
+ digest:
+ type: string
+ postToolUse:
+ type: array
+ items:
+ type: object
+ required:
+ - id
+ properties:
+ id:
+ type: string
+ digest:
+ type: string
+ preCall:
+ type: array
+ items:
+ type: object
+ required:
+ - id
+ properties:
+ id:
+ type: string
+ digest:
+ type: string
+ moderate:
+ type: array
+ items:
+ type: object
+ required:
+ - id
+ properties:
+ id:
+ type: string
+ digest:
+ type: string
+ postCallSuccess:
+ type: array
+ items:
+ type: object
+ required:
+ - id
+ properties:
+ id:
+ type: string
+ digest:
+ type: string
+ onError:
+ type: array
+ items:
+ type: object
+ required:
+ - id
+ properties:
+ id:
+ type: string
+ digest:
+ type: string
+ builtins:
+ type: array
+ description: >-
+ First-party hooks compiled into mcp-host (§7.2). Each entry:
+ { type: prompt-shaping|token-trim|…, order, failMode,
+ timeoutMs, config } — shape validated by mcp-host.
+ items:
+ type: object
+ x-kubernetes-preserve-unknown-fields: true
+ minInstalledHookTrustLevel:
+ type: string
+ enum:
+ - low
+ - mid
+ - high
+ description: Minimum platform-assigned trust level an installed LlmHook must carry to run on this Host.
+ approvalPolicies:
+ type: array
+ description: >-
+ Approval policies available to guardrail `ask` decisions.
+ NOTE: overlaps conceptually with spec.approval.defaultPolicy;
+ reconciling the two is a follow-up decision.
+ items:
+ type: string
+ enum:
+ - cli_only
+ - channel_users
+ - designated_approvers
+ capabilityCeiling:
+ type: array
+ description: Upper bound on capabilities any installed hook may exercise on this Host.
+ items:
+ type: string
+ enum:
+ - may_deny
+ - may_rewrite
+ - may_substitute_result
+ - may_add_context
+ limits:
+ type: object
+ description: Guardrail sizing limits (defaults applied by mcp-host when omitted).
+ properties:
+ maxRules:
+ type: integer
+ default: 100
+ maxHooksPerPhase:
+ type: integer
+ default: 8
+ maxHookTimeoutMs:
+ type: integer
+ default: 5000
+ maxHookOutputBytes:
+ type: integer
+ default: 65536
status:
type: object
properties:
diff --git a/charts/clerum-crds/crds/llmhook.yaml b/charts/clerum-crds/crds/llmhook.yaml
new file mode 100644
index 000000000..849631340
--- /dev/null
+++ b/charts/clerum-crds/crds/llmhook.yaml
@@ -0,0 +1,292 @@
+apiVersion: apiextensions.k8s.io/v1
+kind: CustomResourceDefinition
+metadata:
+ name: llmhooks.clerum.io
+ labels:
+ app.kubernetes.io/name: llmhook
+ app.kubernetes.io/part-of: clerum
+spec:
+ group: clerum.io
+ names:
+ kind: LlmHook
+ listKind: LlmHookList
+ plural: llmhooks
+ singular: llmhook
+ shortNames:
+ - llmhook
+ scope: Namespaced
+ versions:
+ - name: v1alpha1
+ served: true
+ storage: true
+ schema:
+ openAPIV3Schema:
+ type: object
+ required:
+ - spec
+ description: >-
+ LlmHook defines an installed guardrail hook that mcp-host calls over the
+ /v1 protocol (guardrails spec §8). host-context-controller reconciles
+ image-target hooks into a Deployment+Service+NetworkPolicy in the
+ llm-hooks namespace (digest-dedup: hooks sharing an image digest are
+ co-located on one pod and routed by spec.path); service and remote
+ targets deploy no workload. mcp-host only READS these CRs and never
+ writes them; the status subresource is written solely by the controller.
+ properties:
+ spec:
+ type: object
+ required:
+ - target
+ - lifecyclePoints
+ properties:
+ target:
+ type: object
+ description: Exactly one of image, service, or remote.
+ oneOf:
+ - required: [image]
+ - required: [service]
+ - required: [remote]
+ properties:
+ image:
+ type: object
+ description: >-
+ In-cluster image hook. host-context-controller deploys (or
+ reuses, via digest-dedup) a Deployment+Service+NetworkPolicy
+ in the llm-hooks namespace.
+ required:
+ - ref
+ - port
+ properties:
+ ref:
+ type: string
+ description: >-
+ Container image reference. Validated against the image
+ allowlist and digest-pinned at install time (§8.5), same
+ posture as McpServer images.
+ port:
+ type: integer
+ minimum: 1
+ maximum: 65535
+ description: Port the hook HTTP server listens on.
+ imagePullSecrets:
+ type: array
+ description: Names of image pull secrets in the llm-hooks namespace.
+ items:
+ type: string
+ envSecret:
+ type: string
+ description: >-
+ Name of the hook's OWN credential Secret, resolved in the
+ llm-hooks namespace. It can never reference the mcp-host
+ LLM key or any Host secret (namespace isolation, §12.1).
+ egressBindings:
+ type: array
+ description: >-
+ External egress this hook pod is permitted. NOTE: this is
+ looser than McpServer.egressBindings (no SSRF/private-range
+ CEL hardening yet) — tracked as a follow-up (§8.2/§8.4).
+ items:
+ type: object
+ properties:
+ toFQDN:
+ type: string
+ description: Destination FQDN to allow egress to.
+ cidr:
+ type: string
+ description: Destination CIDR to allow egress to.
+ ports:
+ type: array
+ items:
+ type: integer
+ security:
+ type: object
+ description: Security context overrides for the hook pod.
+ properties:
+ addCapabilities:
+ type: array
+ default: []
+ description: >-
+ Linux capabilities to add, subset of the
+ workflow-recipe capability allowlist; enforced at
+ admission (this enum) and at reconcile.
+ items:
+ type: string
+ enum:
+ - CHOWN
+ - FOWNER
+ - DAC_OVERRIDE
+ - NET_BIND_SERVICE
+ service:
+ type: object
+ description: An existing in-cluster Service. Nothing is deployed.
+ required:
+ - name
+ - namespace
+ - port
+ properties:
+ name:
+ type: string
+ namespace:
+ type: string
+ port:
+ type: integer
+ minimum: 1
+ maximum: 65535
+ remote:
+ type: object
+ description: >-
+ External HTTPS endpoint mcp-host dials directly (SSRF-validated
+ at dial, §8.3). No proxy pod is deployed.
+ required:
+ - baseUrl
+ properties:
+ baseUrl:
+ type: string
+ pattern: '^https://'
+ description: External endpoint base URL (must be HTTPS).
+ authHeadersSecret:
+ type: string
+ description: Name of a Secret providing auth headers for the remote endpoint.
+ path:
+ type: string
+ default: '/'
+ description: >-
+ API path on the endpoint; calls go to {endpoint}{path}/v1/{point}.
+ Image hooks co-located by digest-dedup MUST each use a distinct
+ path (unique per pod, §8.2).
+ lifecyclePoints:
+ type: array
+ minItems: 1
+ description: Lifecycle points this hook subscribes to.
+ items:
+ type: string
+ enum:
+ - preCall
+ - moderate
+ - postCallSuccess
+ - onError
+ order:
+ type: integer
+ default: 100
+ description: Execution order within a lifecycle phase (lower runs first).
+ failMode:
+ type: string
+ enum:
+ - open
+ - closed
+ default: closed
+ description: >-
+ Fail posture when the hook is unavailable (§8.6). A
+ deny-authoritative hook (may_deny) MUST fail closed (CEL below).
+ timeoutMs:
+ type: integer
+ default: 5000
+ minimum: 1
+ onUnavailable:
+ type: object
+ description: Circuit-breaker behavior when the hook repeatedly fails.
+ properties:
+ mode:
+ type: string
+ enum:
+ - strict
+ - breaker
+ default: strict
+ failureThreshold:
+ type: integer
+ default: 5
+ minimum: 1
+ cooldownMs:
+ type: integer
+ default: 30000
+ minimum: 0
+ capabilities:
+ type: array
+ description: >-
+ Admin-granted capabilities (§4.3). Enforced to be within
+ Host.spec.guardrails.capabilityCeiling (§5) and re-checked on
+ every hook response (§8.1).
+ items:
+ type: string
+ enum:
+ - may_deny
+ - may_rewrite
+ - may_substitute_result
+ - may_add_context
+ config:
+ type: object
+ description: Opaque hook settings — never a trust input (§8.4).
+ x-kubernetes-preserve-unknown-fields: true
+ x-kubernetes-validations:
+ - rule: "!has(self.target.remote) || self.target.remote.baseUrl.startsWith('https://')"
+ message: "remote.baseUrl must be https://"
+ - rule: "!(has(self.capabilities) && self.capabilities.exists(c, c == 'may_deny')) || self.failMode == 'closed'"
+ message: "a deny-authoritative hook (may_deny) must fail closed"
+ status:
+ type: object
+ description: >-
+ Reconciliation state, written solely by host-context-controller. The
+ mcp-host runtime cannot write it (status subresource).
+ properties:
+ observedDigest:
+ type: string
+ description: >-
+ Image digest actually running. mcp-host binds
+ Host.spec.guardrails.hooks[].digest against this at load and
+ fails closed / skips-with-alert on mismatch (§8.2).
+ readyReplicas:
+ type: integer
+ description: Ready replicas of the reconciled hook Deployment (image target only).
+ lastReconciled:
+ type: string
+ format: date-time
+ description: Timestamp of the last successful reconcile.
+ conditions:
+ type: array
+ description: Standard K8s conditions reflecting reconciliation state (e.g. Deployed, Ready).
+ items:
+ type: object
+ required:
+ - type
+ - status
+ properties:
+ type:
+ type: string
+ description: Condition type (e.g. Ready, Deployed).
+ status:
+ type: string
+ enum:
+ - 'True'
+ - 'False'
+ - 'Unknown'
+ reason:
+ type: string
+ description: Machine-readable reason.
+ message:
+ type: string
+ description: Human-readable explanation.
+ lastTransitionTime:
+ type: string
+ format: date-time
+ observedGeneration:
+ type: integer
+ format: int64
+ description: LlmHook metadata.generation observed when writing this condition.
+ additionalPrinterColumns:
+ - name: Path
+ type: string
+ jsonPath: .spec.path
+ - name: Order
+ type: integer
+ jsonPath: .spec.order
+ - name: FailMode
+ type: string
+ jsonPath: .spec.failMode
+ - name: Digest
+ type: string
+ jsonPath: .status.observedDigest
+ - name: Ready
+ type: string
+ jsonPath: .status.conditions[?(@.type=="Ready")].status
+ subresources:
+ status: {}