Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Helper methods on `WorkflowStatus` and `WorkflowStatusResponse`: `is_terminal()`
- LangGraph adapter: `axonflow.adapters.langgraph.AxonFlowLangGraphAdapter`

- **Workflow Policy Enforcement** (Issues #1019, #1020, #1021): Policy transparency for workflow operations
- `StepGateResponse` now includes `policies_evaluated` and `policies_matched` fields with `PolicyMatch` type
- `PolicyMatch` class with `policy_id`, `policy_name`, `action`, `reason` for policy transparency
- `PolicyEvaluationResult` class for MAP execution with `allowed`, `applied_policies`, `risk_score`
- Workflow operations (`workflow_created`, `workflow_step_gate`, `workflow_completed`) logged to audit trail

### Fixed

- Datetime parsing now handles variable-length fractional seconds (e.g., 5 digits) for Python 3.9 compatibility
Expand Down
2 changes: 2 additions & 0 deletions axonflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
PlanStep,
PolicyApprovalResult,
PolicyEvaluationInfo,
PolicyEvaluationResult,
PricingInfo,
PricingListResponse,
RateLimitInfo,
Expand Down Expand Up @@ -168,6 +169,7 @@
"PlanStep",
"PlanResponse",
"PlanExecutionResponse",
"PolicyEvaluationResult",
# Gateway Mode types
"RateLimitInfo",
"PolicyApprovalResult",
Expand Down
28 changes: 28 additions & 0 deletions axonflow/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,31 @@ class PlanResponse(BaseModel):
metadata: dict[str, Any] = Field(default_factory=dict)


class PolicyEvaluationResult(BaseModel):
"""Result of policy evaluation for workflow steps and plan executions.

Used by MAP (Multi-Agent Planning) and WCP (Workflow Control Plane) to provide
detailed policy enforcement information (Issues #1019, #1020, #1021).
"""

allowed: bool = Field(..., description="Whether the action is allowed by policy")
applied_policies: list[str] = Field(
default_factory=list, description="List of policy IDs that were applied"
)
risk_score: float = Field(
default=0.0, ge=0.0, le=1.0, description="Calculated risk score (0.0-1.0)"
)
required_actions: list[str] | None = Field(
default=None, description="Actions required before proceeding (if any)"
)
processing_time_ms: int = Field(
default=0, ge=0, description="Time taken for policy evaluation in milliseconds"
)
database_accessed: bool | None = Field(
default=None, description="Whether a database was accessed during the operation"
)


class PlanExecutionResponse(BaseModel):
"""Plan execution result."""

Expand All @@ -294,6 +319,9 @@ class PlanExecutionResponse(BaseModel):
step_results: dict[str, Any] = Field(default_factory=dict)
error: str | None = None
duration: str | None = None
policy_info: PolicyEvaluationResult | None = Field(
default=None, description="Policy evaluation result for the plan execution"
)


# Gateway Mode Types
Expand Down
8 changes: 8 additions & 0 deletions axonflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ class StepGateResponse(BaseModel):
approval_url: str | None = Field(
default=None, description="URL to the approval portal (if decision is require_approval)"
)
policies_evaluated: list[PolicyMatch] | None = Field(
default=None,
description="List of all policies that were evaluated during the gate check (Issue #1019)",
)
policies_matched: list[PolicyMatch] | None = Field(
default=None,
description="List of policies that matched and influenced the decision (Issue #1019)",
)

def is_allowed(self) -> bool:
"""Check if the step is allowed to proceed."""
Expand Down