@highflame/policy 2.1.3 → 2.1.5
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.
- package/README.md +41 -0
- package/_schemas/guardrails/context.json +466 -76
- package/_schemas/guardrails/schema.cedarschema +39 -3
- package/_schemas/guardrails/templates/defaults/injection.cedar +6 -6
- package/_schemas/guardrails/templates/profiles/chat_assistant/security.cedar +2 -2
- package/_schemas/guardrails/templates/profiles/data_pipeline/security.cedar +1 -1
- package/_schemas/overwatch/context.json +443 -5
- package/_schemas/overwatch/schema.cedarschema +42 -4
- package/_schemas/palisade/context.json +1 -1
- package/_schemas/sentry/context.json +1165 -0
- package/_schemas/sentry/schema.cedarschema +388 -0
- package/_schemas/sentry/templates/defaults/baseline.cedar +24 -0
- package/_schemas/sentry/templates/defaults/content_safety.cedar +232 -0
- package/_schemas/sentry/templates/defaults/file_safety.cedar +174 -0
- package/_schemas/sentry/templates/defaults/organization.cedar +207 -0
- package/_schemas/sentry/templates/defaults/pii.cedar +229 -0
- package/_schemas/sentry/templates/defaults/semantic.cedar +167 -0
- package/_schemas/sentry/templates/templates.json +93 -0
- package/dist/builder.d.ts +32 -0
- package/dist/builder.js +6 -6
- package/dist/condition-groups.d.ts +69 -0
- package/dist/condition-groups.js +305 -0
- package/dist/guardrails-context.gen.d.ts +19 -2
- package/dist/guardrails-context.gen.js +19 -2
- package/dist/guardrails-defaults.gen.js +9 -9
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/overwatch-context.gen.d.ts +17 -0
- package/dist/overwatch-context.gen.js +17 -0
- package/dist/sentry-context.gen.d.ts +76 -0
- package/dist/sentry-context.gen.js +77 -0
- package/dist/sentry-defaults.gen.d.ts +61 -0
- package/dist/sentry-defaults.gen.js +1235 -0
- package/dist/sentry-entities.gen.d.ts +11 -0
- package/dist/sentry-entities.gen.js +33 -0
- package/dist/service-schemas.gen.d.ts +12 -2
- package/dist/service-schemas.gen.js +861 -25
- package/dist/types.d.ts +6 -1
- package/dist/types.js +6 -1
- package/package.json +1 -1
- package/_schemas/guardrails/templates/profiles/chat_assistant.cedar +0 -85
- package/_schemas/guardrails/templates/profiles/code_agent.cedar +0 -125
- 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.
|