Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Examples

ExampleDescription
access_not_revoked_since_grantThe “open session” idiom: a negated left operand on since expresses “has
alert_exactly_three_transfersCounting over a *-wildcard field: permit an Alert only if exactly three
alert_heartbeat_and_login_rateA top-level && chain combining a formerly with an exists-guarded count
alert_login_and_big_transferNested exists with a value-threshold filter: permit an Alert when the
alert_login_current_tpThe canonical tp(t) count-over-timepoints idiom with no temporal wrapper
alert_login_in_last_hourCounting over history: a formerly within 1h body inside the aggregation
alert_pending_transfersAggregate-vs-aggregate comparison (parenthesized left, bare right): permit an
alert_same_principal_login_transferAn entity-typed exists binder that correlates on the request principal
alert_same_user_login_and_transferA shared exists variable joins two different predicates through a common
alert_some_loginexists is the sole quantifier: it asserts at least one satisfying
alert_total_transfer_over_200Aggregation example: permit an Alert only when the total transferred amount
allow_anythingAn unconstrained (bare) scope triple: all three slots (principal, action,
approve_has_output_guardThe has attribute-existence guard before reading an optional Bool output
call_cedar_macro_as_argumentA Cedar macro call passed as an argument to another macro call:
call_cedar_macro_is_smallA def cedar macro called in an ordinary when { … } position:
call_cedar_macro_with_temporal_leafA Cedar macro conjoined mid-expression with a temporal { … } leaf. Because a
call_cedar_macros_composedTwo Cedar macros composed with && in one when { … } clause:
call_temporal_aggregation_macro_countCalling a def temporal aggregation macro. count_formerly produces a
call_temporal_condition_macro_onceCalling a def temporal condition macro inside a when temporal { … }
call_temporal_condition_macros_composedTwo def temporal condition macros composed with && inside a single
cedar_eligible_not_blockedTwo def cedar macros of different argument types composed with && inside one
cedar_is_small_thresholdThe simplest def cedar macro: is_small(?n) names the < 100 threshold so
cedar_macro_plus_temporal_leafA def cedar boolean macro (level_ok) conjoined mid-expression with an
cedar_semver_gtThe RFC 0061 semver worked example for Cedar macros: a record-building macro
cedar_starts_with_f_likeA Cedar macro whose body is a like wildcard pattern: starts_with_f(?s)
cedar_within_cap_if_elseA def cedar macro whose body is an if/then/else expression, encoding a
cond_is_oauth_in_teamThe expression-level counterpart of the is / is-in scope constraint: an
deny_overrides_sell_not_amznA permit + forbid pair showing deny-overrides semantics: SellShares is
forbid_large_except_amznMixing when and unless on a forbid rule: block large SellShares
forbid_read_transfers_over_1000A forbid rule with a sum over a (value, timepoint) domain and a filtered
get_amzn_stock_infoA plain (non-temporal) permit showing that an MCP-manifest input field
heartbeat_scope_aliasformerly with scope-alias correlation. Permit an Alert only if a
login_attempt_custom_kindA custom, author-defined event kind. The per-case event schema
macro_library_once_is_smallDemonstrates the shareable macro library: the policy calls once (a
max_window_raisedRaising the temporal look-back cap. The event schema’s default cap on any
permit_read_anyoneThe simplest useful rule: permit the Read action for any principal on any
principal_is_oauthDemonstrates the principal is Type entity-type scope constraint: the policy
provider_allowed_or_shortDisjunction and parentheses over two information providers: permit Read when
provider_digitcount_forbidA provider gating a forbid rule, alongside a catch-all permit – showing
provider_digitcount_operator_geThe operator-form comparison example (>= on an integer provider output),
provider_filter_set_index_decimalThe guardrail flagship shape in one atom: a set argument
provider_int_arithmetic_trustedA provider’s integer output used inside arithmetic, mixed under && with a
provider_matches_and_not_blockedTwo information providers combined with the boolean spine (&& and !) inside
provider_principal_id_allowlistPermit Read only when the requesting principal is on the provider’s
provider_regex_analyze_fieldsSeveral calls to the same Regex::Analyze provider, each projecting a
provider_regex_matches_uppercaseThe canonical worked information-provider example: permit Read only when the
provider_risk_decimal_methodThe decimal-extension-method comparison form. The Content::Risk provider
read_after_loginThe history-dependent version of the getting-started tour (Step 4 — a decision that
read_after_login_successResponse predicate + output-field filter: permit a Read only if the **same
read_heartbeat_since_login_30ssince with a short (seconds) window: the anchor must be recent enough, or the
read_login_not_logoutThe accepted “A but not B” idiom with restrictor-first conjunct ordering.
read_prev_compute_open_sessionA top-level previous && (open-session since) chain: permit a Read only if the
read_prev_loginprevious within 1h: permit a Read only if the immediately preceding
read_prev_login_successprevious with a response predicate and an output-field filter.
read_since_loginPositive-left since within 1h: the left operand must have **held
sell_after_2024_datetimeA single datetime literal compared with an ordinary comparison operator
sell_after_approval_valid_tickerTwo Dogwood clause forms combined on a single rule:
sell_comparison_chainSeveral comparison operators chained in a single && conjunction on a Long.
sell_datetime_windowDatetime ordered comparison expressing a calendar-year time window: permit
sell_like_a_prefixThe like operator matches a string against a wildcard pattern, where *
sell_logical_groupingLogical connectives ||, &&, and ! with parenthesized grouping to override
sell_nested_if_thresholdNested if/then/else used as an operand rather than a top-level
sell_nonzero_proceeds_decimalDecimal supports equality only (== / !=); ordered comparison on
sell_not_blocked_stringString inequality (!=) — one of the two operators strings support (== and
sell_not_test_tickers_likeThe like string-pattern operator used under unless as a denylist idiom: a
sell_or_approve_action_inaction in [ ... ]: list-membership matching on the action. This rule permits
sell_shares_eq_scopeAn == scope constraint pinning the action to a specific entity reference: this
sell_shares_temporal_subexprA temporal { ... } marker used as a sub-expression inside a larger Cedar
sell_small_onlyThe canonical five-part rule shape: annotation + effect + parenthesized scope
sell_small_proceeds_decimal_methodDecimal .lessThan(...) method call — how decimals are ordered. Cedar decimals
sell_threshold_by_stockAn if / then / else used as the whole body of a when clause reads like a
sell_two_when_small_amznTwo when clauses stacked on one rule are implicitly conjoined: both must
sell_unless_hugeBasic unless { ... } clause: permit SellShares unless the order is
sell_when_under_100A basic when { ... } condition clause: a when body must evaluate true for
sell_when_unless_mixMixing when and unless clauses on a single permit rule. Because clauses
sell_zero_proceeds_if_hasThe if C has attr then ... else false idiom guards an optional output field.
simplest_permitThe simplest possible policy: a bare permit for GetStockInfo with no
submit_after_approval_injectionA def temporal macro (approved_recently) whose predicate-valued parameter
temporal_count_formerly_loginAn aggregation-flavoured temporal macro. count_formerly(?w, ?s) counts the
temporal_login_then_readTwo def temporal condition macros joined with && inside a single
temporal_once_read_recentA condition-flavoured temporal macro. `def temporal once(?w, ?s) { formerly
temporal_sum_formerly_transferA temporal sum aggregation macro defined inline. sum_formerly combines a
traders_is_in_group_scopeThe is Type in Group scope constraint: the principal slot both tests the
transfer_prev_nested_conjprevious’s body must be a single atom, so a conjunction has to be
write_after_readThe canonical history-dependent policy: permit SellShares only if the **same
write_after_read_formerlyThe flagship history-dependent policy in the guide’s literal wording: permit a