Documentation
¶
Overview ¶
Package decisionpolicy implements Pilot's small deterministic v1 action policy. It is both an authority.PolicyValidator and a decision.Authorizer / AuthorityCeiling, keeping managed answers below locally signed policy.
Index ¶
- Constants
- func Compile(payload []byte) (*compiled, error)
- type ApprovalPlan
- type Comparison
- type DisclosureRule
- type Document
- type DocumentDiff
- type EngineInstance
- func (engine *EngineInstance) ApprovalPlanFor(ctx context.Context, intent decision.Intent, initial decision.Decision) (ApprovalPlan, error)
- func (engine *EngineInstance) ApprovalPlanForDisclosure(ctx context.Context, intent decision.Intent, initial decision.Decision, ...) (ApprovalPlan, error)
- func (engine *EngineInstance) Authorize(ctx context.Context, intent decision.Intent) (decision.Decision, error)
- func (engine *EngineInstance) AuthorizeDisclosure(ctx context.Context, intent decision.Intent, ...) (decision.Decision, error)
- func (engine *EngineInstance) Check(ctx context.Context, intent decision.Intent, remote decision.Decision) error
- func (engine *EngineInstance) CheckDisclosure(ctx context.Context, intent decision.Intent, remote decision.Decision, ...) error
- func (engine *EngineInstance) ValidatePolicy(_ context.Context, name, version, contentType string, payload []byte) error
- type ImpactChange
- type RolloutSimulation
- type RolloutSimulator
- type RolloutValidation
- type Rule
- type SimulationInput
- type SimulationResult
- type Validator
Constants ¶
const ( Engine = "pilot-action-policy" EngineVersion = "1" ContentType = "application/vnd.pilot.action-policy+json" MaxRules = 256 )
const MaxSimulationIntents = 1_000
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApprovalPlan ¶
type ApprovalPlan struct {
ApproverKeyIDs []string `json:"approver_key_ids"`
RequiredApprovals uint16 `json:"required_approvals"`
ValiditySeconds int64 `json:"validity_seconds"`
Outcome decision.Outcome `json:"outcome"`
Constraints []decision.Constraint `json:"constraints,omitempty"`
}
ApprovalPlan is a signed-policy declaration of the authority unlocked after a rule's approval_required outcome has satisfied its named-key threshold. It deliberately carries no approver display names or mutable UI state.
type Comparison ¶
type Comparison struct {
Diff DocumentDiff `json:"diff"`
Candidate []SimulationResult `json:"candidate"`
Impacts []ImpactChange `json:"impacts"`
}
func Compare ¶
func Compare(currentPayload, candidatePayload []byte, intents []decision.Intent) (Comparison, error)
func CompareInputs ¶
func CompareInputs(currentPayload, candidatePayload []byte, inputs []SimulationInput) (Comparison, error)
type DisclosureRule ¶
type DisclosureRule struct {
LabelsAll []string `json:"labels_all,omitempty"`
ContentTypes []string `json:"content_types,omitempty"`
Recipients []string `json:"recipients,omitempty"`
Purposes []string `json:"purposes,omitempty"`
Residencies []string `json:"residencies,omitempty"`
RetentionClasses []string `json:"retention_classes,omitempty"`
}
DisclosureRule adds typed data-governance conditions to an ordinary action rule. All labels must be present; each non-empty list of content types, recipients, purposes, and residencies is an exact OR match. A rule with a disclosure clause never matches a bare V1 authorization request.
type DocumentDiff ¶
type DocumentDiff struct {
DefaultOutcomeFrom decision.Outcome `json:"default_outcome_from"`
DefaultOutcomeTo decision.Outcome `json:"default_outcome_to"`
AddedRules []string `json:"added_rules"`
RemovedRules []string `json:"removed_rules"`
ChangedRules []string `json:"changed_rules"`
Changed bool `json:"changed"`
}
type EngineInstance ¶
type EngineInstance struct {
// contains filtered or unexported fields
}
func New ¶
func New(manager *authority.PolicyManager) (*EngineInstance, error)
func (*EngineInstance) ApprovalPlanFor ¶
func (engine *EngineInstance) ApprovalPlanFor(ctx context.Context, intent decision.Intent, initial decision.Decision) (ApprovalPlan, error)
ApprovalPlanFor returns the signed policy plan for an exact current approval_required result. It rejects stale state or a rule with no long-run plan, leaving the existing short-lived approval path available to policies that intentionally omit one.
func (*EngineInstance) ApprovalPlanForDisclosure ¶
func (engine *EngineInstance) ApprovalPlanForDisclosure(ctx context.Context, intent decision.Intent, initial decision.Decision, disclosure decision.DisclosureBinding) (ApprovalPlan, error)
ApprovalPlanForDisclosure resolves an approval plan using the same typed rule that issued a disclosure-bound approval_required Decision. Legacy ApprovalPlanFor deliberately cannot match those rules, preventing a caller from opening a long-running approval path after omitting data metadata.
func (*EngineInstance) AuthorizeDisclosure ¶
func (engine *EngineInstance) AuthorizeDisclosure(ctx context.Context, intent decision.Intent, disclosure decision.DisclosureBinding) (decision.Decision, error)
AuthorizeDisclosure verifies the explicit metadata-to-Intent binding before evaluating the disclosure-aware deterministic policy. Rules with a disclosure clause never match an ordinary V1 request, so a tenant can make typed metadata a real authorization precondition rather than a UI hint.
func (*EngineInstance) CheckDisclosure ¶
func (engine *EngineInstance) CheckDisclosure(ctx context.Context, intent decision.Intent, remote decision.Decision, disclosure decision.DisclosureBinding) error
CheckDisclosure proves that a remote signed decision is no broader than the locally installed policy for the same typed disclosure. This is the method called by governed receivers and brokers before they release a message, file, stream, or event.
func (*EngineInstance) ValidatePolicy ¶
type ImpactChange ¶
type ImpactChange struct {
IntentID string `json:"intent_id"`
Before decision.Outcome `json:"before"`
After decision.Outcome `json:"after"`
BeforeConstraints []decision.Constraint `json:"before_constraints,omitempty"`
AfterConstraints []decision.Constraint `json:"after_constraints,omitempty"`
BeforeApproval *ApprovalPlan `json:"before_approval,omitempty"`
AfterApproval *ApprovalPlan `json:"after_approval,omitempty"`
AuthorityChange string `json:"authority_change"`
}
type RolloutSimulation ¶
type RolloutSimulation struct {
CurrentRevision uint64 `json:"current_revision"`
CandidateRevision uint64 `json:"candidate_revision"`
Comparison Comparison `json:"comparison"`
}
type RolloutSimulator ¶
type RolloutSimulator struct{ Rollouts RolloutValidation }
func (RolloutSimulator) Simulate ¶
func (simulator RolloutSimulator) Simulate(ctx context.Context, publication authority.PolicyPublication, bundle authority.PolicyBundle, intents []decision.Intent) (RolloutSimulation, error)
func (RolloutSimulator) SimulateInputs ¶
func (simulator RolloutSimulator) SimulateInputs(ctx context.Context, publication authority.PolicyPublication, bundle authority.PolicyBundle, inputs []SimulationInput) (RolloutSimulation, error)
SimulateInputs compares a candidate against the active signed policy with both legacy Intent and hash-bound typed disclosure cases.
type RolloutValidation ¶
type RolloutValidation interface {
ValidateCandidate(context.Context, authority.PolicyPublication, authority.PolicyBundle) error
CurrentPolicy(context.Context, string) (authority.PolicyBundle, error)
}
type Rule ¶
type Rule struct {
ID string `json:"id"`
Agents []string `json:"agents"`
Actions []string `json:"actions"`
ResourcePrefixes []string `json:"resource_prefixes"`
Risks []decision.RiskClass `json:"risks"`
Outcome decision.Outcome `json:"outcome"`
Reasons []string `json:"reasons,omitempty"`
Constraints []decision.Constraint `json:"constraints,omitempty"`
Approval *ApprovalPlan `json:"approval,omitempty"`
Disclosure *DisclosureRule `json:"disclosure,omitempty"`
}
type SimulationInput ¶
type SimulationInput struct {
Intent decision.Intent `json:"intent"`
Disclosure *decision.DisclosureBinding `json:"disclosure,omitempty"`
}
SimulationInput is a policy-review case. Disclosure is optional for legacy V1 intents, but when present it must be the exact metadata bound by the input Intent. This lets policy rollout simulation show the real effect of typed data-governance rules before an operator activates them.
func (SimulationInput) Validate ¶
func (input SimulationInput) Validate() error
type SimulationResult ¶
type SimulationResult struct {
IntentID string `json:"intent_id"`
Outcome decision.Outcome `json:"outcome"`
Reasons []string `json:"reasons,omitempty"`
Constraints []decision.Constraint `json:"constraints,omitempty"`
Approval *ApprovalPlan `json:"approval,omitempty"`
}
func Simulate ¶
func Simulate(payload []byte, intents []decision.Intent) ([]SimulationResult, error)
func SimulateInputs ¶
func SimulateInputs(payload []byte, inputs []SimulationInput) ([]SimulationResult, error)