Resolves subject slots to values at evaluation time.

A CompiledRule receives a RuleScope and reads each slot it needs (e.g. the current user, the object in context). Each scope resolves slots its own way: by walking the DOM, by consulting a session-wide default, or by reading from a fixed value bag. The caller picks which strategy when they build the scope with scope.

One method, get(slot). A primitive that needs more than one slot calls get multiple times.

Each slot resolves in order from most specific to least: a per-call override on scope wins first, then the closest DOM ancestor that registered a value through provideSubject, then a session-wide default registered through registerSubject. If none of those answer, get returns undefined and primitives reading the slot return false.

Resolution is pull-based, not reactive: a RuleScope answers the current value on each get call but does not notify when a value changes. Re-evaluating a rule when its inputs change is the caller's responsibility.

Example

Reading a slot inside a primitive's predicate

type OlderThanArgs = { days: number };

const olderThan = definePrimitive({
id: 'limetech.object-older-than',
reads: ['limeobject'],
build: ({ days }: OlderThanArgs) => (scope) => {
const obj = scope.get('limeobject');
if (!obj) return false;
return daysSince(obj.createdtime) > days;
},
});

See

  • scope, the only supported way to construct a RuleScope.
  • SubjectRegistry, what slots exist and what they return.

Hierarchy

  • RuleScope

Methods

Methods

  • Look up the current value of a subject slot.

    Returns

    The value if any provider answered, otherwise undefined. Primitives that read a missing slot should return false.

    Type Parameters

    Parameters

    Returns SubjectRegistry[K]