liveBook · Manning

Assertion

As explained in Effective Platform Engineering

An assertion is a declarative statement that evaluates as true or false for given data.

An assertion is a declarative statement that evaluates as true or false for given data. In policy-as-code, it describes a fixed structure: data that looks a certain way is approved. Assertions are expressed as predicates—properties or descriptions of subjects—and can include variables whose values determine whether the statement holds. section 4.2.1

Use the surrounding vocabulary to make an assertion operational:

  • Treat the predicate as the condition, such as “X is writing a book.” section 4.2.1
  • Treat the extension as every subject in the data domain that satisfies the predicate. section 4.2.1
  • Evaluate each subject variable against available data to obtain a true or false result. section 4.2.1

Policy approval

A Rego rule can assert that a user is allowed when the user's age exceeds 12. For a supplied input, the policy returns an allow result alongside the evaluated assertion. section 4.2.1

package test   #1
default allow := false   #2
allow if user_is_over_12  #3

user_is_over_12 if {  #4
    data.user_attributes[input.user].age > 12
}

Inspect a compact Rego policy that defines a default decision, an approval assertion, and the predicate supporting it. section 4.2.1

How Effective Platform Engineering covers it

How deep it goes
Defines predicates, extensions, data domains, and subject variables, then connects them to true-or-false evaluation.
Examples
Uses book-writing predicates, employee lists, age-based Rego rules, and allow-or-deny policy results.
What you can do after
Evaluate policy inputs by identifying predicates, assigning subject variables, and checking whether assertions hold.
How it connects
Connects predicates, variables, data domains, declarative programming, Rego, and Terraform.

Also explained in

Compare how 15 books explain assertion →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Platform Engineering. The section links point to the parts of the book it draws on.