Help us shape the future of Go! Take the 2026 Go Developer Survey

eval

package
v0.44.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package eval is SPEC §8 as a pure function: order-independent evaluation of a compiled policy against one (user, host, account) request. It knows nothing about HTTP, OIDC, or inventories — the caller resolves the request tuple and passes resolvers for flags (`when`) and facts (`require`).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision struct {
	Outcome   Outcome
	Reason    string
	TTL       time.Duration
	DenyRule  *il.DenyRule
	Allowed   []*il.AllowRule
	PendingOn []string
}

Decision is the evaluation result. TTL is the minimum across satisfied allows that set one; zero means the deployment default. DenyRule is set when a deny rule fired; Allowed carries the satisfied allows (for notify and audit); PendingOn names the requirements a Pending outcome waits on.

func Decide

func Decide(p *il.Policy, req Request, now time.Time, flags FlagFunc, facts FactFunc) (Decision, error)

Decide evaluates policy p for req at instant now. It implements SPEC §8 steps 1–7; file order never matters. Any resolver error is returned as-is — the caller must fail closed (500), never treat it as a non-match.

type FactFunc

type FactFunc func(name string) (FactState, error)

FactFunc resolves a `require` fact through the three-state resolver. An error fails the evaluation closed. Request-scoped caching and fast-before-side-effecting ordering are the resolver's business.

type FactState

type FactState int

FactState is the three-state result of a `require` fact resolver.

const (
	FactUnknown FactState = iota // unstarted — pends
	FactSatisfied
	FactUnsatisfied
	FactPending
)

type FlagFunc

type FlagFunc func(name string) (bool, error)

FlagFunc resolves a `when` flag: synchronous, two-state, never pending. An error fails the evaluation closed.

type Host

type Host struct {
	ID         string
	Names      []string
	Attributes object.Attributes
	Accounts   []string
}

Host is one resolved host. Nil Accounts imposes no restriction; a non-nil slice restricts requests to its members, and an empty slice permits none.

type Outcome

type Outcome int

Outcome is the decision category.

const (
	Deny Outcome = iota
	Issue
	Pending
)

type Request

type Request struct {
	User    *User
	Host    *Host
	Account string // requested account name, verbatim — never case-folded
}

Request is one evaluation request. A nil User or Host is a structural non-match (the SPEC §8 step 1 gates), not an error.

type User

type User = object.User

User is a resolved, eligible user. Providers own eligibility.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL