Skip to main content

Policy

A Policy is a rule enforced at design time to prevent unsafe operations from reaching production. Unlike runtime validation, Policies are checked by the Risk Engine before a Tool is deployed. If a Tool violates a Policy, it is either flagged with a warning or blocked from deployment entirely.

Design-Time Enforcement

Fascia follows a "Policy-First" principle: unsafe patterns are caught during the design and review phase, not at runtime. This means that by the time a Tool is deployed and executing in your GCP environment, it has already passed all safety checks.

The Risk Engine analyzes every Tool spec and its Flow graph to classify risk. Policies define the specific rules that the Risk Engine evaluates.

Policy Spec Structure

A Policy spec includes:

FieldDescription
nameUnique identifier in camelCase (e.g., maxRowLimit, budgetCheck)
typeCategory of the policy
conditionValue DSL boolean expression that defines the rule
actionWhat happens when the condition is violated

Policy Types

TypePurposeExample
rowLimitPrevent operations that affect too many rowsBlock updates touching more than 1000 rows
budgetCheckEnsure financial operations stay within boundsWarn if payment exceeds configured threshold
rateLimitLimit how frequently a Tool can be invokedBlock more than 100 calls per minute
customUser-defined business rulesRequire manager approval for discounts over 50%

Policy Actions

When a Policy condition is violated, one of three actions is taken:

ActionBehavior
blockThe Tool cannot be deployed until the violation is resolved
warnThe Tool can be deployed, but the user must acknowledge the warning (logged in audit)
escalateThe violation is flagged for manual review by an admin

Invariants

While Policies operate at design time, Invariants operate at runtime as part of the Execution Contract. An Invariant is a business rule that must always hold true for an Entity.

Invariants are defined in the Entity spec as Value DSL boolean expressions. They are enforced at step 6 of the Execution Contract -- after the flow graph executes but before the transaction commits. If any invariant evaluates to false, the entire transaction rolls back.

Examples of invariants:

  • reservation.endDate > reservation.startDate -- End date must be after start date
  • order.totalPrice > 0 -- Order total must be positive
  • account.balance >= 0 -- Account balance cannot go negative

Risk Engine

The Risk Engine is the automated system that evaluates Policies against Tool specs. It assigns one of three risk levels:

LevelMeaningDeployable?
GreenAll safety patterns satisfiedYes
YellowWarning-level concerns detectedYes, with user acknowledgment
RedCritical safety violations foundNo -- must be resolved

Red-level Tools are blocked from deployment with no exceptions and no overrides. The violations must be fixed in the Tool spec before resubmitting.

The Risk Engine also provides auto-fix suggestions for common violations, such as wrapping writes in a Transaction boundary, adding Retry nodes to external calls, or converting hard deletes to soft deletes.

For the full list of risk classification criteria, signals, and auto-fix suggestions, see the risk rules reference.