jaredzhou/mooncedar/evaluator does not have a README file

    EntityStore

    Pluggable entity storage. Implement this trait to provide entity lookups from any backing store (in-memory Map, database, cache, etc.).

    EvalError

    pub(all) suberror EvalError {
    TypeMismatch(String)
    IntegerOverflow
    EntityNotFound(String)
    InvalidOperator(String)
    ExtensionNotSupported(String)
    SlotNotSupported
    } derive(Eq,
    Debug
    )

    Errors that can occur during expression evaluation.

    Context

    Request context — three states matching Rust's CPE:
    • Concrete(Value::Record(...)): fully known context
    • Unknown(Expr): entirely unknown (e.g., Expr::Unknown("context", None))
    • Partial(Expr): partially known, containing an Expr::Record where individual fields may be Expr::Unknown nodes.

    Dereference

    Result of looking up an entity in the store.

    EntityUIDEntry

    A PARC slot: either a known EntityUID (concrete eval) or a typed Unknown (partial eval).

    EvalResult

    Result of evaluating an expression. Value(v) means a concrete value was produced. Residual(e) means the expression could not be reduced and is returned as-is.

    MapEntityStore

    In-memory entity store backed by a Map.

    Request

    pub(all) struct Request {
    principal : EntityUIDEntry
    action : EntityUIDEntry
    resource : EntityUIDEntry
    context : Context
    } derive(Eq,
    Debug
    )

    The PARC authorization request.

    concrete_uid

    fn concrete_uid(type_ : String, id : String) -> EntityUIDEntry

    Helper: construct a concrete EntityUIDEntry.

    eval_binary

    Evaluate a binary operator on two concrete values. Does NOT handle In_ — that requires EntityStore access and is handled in expr_eval.mbt.

    eval_expr

    fn[S : EntityStore] eval_expr(expr :
    Expr
    , req : Request, store : S) -> EvalResult raise EvalError

    Evaluate a Cedar expression in the context of a Request and EntityStore. Returns Value(concrete) for fully-reducible expressions, or Residual(expr) for expressions that cannot be fully reduced (partial evaluation).

    eval_policy

    fn[S : EntityStore] eval_policy(p :
    Policy
    , req : Request, store : S) -> EvalResult raise EvalError

    Evaluate a single policy against a Request and EntityStore. Returns: Value(Bool(true)) — policy satisfied (scope matched, all conditions passed) Value(Bool(false)) — policy not satisfied (scope didn't match, or condition failed) Residual(Expr) — partial eval: scope matched but some conditions are residual raise EvalError — evaluation error

    eval_unary

    Evaluate a unary operator on a concrete value.

    is_descendant

    Check if uid is equal to or a descendant of ancestor in the entity hierarchy. Uses BFS to traverse parent chains.

    new_map_store

    fn new_map_store() -> MapEntityStore

    Create an empty MapEntityStore.

    scope_match

    Check whether a scope constraint matches the given entity variable.

    value_to_expr

    Convert a concrete Value back into an Expr (inverse of lit_to_value).

    wildcard_match

    fn wildcard_match(text : String, pattern :
    Pattern
    ) -> Bool

    Match a string against a Cedar like-pattern. * matches any sequence of characters (including empty). \* matches a literal * (already parsed as PatternElem::Char('*')).

    Uses two-pointer backtracking: on Wildcard, record the star position and advance the text pointer; on mismatch, backtrack to the last star.