Highflame Cedar policy types and engine wrapper
Project description
Highflame Policy - Python Package
Cedar policy engine and typed constants for the Highflame security platform. Ensures entity/action consistency across all Highflame services.
Features
- ๐ Cedar Policy Evaluation - Wraps
cedarpywith Highflame-specific types - ๐ Typed Constants - Auto-generated entity types, actions, and context keys (prevents typos!)
- ๐ Cedar Parser - Convert Cedar text to structured PolicyRule JSON for UI editing
- โ Schema Validation - Validate policies against embedded Cedar schemas
- ๐ฏ Service-Specific Schemas - Overwatch (Guardian) and Palisade schemas included
- ๐ Namespace Support - Generic support for namespaced entities and actions
Installation
pip install highflame-policy
Quick Start
Policy Evaluation (Palisade Example)
from highflame_policy import (
PolicyEngine,
EntityType,
ActionType,
schemas,
)
from highflame_policy.schemas import PalisadeContextKey
# Create engine with Palisade schema
engine = PolicyEngine(schema=schemas.palisade_schema)
engine.load_policies_from_file("palisade_policy.cedar")
# Evaluate with typed constants (no typos!)
decision = engine.evaluate(
principal_type=EntityType.SCANNER,
principal_id="palisade",
action=ActionType.SCAN_ARTIFACT,
resource_type=EntityType.ARTIFACT,
resource_id="/model.safetensors",
context={
PalisadeContextKey.ARTIFACT_FORMAT: "safetensors",
PalisadeContextKey.SEVERITY: "HIGH",
PalisadeContextKey.ENVIRONMENT: "production",
},
)
if decision.is_denied():
print(f"Blocked by policies: {decision.determining_policies}")
Service-Specific Schemas
from highflame_policy import PolicyEngine, schemas
from highflame_policy.schemas import OverwatchContextKey
# Use Overwatch (Guardian) schema for IDE security
engine = PolicyEngine(schema=schemas.overwatch_schema)
engine.load_policies(policy)
decision = engine.evaluate(
principal_type="Overwatch::User",
principal_id="mcp_client",
action='Overwatch::Action::"call_tool"',
resource_type="Overwatch::Tool",
resource_id="shell",
context={
OverwatchContextKey.THREAT_COUNT: 3,
OverwatchContextKey.TOOL_NAME: "shell",
},
)
Cedar Parser (Text โ JSON)
from highflame_policy import parse_cedar_to_rules
cedar_text = '''
@id("allow-read")
permit(
principal is User,
action == Action::"read_file",
resource is FilePath
)
when { context.environment == "production" };
'''
result = parse_cedar_to_rules(cedar_text)
for rule in result.rules:
print(f"Rule: {rule['id']}, Effect: {rule['effect']}")
# Use in UI for editing
Available Constants
Entity Types (17 total)
EntityType.USER,EntityType.AGENT,EntityType.SCANNER,EntityType.SERVICEEntityType.ARTIFACT,EntityType.TOOL,EntityType.SERVER,EntityType.FILE_PATHEntityType.MODEL,EntityType.REPOSITORY,EntityType.PACKAGE- And more...
Actions (38 total)
ActionType.SCAN_ARTIFACT,ActionType.CALL_TOOL,ActionType.LOAD_MODELActionType.PROCESS_PROMPT,ActionType.PROCESS_RESPONSEActionType.READ_FILE,ActionType.WRITE_FILE,ActionType.DELETE_FILEActionType.HTTP_REQUEST,ActionType.EXECUTE_CODE- And more...
Context Keys (Service-Specific)
Overwatch (Guardian) Context:
from highflame_policy.schemas import OverwatchContextKey
# 20+ context attributes for IDE security
OverwatchContextKey.THREAT_COUNT
OverwatchContextKey.TOOL_NAME
OverwatchContextKey.USER_EMAIL
OverwatchContextKey.SOURCE
# And more...
Palisade Context:
from highflame_policy.schemas import PalisadeContextKey
# 15+ context attributes for ML security
PalisadeContextKey.ENVIRONMENT
PalisadeContextKey.SEVERITY
PalisadeContextKey.ARTIFACT_FORMAT
PalisadeContextKey.PICKLE_EXEC_PATH_DETECTED
# And more...
Service-Specific Schemas
Overwatch (Guardian) - IDE Security
from highflame_policy import PolicyEngine, schemas
from highflame_policy.schemas import OverwatchContextKey
# Schema: schemas.overwatch_schema
# Context: schemas.overwatch_context (JSON metadata for UI)
# Namespaced entities and actions
engine = PolicyEngine(schema=schemas.overwatch_schema)
decision = engine.evaluate(
principal_type="Overwatch::User",
principal_id="claude-code-user",
action='Overwatch::Action::"call_tool"',
resource_type="Overwatch::Tool",
resource_id="bash",
context={
OverwatchContextKey.THREAT_COUNT: 0,
OverwatchContextKey.TOOL_NAME: "bash",
OverwatchContextKey.SOURCE: "claude-code",
},
)
Palisade - ML Supply Chain Security
from highflame_policy import PolicyEngine, schemas
from highflame_policy.schemas import PalisadeContextKey
# Schema: schemas.palisade_schema
# Context: schemas.palisade_context (JSON metadata for UI)
engine = PolicyEngine(schema=schemas.palisade_schema)
decision = engine.evaluate(
principal_type="Palisade::Scanner",
principal_id="palisade",
action='Palisade::Action::"scan_artifact"',
resource_type="Palisade::Artifact",
resource_id="/model.safetensors",
context={
PalisadeContextKey.SEVERITY: "HIGH",
PalisadeContextKey.ARTIFACT_FORMAT: "safetensors",
PalisadeContextKey.ENVIRONMENT: "production",
},
)
Input Validation
Protect against DoS attacks with built-in validation:
from highflame_policy import (
PolicyEngine,
EngineOptions,
ValidationLimits,
InputValidationError,
)
engine = PolicyEngine(
options=EngineOptions(
limits=ValidationLimits(
max_context_keys=200,
max_string_length=1_000_000,
max_nesting_depth=10,
)
)
)
try:
decision = engine.evaluate(...)
except InputValidationError as e:
print(f"Validation failed: {e}")
Why Typed Constants?
Without typed constants (error-prone):
context = {
"enviroment": "production", # Typo! Policy won't match
"severety": "HIGH", # Typo! Policy won't match
}
With typed constants (compile-time safety):
from highflame_policy.schemas import PalisadeContextKey
context = {
PalisadeContextKey.ENVIRONMENT: "production", # โ Autocomplete + type checking
PalisadeContextKey.SEVERITY: "HIGH", # โ Can't typo!
}
Architecture
This package wraps the official Cedar Python engine (cedarpy) with Highflame-specific types generated from the Cedar schema. All services use identical entity/action names, ensuring policy consistency.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ schema/highflame.cedarschema โ โ Source of truth
โ (Cedar schema) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโดโโโโโโโโโโโ
โ Rust codegen tool โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ
โผ โผ โผ
Python Go TypeScript
cedarpy cedar-go cedar-wasm
โ โ โ
โผ โผ โผ
Palisade Guardrails Guardian
(scanner) (proxy) (IDE)
Related Packages
- Go:
github.com/highflame-ai/highflame-policy/packages/go - TypeScript:
@highflame/policyon npm - Rust:
highflame-policyon crates.io
Documentation
Full documentation: CLAUDE.md
License
Apache 2.0 - See LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file highflame_policy-2.1.22.tar.gz.
File metadata
- Download URL: highflame_policy-2.1.22.tar.gz
- Upload date:
- Size: 139.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a9408f493a681943855284af84ce0602beb85eed9a325544330734ed30db95e
|
|
| MD5 |
b99042e88272e0c9b6dcad2a21f45241
|
|
| BLAKE2b-256 |
67a5ac69a6fff4aa3f0b558bdbbc17fdbbda71032a98289a566a3866c4aab1bd
|
Provenance
The following attestation bundles were made for highflame_policy-2.1.22.tar.gz:
Publisher:
release.yml on highflame-ai/highflame-policy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
highflame_policy-2.1.22.tar.gz -
Subject digest:
4a9408f493a681943855284af84ce0602beb85eed9a325544330734ed30db95e - Sigstore transparency entry: 1369701023
- Sigstore integration time:
-
Permalink:
highflame-ai/highflame-policy@2128b0fd25c42a78b972169512ab271531ad76b5 -
Branch / Tag:
refs/tags/v2.1.22 - Owner: https://github.com/highflame-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2128b0fd25c42a78b972169512ab271531ad76b5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file highflame_policy-2.1.22-py3-none-any.whl.
File metadata
- Download URL: highflame_policy-2.1.22-py3-none-any.whl
- Upload date:
- Size: 172.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fb474f1cd15acee25227191b3984d72b7a426d34a01851e7b98537799bf065a
|
|
| MD5 |
0819a268bd569effe498a77f64d1ded5
|
|
| BLAKE2b-256 |
1470e642904cc1803382e44edf08dd04f7af3c8f91f4f2214bba5b32c638f500
|
Provenance
The following attestation bundles were made for highflame_policy-2.1.22-py3-none-any.whl:
Publisher:
release.yml on highflame-ai/highflame-policy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
highflame_policy-2.1.22-py3-none-any.whl -
Subject digest:
9fb474f1cd15acee25227191b3984d72b7a426d34a01851e7b98537799bf065a - Sigstore transparency entry: 1369701079
- Sigstore integration time:
-
Permalink:
highflame-ai/highflame-policy@2128b0fd25c42a78b972169512ab271531ad76b5 -
Branch / Tag:
refs/tags/v2.1.22 - Owner: https://github.com/highflame-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2128b0fd25c42a78b972169512ab271531ad76b5 -
Trigger Event:
release
-
Statement type: