@highflame/policy 2.1.4 → 2.1.6

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 (33) hide show
  1. package/README.md +41 -0
  2. package/_schemas/guardrails/context.json +600 -6
  3. package/_schemas/guardrails/schema.cedarschema +79 -3
  4. package/_schemas/guardrails/templates/defaults/agent_identity.cedar +118 -0
  5. package/_schemas/guardrails/templates/defaults/agentic_safety.cedar +4 -4
  6. package/_schemas/guardrails/templates/defaults/injection.cedar +10 -10
  7. package/_schemas/guardrails/templates/defaults/secrets.cedar +2 -2
  8. package/_schemas/guardrails/templates/defaults/security_patterns.cedar +1 -1
  9. package/_schemas/guardrails/templates/defaults/toxicity.cedar +3 -3
  10. package/_schemas/guardrails/templates/profiles/chat_assistant/privacy.cedar +1 -1
  11. package/_schemas/guardrails/templates/profiles/chat_assistant/security.cedar +4 -4
  12. package/_schemas/guardrails/templates/profiles/chat_assistant/trust_safety.cedar +2 -2
  13. package/_schemas/guardrails/templates/profiles/code_agent/agentic_security.cedar +3 -3
  14. package/_schemas/guardrails/templates/profiles/data_pipeline/agentic_security.cedar +1 -1
  15. package/_schemas/guardrails/templates/profiles/data_pipeline/privacy.cedar +2 -2
  16. package/_schemas/guardrails/templates/profiles/data_pipeline/security.cedar +3 -3
  17. package/_schemas/guardrails/templates/profiles/multi_agent/agent_safety.cedar +157 -0
  18. package/_schemas/guardrails/templates/profiles/multi_agent/agent_trust.cedar +140 -0
  19. package/_schemas/guardrails/templates/templates.json +41 -0
  20. package/_schemas/overwatch/context.json +232 -4
  21. package/_schemas/overwatch/schema.cedarschema +42 -4
  22. package/dist/guardrails-context.gen.d.ts +24 -2
  23. package/dist/guardrails-context.gen.js +24 -2
  24. package/dist/guardrails-defaults.gen.d.ts +1 -1
  25. package/dist/guardrails-defaults.gen.js +524 -36
  26. package/dist/overwatch-context.gen.d.ts +10 -0
  27. package/dist/overwatch-context.gen.js +10 -0
  28. package/dist/service-schemas.gen.d.ts +2 -2
  29. package/dist/service-schemas.gen.js +275 -24
  30. package/package.json +1 -1
  31. package/_schemas/guardrails/templates/profiles/chat_assistant.cedar +0 -85
  32. package/_schemas/guardrails/templates/profiles/code_agent.cedar +0 -125
  33. package/_schemas/guardrails/templates/profiles/data_pipeline.cedar +0 -111
package/README.md CHANGED
@@ -168,6 +168,47 @@ result.unstructured.forEach(policy => {
168
168
  });
169
169
  ```
170
170
 
171
+ ## Condition Groups (Visual Builder Support)
172
+
173
+ Bidirectional conversion between recursive `ConditionExpression` ASTs and flat `ConditionGroup` arrays for visual condition builder UIs.
174
+
175
+ ```typescript
176
+ import {
177
+ expressionToGroups,
178
+ groupsToExpression,
179
+ expressionToCedar,
180
+ extractContextFields,
181
+ } from '@highflame/policy/types';
182
+
183
+ // Parse Cedar → edit in UI → generate Cedar
184
+ const result = parseCedarToRules(cedarText);
185
+ const rule = result.rules[0];
186
+
187
+ if (rule.conditionExpression) {
188
+ // Convert AST to flat groups for visual builder
189
+ const groups = expressionToGroups(rule.conditionExpression);
190
+
191
+ // User edits groups in UI...
192
+
193
+ // Convert back to AST
194
+ const expr = groupsToExpression(groups);
195
+
196
+ // Render to Cedar text
197
+ const cedarCondition = expressionToCedar(expr);
198
+ }
199
+ ```
200
+
201
+ ### Why Top-Level AND Between Groups?
202
+
203
+ Groups are always combined with **AND** at the top level. This reflects Cedar's authorization model:
204
+
205
+ - **Cedar provides OR between policies for free** — if ANY `forbid` matches, the request is denied
206
+ - **AND within a rule**: "block if injection > 70 AND jailbreak > 65" → conditions in one AND group
207
+ - **OR within a rule**: "block if violence > 70 OR hate > 70" → conditions in one OR group
208
+ - **OR between rules**: separate `forbid` rules — Cedar ORs them automatically
209
+
210
+ This means `(A && B) || (C && D)` is expressed as two separate rules, which is cleaner, more auditable, and idiomatic Cedar.
211
+
171
212
  ## Available Constants
172
213
 
173
214
  - **17 Entity Types**: `EntityType.User`, `Scanner`, `Artifact`, `Tool`, etc.