@highflame/policy 2.0.10 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/_schemas/guardrails/context.json +435 -0
  2. package/_schemas/guardrails/schema.cedarschema +225 -0
  3. package/_schemas/guardrails/templates/defaults/agentic_safety.cedar +94 -0
  4. package/_schemas/guardrails/templates/defaults/baseline.cedar +24 -0
  5. package/_schemas/guardrails/templates/defaults/injection.cedar +70 -0
  6. package/_schemas/guardrails/templates/defaults/pii.cedar +48 -0
  7. package/_schemas/guardrails/templates/defaults/secrets.cedar +40 -0
  8. package/_schemas/guardrails/templates/defaults/semantic.cedar +59 -0
  9. package/_schemas/guardrails/templates/defaults/tool_risk.cedar +58 -0
  10. package/_schemas/guardrails/templates/defaults/toxicity.cedar +76 -0
  11. package/_schemas/guardrails/templates/mcp_tool_permissions.cedar +84 -0
  12. package/_schemas/guardrails/templates/profiles/chat_assistant/privacy.cedar +22 -0
  13. package/_schemas/guardrails/templates/profiles/chat_assistant/security.cedar +35 -0
  14. package/_schemas/guardrails/templates/profiles/chat_assistant/trust_safety.cedar +43 -0
  15. package/_schemas/guardrails/templates/profiles/chat_assistant.cedar +85 -0
  16. package/_schemas/guardrails/templates/profiles/code_agent/agentic_security.cedar +109 -0
  17. package/_schemas/guardrails/templates/profiles/code_agent/security.cedar +22 -0
  18. package/_schemas/guardrails/templates/profiles/code_agent.cedar +125 -0
  19. package/_schemas/guardrails/templates/profiles/data_pipeline/agentic_security.cedar +38 -0
  20. package/_schemas/guardrails/templates/profiles/data_pipeline/privacy.cedar +40 -0
  21. package/_schemas/guardrails/templates/profiles/data_pipeline/security.cedar +49 -0
  22. package/_schemas/guardrails/templates/profiles/data_pipeline.cedar +111 -0
  23. package/_schemas/guardrails/templates/templates.json +213 -0
  24. package/dist/builder.d.ts +61 -0
  25. package/dist/builder.js +4 -2
  26. package/dist/entities.gen.d.ts +4 -0
  27. package/dist/entities.gen.js +4 -0
  28. package/dist/explain.d.ts +150 -0
  29. package/dist/explain.js +363 -0
  30. package/dist/guardrails-context.gen.d.ts +49 -0
  31. package/dist/guardrails-context.gen.js +50 -0
  32. package/dist/guardrails-defaults.gen.d.ts +61 -0
  33. package/dist/guardrails-defaults.gen.js +1278 -0
  34. package/dist/guardrails-entities.gen.d.ts +11 -0
  35. package/dist/guardrails-entities.gen.js +37 -0
  36. package/dist/index.d.ts +6 -1
  37. package/dist/index.js +6 -1
  38. package/dist/overwatch-defaults.gen.js +98 -0
  39. package/dist/parser.js +136 -4
  40. package/dist/schema.gen.d.ts +1 -1
  41. package/dist/schema.gen.js +6 -0
  42. package/dist/service-schemas.gen.d.ts +10 -0
  43. package/dist/service-schemas.gen.js +337 -1
  44. package/dist/types.d.ts +6 -1
  45. package/dist/types.js +6 -1
  46. package/package.json +5 -1
@@ -0,0 +1,213 @@
1
+ {
2
+ "service": "guardrails",
3
+ "version": "1.0.0",
4
+ "description": "Guardrails policy templates for LLM application security",
5
+ "categories": [
6
+ {
7
+ "id": "security",
8
+ "name": "Security",
9
+ "description": "Detect and block prompt injection, jailbreak attempts, and credential leakage"
10
+ },
11
+ {
12
+ "id": "privacy",
13
+ "name": "Privacy",
14
+ "description": "Detect and block personally identifiable information (PII) in prompts and responses"
15
+ },
16
+ {
17
+ "id": "trust_safety",
18
+ "name": "Trust & Safety",
19
+ "description": "Detect and block toxic, violent, hateful, sexual, or profane content"
20
+ },
21
+ {
22
+ "id": "agentic_security",
23
+ "name": "Agentic Security",
24
+ "description": "Detect tool abuse, data exfiltration patterns, infinite loops, and budget violations"
25
+ },
26
+ {
27
+ "id": "organization",
28
+ "name": "Organization",
29
+ "description": "Organization-wide baselines and default permit/deny policies"
30
+ }
31
+ ],
32
+ "defaults": [
33
+ {
34
+ "id": "baseline-default",
35
+ "name": "Baseline Permit",
36
+ "description": "Permits all actions by default — threat-specific forbid policies override this when threats are detected",
37
+ "category": "organization",
38
+ "file": "defaults/baseline.cedar",
39
+ "severity": "low",
40
+ "tags": ["baseline", "permit-default", "organization"],
41
+ "is_active": true
42
+ },
43
+ {
44
+ "id": "secrets-default",
45
+ "name": "Secrets Detection",
46
+ "description": "Block content containing API keys, tokens, credentials, or other secrets",
47
+ "category": "security",
48
+ "file": "defaults/secrets.cedar",
49
+ "severity": "critical",
50
+ "tags": ["secrets", "api-keys", "credentials", "data-leak"],
51
+ "is_active": true
52
+ },
53
+ {
54
+ "id": "injection-default",
55
+ "name": "Injection & Jailbreak Detection",
56
+ "description": "Block prompt injection, jailbreak attempts, and command injection using ML confidence scores",
57
+ "category": "security",
58
+ "file": "defaults/injection.cedar",
59
+ "severity": "high",
60
+ "tags": ["injection", "jailbreak", "security"],
61
+ "is_active": true
62
+ },
63
+ {
64
+ "id": "pii-default",
65
+ "name": "PII Detection",
66
+ "description": "Block content containing PII such as SSN, credit cards, or passport numbers in outputs",
67
+ "category": "privacy",
68
+ "file": "defaults/pii.cedar",
69
+ "severity": "high",
70
+ "tags": ["pii", "privacy", "data-protection"],
71
+ "is_active": true
72
+ },
73
+ {
74
+ "id": "toxicity-default",
75
+ "name": "Toxicity & Content Moderation",
76
+ "description": "Block toxic, violent, hateful, sexual, and profane content based on classifier scores",
77
+ "category": "trust_safety",
78
+ "file": "defaults/toxicity.cedar",
79
+ "severity": "critical",
80
+ "tags": ["toxicity", "trust-safety", "content-moderation"],
81
+ "is_active": true
82
+ },
83
+ {
84
+ "id": "tool-risk-default",
85
+ "name": "Tool Risk",
86
+ "description": "Block dangerous tool calls, shell execution, and sensitive tool usage based on risk scoring",
87
+ "category": "agentic_security",
88
+ "file": "defaults/tool_risk.cedar",
89
+ "severity": "critical",
90
+ "tags": ["tools", "agentic", "security"],
91
+ "is_active": true
92
+ },
93
+ {
94
+ "id": "agentic-safety-default",
95
+ "name": "Agentic Safety",
96
+ "description": "Block tool call loops, data exfiltration patterns, high-risk sequences, and budget violations",
97
+ "category": "agentic_security",
98
+ "file": "defaults/agentic_safety.cedar",
99
+ "severity": "high",
100
+ "tags": ["agentic", "safety", "loops", "exfiltration", "budget"],
101
+ "is_active": true
102
+ }
103
+ ],
104
+ "templates": [
105
+ {
106
+ "id": "mcp-tool-permissions",
107
+ "name": "MCP Tool Permissions",
108
+ "description": "Per-tool access control for MCP servers — allow specific tools while denying others, exclude servers org-wide, block unverified sources",
109
+ "category": "agentic_security",
110
+ "file": "mcp_tool_permissions.cedar",
111
+ "severity": "high",
112
+ "tags": ["mcp", "tools", "least-privilege", "per-server", "exclusion"]
113
+ },
114
+ {
115
+ "id": "chat-assistant-security",
116
+ "name": "Chat Assistant — Security",
117
+ "description": "Aggressive injection and jailbreak defense for customer-facing chatbots with lower thresholds",
118
+ "category": "security",
119
+ "file": "profiles/chat_assistant/security.cedar",
120
+ "severity": "high",
121
+ "tags": ["profile", "chat-assistant", "injection", "jailbreak", "security"]
122
+ },
123
+ {
124
+ "id": "chat-assistant-privacy",
125
+ "name": "Chat Assistant — Privacy",
126
+ "description": "Block PII in both user inputs and assistant outputs for chat applications",
127
+ "category": "privacy",
128
+ "file": "profiles/chat_assistant/privacy.cedar",
129
+ "severity": "high",
130
+ "tags": ["profile", "chat-assistant", "pii", "privacy"]
131
+ },
132
+ {
133
+ "id": "chat-assistant-trust-safety",
134
+ "name": "Chat Assistant — Trust & Safety",
135
+ "description": "Strict content moderation with lower toxicity thresholds and topic restrictions for public-facing chat",
136
+ "category": "trust_safety",
137
+ "file": "profiles/chat_assistant/trust_safety.cedar",
138
+ "severity": "critical",
139
+ "tags": ["profile", "chat-assistant", "toxicity", "trust-safety", "topics"]
140
+ },
141
+ {
142
+ "id": "code-agent-agentic-security",
143
+ "name": "Code Agent — Agentic Security",
144
+ "description": "Tool risk controls, shell blocking, loop detection, exfiltration prevention, and budget enforcement for coding assistants",
145
+ "category": "agentic_security",
146
+ "file": "profiles/code_agent/agentic_security.cedar",
147
+ "severity": "high",
148
+ "tags": ["profile", "code-agent", "tools", "agentic", "exfiltration", "budget"]
149
+ },
150
+ {
151
+ "id": "code-agent-security",
152
+ "name": "Code Agent — Security",
153
+ "description": "Prevent code agents from writing detected secrets to output files",
154
+ "category": "security",
155
+ "file": "profiles/code_agent/security.cedar",
156
+ "severity": "critical",
157
+ "tags": ["profile", "code-agent", "secrets", "security"]
158
+ },
159
+ {
160
+ "id": "data-pipeline-privacy",
161
+ "name": "Data Pipeline — Privacy",
162
+ "description": "Strict PII protection with zero-tolerance for sensitive PII types in data pipelines",
163
+ "category": "privacy",
164
+ "file": "profiles/data_pipeline/privacy.cedar",
165
+ "severity": "critical",
166
+ "tags": ["profile", "data-pipeline", "pii", "privacy", "compliance"]
167
+ },
168
+ {
169
+ "id": "data-pipeline-security",
170
+ "name": "Data Pipeline — Security",
171
+ "description": "Strict secrets detection and lower injection thresholds for RAG and data processing pipelines",
172
+ "category": "security",
173
+ "file": "profiles/data_pipeline/security.cedar",
174
+ "severity": "critical",
175
+ "tags": ["profile", "data-pipeline", "secrets", "injection", "security"]
176
+ },
177
+ {
178
+ "id": "data-pipeline-agentic-security",
179
+ "name": "Data Pipeline — Agentic Security",
180
+ "description": "Exfiltration prevention and tool risk controls for data processing pipelines",
181
+ "category": "agentic_security",
182
+ "file": "profiles/data_pipeline/agentic_security.cedar",
183
+ "severity": "critical",
184
+ "tags": ["profile", "data-pipeline", "exfiltration", "tools"]
185
+ }
186
+ ],
187
+ "profiles": [
188
+ {
189
+ "id": "chat-assistant",
190
+ "name": "Chat Assistant",
191
+ "description": "Optimized for customer-facing chatbots — strict toxicity, PII blocking, aggressive injection defense, topic restrictions",
192
+ "severity": "high",
193
+ "tags": ["chat-assistant", "toxicity", "pii", "injection"],
194
+ "template_ids": ["chat-assistant-security", "chat-assistant-privacy", "chat-assistant-trust-safety"]
195
+ },
196
+ {
197
+ "id": "code-agent",
198
+ "name": "Code Agent",
199
+ "description": "Optimized for coding assistants — tool risk controls, shell blocking, loop detection, exfiltration prevention, budget enforcement",
200
+ "severity": "high",
201
+ "tags": ["code-agent", "tools", "agentic", "exfiltration"],
202
+ "template_ids": ["code-agent-agentic-security", "code-agent-security"]
203
+ },
204
+ {
205
+ "id": "data-pipeline",
206
+ "name": "Data Pipeline",
207
+ "description": "Optimized for RAG and data processing — strict PII/secrets protection, exfiltration detection, pipeline injection defense",
208
+ "severity": "critical",
209
+ "tags": ["data-pipeline", "pii", "secrets", "exfiltration"],
210
+ "template_ids": ["data-pipeline-privacy", "data-pipeline-security", "data-pipeline-agentic-security"]
211
+ }
212
+ ]
213
+ }
package/dist/builder.d.ts CHANGED
@@ -53,16 +53,75 @@ export interface PolicyCondition {
53
53
  /** The value to compare against */
54
54
  value: string | number | boolean | string[];
55
55
  }
56
+ /** context.field <op> value */
57
+ export interface ConditionComparison {
58
+ kind: 'comparison';
59
+ field: string;
60
+ operator: ConditionOperator;
61
+ value: string | number | boolean | string[];
62
+ }
63
+ /** context.field.contains(value) */
64
+ export interface ConditionContains {
65
+ kind: 'contains';
66
+ field: string;
67
+ value: string | number | boolean;
68
+ }
69
+ /** context.field like "pattern" */
70
+ export interface ConditionLike {
71
+ kind: 'like';
72
+ field: string;
73
+ pattern: string;
74
+ }
75
+ /** context has field (existence check) */
76
+ export interface ConditionHas {
77
+ kind: 'has';
78
+ field: string;
79
+ }
80
+ /** N-ary AND (flattened from binary && chains) */
81
+ export interface ConditionAnd {
82
+ kind: 'and';
83
+ children: ConditionExpression[];
84
+ }
85
+ /** N-ary OR (flattened from binary || chains) */
86
+ export interface ConditionOr {
87
+ kind: 'or';
88
+ children: ConditionExpression[];
89
+ }
90
+ /** Unary NOT */
91
+ export interface ConditionNot {
92
+ kind: 'not';
93
+ child: ConditionExpression;
94
+ }
95
+ /** Fallback for expressions that cannot be decomposed */
96
+ export interface ConditionRaw {
97
+ kind: 'raw';
98
+ text: string;
99
+ }
100
+ /**
101
+ * Recursive condition expression tree parsed from Cedar JSON AST.
102
+ * Used by Studio UI for visual condition block rendering and by
103
+ * explainDecision() for per-condition evaluation with actual values.
104
+ */
105
+ export type ConditionExpression = ConditionComparison | ConditionContains | ConditionLike | ConditionHas | ConditionAnd | ConditionOr | ConditionNot | ConditionRaw;
56
106
  /**
57
107
  * Principal or resource entity constraint.
58
108
  * Used to specify type-only constraints (any entity of type) or
59
109
  * specific entity constraints (type + id).
110
+ *
111
+ * The `operator` field controls Cedar scope syntax:
112
+ * - `'eq'` (default): `resource == Type::"id"` — exact match
113
+ * - `'in'`: `resource in Type::"id"` — hierarchy match (descendants)
114
+ *
115
+ * Use `'in'` for container resource types (Account, Project, App) to match
116
+ * all descendant entities. Use `'eq'` for leaf types (Session, Tool).
60
117
  */
61
118
  export interface PolicyEntity {
62
119
  /** Entity type (e.g., "Agent", "Tool", "FilePath", "User") */
63
120
  type: string;
64
121
  /** Optional specific entity ID. If omitted, matches any entity of this type. */
65
122
  id?: string;
123
+ /** Scope operator: 'eq' for exact match (==), 'in' for hierarchy match (in). Default: 'eq' */
124
+ operator?: 'eq' | 'in';
66
125
  }
67
126
  /** Alias for PolicyEntity when used as principal constraint */
68
127
  export type PolicyPrincipal = PolicyEntity;
@@ -130,6 +189,8 @@ export interface PolicyRule {
130
189
  conditions: PolicyCondition[];
131
190
  /** Raw condition string (for advanced/complex conditions) */
132
191
  rawCondition?: string;
192
+ /** Recursive condition expression tree from Cedar JSON AST */
193
+ conditionExpression?: ConditionExpression;
133
194
  /** Whether this rule is active - NOT embedded in Cedar (runtime state) */
134
195
  enabled: boolean;
135
196
  /** Display/evaluation order - NOT embedded in Cedar (runtime state) */
package/dist/builder.js CHANGED
@@ -293,7 +293,8 @@ function generatePolicyBody(effect, principal, action, resource, conditions, raw
293
293
  if (principal) {
294
294
  const entityType = sanitizeIdentifier(principal.type, 'principal_type');
295
295
  if (principal.id) {
296
- policyLine += `\n principal == ${entityType}::"${escapeCedarString(principal.id)}"`;
296
+ const op = principal.operator === 'in' ? 'in' : '==';
297
+ policyLine += `\n principal ${op} ${entityType}::"${escapeCedarString(principal.id)}"`;
297
298
  }
298
299
  else {
299
300
  policyLine += `\n principal is ${entityType}`;
@@ -326,7 +327,8 @@ function generatePolicyBody(effect, principal, action, resource, conditions, raw
326
327
  if (resource) {
327
328
  const entityType = sanitizeIdentifier(resource.type, 'resource_type');
328
329
  if (resource.id) {
329
- policyLine += `,\n resource == ${entityType}::"${escapeCedarString(resource.id)}"`;
330
+ const op = resource.operator === 'in' ? 'in' : '==';
331
+ policyLine += `,\n resource ${op} ${entityType}::"${escapeCedarString(resource.id)}"`;
330
332
  }
331
333
  else {
332
334
  policyLine += `,\n resource is ${entityType}`;
@@ -2,7 +2,9 @@
2
2
  * Entity types defined in the Highflame Cedar schema.
3
3
  */
4
4
  export declare const EntityType: {
5
+ readonly Account: "Account";
5
6
  readonly Agent: "Agent";
7
+ readonly App: "App";
6
8
  readonly Artifact: "Artifact";
7
9
  readonly ExternalAPI: "ExternalAPI";
8
10
  readonly FilePath: "FilePath";
@@ -12,12 +14,14 @@ export declare const EntityType: {
12
14
  readonly Memory: "Memory";
13
15
  readonly Model: "Model";
14
16
  readonly Package: "Package";
17
+ readonly Project: "Project";
15
18
  readonly Repository: "Repository";
16
19
  readonly Resource: "Resource";
17
20
  readonly ResponseData: "ResponseData";
18
21
  readonly Scanner: "Scanner";
19
22
  readonly Server: "Server";
20
23
  readonly Service: "Service";
24
+ readonly Session: "Session";
21
25
  readonly Tool: "Tool";
22
26
  readonly User: "User";
23
27
  };
@@ -4,7 +4,9 @@
4
4
  * Entity types defined in the Highflame Cedar schema.
5
5
  */
6
6
  export const EntityType = {
7
+ Account: 'Account',
7
8
  Agent: 'Agent',
9
+ App: 'App',
8
10
  Artifact: 'Artifact',
9
11
  ExternalAPI: 'ExternalAPI',
10
12
  FilePath: 'FilePath',
@@ -14,12 +16,14 @@ export const EntityType = {
14
16
  Memory: 'Memory',
15
17
  Model: 'Model',
16
18
  Package: 'Package',
19
+ Project: 'Project',
17
20
  Repository: 'Repository',
18
21
  Resource: 'Resource',
19
22
  ResponseData: 'ResponseData',
20
23
  Scanner: 'Scanner',
21
24
  Server: 'Server',
22
25
  Service: 'Service',
26
+ Session: 'Session',
23
27
  Tool: 'Tool',
24
28
  User: 'User',
25
29
  };
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Policy Decision Explanation
3
+ *
4
+ * Provides structured explanations for Cedar policy decisions by matching
5
+ * determining policies against their structured conditions and the request context.
6
+ *
7
+ * Browser-safe — no WASM or Node.js dependencies.
8
+ */
9
+ import type { PolicyRule, PolicyEffect, ConditionOperator, ConditionExpression } from "./builder.js";
10
+ /**
11
+ * Duck-typed decision input — accepts the Decision class from engine.ts
12
+ * without importing cedar-wasm (keeps this module browser-safe).
13
+ */
14
+ export interface DecisionInput {
15
+ effect: "Allow" | "Deny";
16
+ determining_policies: Array<{
17
+ id: string;
18
+ annotations: Record<string, string>;
19
+ }>;
20
+ }
21
+ /**
22
+ * Result of explaining a policy decision.
23
+ */
24
+ export interface ExplainedDecision {
25
+ /** The original decision effect */
26
+ effect: "Allow" | "Deny";
27
+ /** Enriched explanations for each determining policy */
28
+ explanations: PolicyExplanation[];
29
+ /** Determining policy IDs that had no matching rule in the provided rules array */
30
+ unmatched_policies: string[];
31
+ }
32
+ /**
33
+ * Explanation for a single determining policy.
34
+ */
35
+ export interface PolicyExplanation {
36
+ /** Policy ID */
37
+ policy_id: string;
38
+ /** Policy effect (permit or forbid) */
39
+ effect: PolicyEffect;
40
+ /** Human-readable summary */
41
+ summary: string;
42
+ /** Recursive evaluated condition tree with actual values (from conditionExpression) */
43
+ evaluated_expression?: EvaluatedExpression;
44
+ /** Per-condition match results (flat, from structured conditions[]) */
45
+ condition_results: ConditionResult[];
46
+ /** Raw Cedar condition text if the policy uses rawCondition instead of structured conditions */
47
+ raw_condition?: string;
48
+ }
49
+ /**
50
+ * Result of evaluating a single condition against the request context.
51
+ */
52
+ export interface ConditionResult {
53
+ /** Context field name */
54
+ field: string;
55
+ /** Comparison operator */
56
+ operator: ConditionOperator;
57
+ /** Expected value (threshold from the rule) */
58
+ expected: string | number | boolean | string[];
59
+ /** Actual value from the context (undefined if field was missing) */
60
+ actual?: unknown;
61
+ /** Whether this condition matched */
62
+ matched: boolean;
63
+ }
64
+ /** Evaluated comparison: context.field <op> value */
65
+ export interface EvaluatedComparison {
66
+ kind: 'comparison';
67
+ field: string;
68
+ operator: ConditionOperator;
69
+ expected: string | number | boolean | string[];
70
+ actual: unknown;
71
+ matched: boolean;
72
+ }
73
+ /** Evaluated contains: context.field.contains(value) */
74
+ export interface EvaluatedContains {
75
+ kind: 'contains';
76
+ field: string;
77
+ expected: string | number | boolean;
78
+ actual: unknown;
79
+ matched: boolean;
80
+ }
81
+ /** Evaluated like: context.field like "pattern" */
82
+ export interface EvaluatedLike {
83
+ kind: 'like';
84
+ field: string;
85
+ pattern: string;
86
+ actual: unknown;
87
+ matched: boolean;
88
+ }
89
+ /** Evaluated has: context has field */
90
+ export interface EvaluatedHas {
91
+ kind: 'has';
92
+ field: string;
93
+ matched: boolean;
94
+ }
95
+ /** Evaluated AND */
96
+ export interface EvaluatedAnd {
97
+ kind: 'and';
98
+ children: EvaluatedExpression[];
99
+ matched: boolean;
100
+ }
101
+ /** Evaluated OR */
102
+ export interface EvaluatedOr {
103
+ kind: 'or';
104
+ children: EvaluatedExpression[];
105
+ matched: boolean;
106
+ }
107
+ /** Evaluated NOT */
108
+ export interface EvaluatedNot {
109
+ kind: 'not';
110
+ child: EvaluatedExpression;
111
+ matched: boolean;
112
+ }
113
+ /** Evaluated raw (cannot be decomposed) */
114
+ export interface EvaluatedRaw {
115
+ kind: 'raw';
116
+ text: string;
117
+ matched: boolean;
118
+ }
119
+ /**
120
+ * Recursive evaluated condition expression tree.
121
+ * Produced by evaluateExpression() by walking ConditionExpression against context.
122
+ * Every node has a `matched` boolean; leaf nodes include `actual` values.
123
+ */
124
+ export type EvaluatedExpression = EvaluatedComparison | EvaluatedContains | EvaluatedLike | EvaluatedHas | EvaluatedAnd | EvaluatedOr | EvaluatedNot | EvaluatedRaw;
125
+ /**
126
+ * Explain a policy decision by matching determining policies against their
127
+ * structured conditions and the request context.
128
+ *
129
+ * @param decision - The decision from PolicyEngine.evaluate()
130
+ * @param rules - The PolicyRule[] that were loaded (parsed or built)
131
+ * @param context - The context map that was passed to evaluate()
132
+ * @returns Structured explanation with per-condition match details
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const decision = engine.evaluate(request);
137
+ * const explained = explainDecision(decision, rules, request.context);
138
+ *
139
+ * for (const explanation of explained.explanations) {
140
+ * console.log(explanation.summary);
141
+ * // "forbid process_prompt — threat_count (10) > 5"
142
+ * }
143
+ * ```
144
+ */
145
+ export declare function explainDecision(decision: DecisionInput, rules: PolicyRule[], context: Record<string, unknown>): ExplainedDecision;
146
+ /**
147
+ * Recursively evaluate a ConditionExpression tree against a context map.
148
+ * Returns an EvaluatedExpression tree with `matched` booleans and `actual` values.
149
+ */
150
+ export declare function evaluateExpression(expr: ConditionExpression, context: Record<string, unknown>): EvaluatedExpression;