The independent-review rule fits on one line:
guard: "user.id != $record.submittedBy"
Understanding that line requires more than knowing what inequality means. Which user is bound? Which record is visible? Has the request body been merged? What happens if an identifier is unknown? Does evaluation return a boolean, or a value converted to truth?
These questions define the expression’s execution context. AEL is used by several ADL constructs, and the construct determines what the expression can see and when it runs.
Follow the record through the request
For the inspected state-machine guard, $record is the existing stored record. The executor binds the current caller as both user and $user. A body that changes another field does not first change the guard’s view of the record. The guard answers a precondition about the existing state.
Validation of the effective update happens later on a merged record after transition assignments. A guard and a validation rule can therefore legitimately observe different values during one request. If a requirement concerns the stored precondition, put it where that precondition is available. If it concerns the resulting record, verify that the chosen rule runs against that result.
The distinction also explains a historical defect. Older code bound user but not $user in this guard context. An inequality using the unbound alias could pass for the actual submitter. The current reference describes the fix and its version; the new lab exercises the authenticated submitter directly rather than assuming that a familiar variable name is bound correctly.
Keep values and truth separate
The JSON-based evaluator has value conversions. The text 'false' is a nonempty string; it is not the boolean false. A predicate expected to deny on false should produce a boolean. Quoting the YAML expression preserves its source text, but quoting a word inside the expression changes the value the expression returns.
For example, the YAML scalar guard: false and the string guard: "false" are different inputs to the parser. The reference documents a path where the boolean declaration value is ignored while the expression string evaluates to false. Use the declared expression form and validate the document you actually wrote.
Missing values require similar precision. A nullable data property can be absent for an ordinary business reason. An absent authority claim means the caller has not supplied evidence for that authority. The policy supervisor treats missing referenced claims conservatively; ordinary expressions have their own configured behavior. Do not derive authorization by comparing an absent value with an arbitrary string.
Read access is part of an aggregate’s meaning
Guards and policies can use read functions such as count, exists, and lookup in the supported scope. These reads operate under the caller’s readCondition. A count of zero can therefore mean that no matching row exists or that no matching row is visible to that caller.
Suppose approval requires a current training record. A positive-count condition denies when the record cannot be established, which is often the intended behavior. A negative condition such as “no revocation exists” is more delicate: an invisible revocation must not be mistaken for its absence. Design the authority and visibility of the evidence resource together.
Also distinguish readCondition filtering from full resource-policy enforcement. The current policy reference says that AEL reads from another resource’s guard or rule are not checked against that resource’s policies. Calling a read function does not automatically reproduce the public GET path.
Bound the claim made by validation
Closed identifier checking catches many misspellings and illegal scope references before deployment. It does not prove that every expression returns the intended value for every record. Type conversions, data-dependent failures, and runtime inputs still matter. A compiler diagnostic identifies a static problem; a clean result establishes only that the implemented checks found none.
The relevant sources are ADL 18, the guard context in ADL 22, and evaluator.cpp.
Workshop
Describe a training rule that must deny when the training resource is unavailable. Identify separately the outcomes for a visible valid row, a visible expired row, an invisible row, and an evaluation error. Decide which observations your test must retain to distinguish those cases.