AlphaAlphaAttach or replace the display metadata for an already-registered primitive. Use this when the runtime side of a primitive (the factory + matching engine) is registered by the platform, and the UI binding (a configComponent to author its args) is contributed by a UI layer that loads later.
Replaces any prior metadata for id wholesale; merge externally
if partial updates are needed.
The primitive id whose metadata to set.
The display metadata to attach.
AlphaTurn a Rule into a callable predicate.
Every ref is resolved against the registered primitives and
saved rules. Saved rules are expanded in place and cycles are
detected. Args at each leaf are not validated by the contract;
primitives are responsible for handling their own args (see
RulePrimitive). An implementation may surface
args-mismatch issues if it has a way to introspect a primitive's
args, but the contract does not require it.
The returned predicate is a snapshot: it reflects whatever was
registered when compile ran, so anything compiled against an
older set of saved rules is stale once those rules change. If
results are cached, recompile when saved rules change. Re-running
compile on a structurally-equal rule may or may not return the
same CompiledRule instance, so don't rely on identity equality.
Thrown errors inside a predicate are caught and treated as
false for that node, the same outcome as a missing context key.
Callers do not need to wrap evaluations in try/catch. This
fail-closed behavior applies only to errors raised at
evaluation time. Errors raised by RulePrimitive.build
while compiling propagate out of compile, so a primitive that
cannot handle its args should return a constant-false
predicate from build rather than throwing.
The rule to compile.
A predicate over ContextScope.
If the rule has an unknown-ref or cycle issue, or if
a RulePrimitive.build call throws. Implementations that
validate args may also throw args-mismatch.
args-on-saved-rule does not throw, the args are dropped and
RuleRegistry.validate reports it as a diagnostic. Use
RuleRegistry.validate for the non-throwing variant.
OptionallistAlphaList the display metadata supplied at registration.
Optional, an implementation that doesn't track metadata can leave this method off. When present, returns one entry per registered primitive.
Metadata for each registered primitive.
AlphaList the registered primitives, the runtime-callable side only. For titles, icons, or custom args editors, use listMetadata.
AlphaRegister a RulePrimitive.
The id must be namespaced (contain a .) and must not be in use
already, neither by another primitive nor by a saved rule.
metadata is optional and carries the display side of things:
title, description, icon, tags, and a
configComponent for
editing the primitive's args. None of it is used at evaluation
time; it shows up later via
listMetadata.
The primitive to register.
Optionalmetadata: ConfigMetadataOptional display metadata.
AlphaBuild a ContextScope, the same as ContextRegistry.scope. Exists on the rule registry as a convenience so the typical "compile and evaluate" sequence stays a single-service interaction.
New non-rule consumers should reach for ContextRegistry.scope directly.
Optionaloptions: ContextScopeOptionsOptional construction options.
A new ContextScope.
AlphaSame checks as compile, but returns structured diagnostics instead of throwing, and no predicate is produced.
available is a hint from the caller, not something the
registry can verify: the registry doesn't know which context
keys will be supplied at evaluation time, only the caller
building the scope does. Pass it when known; otherwise the
runtime fallback (missing keys produce false) catches the gap.
The rule to validate.
Optionalavailable: (keyof ContextMap)[]Optional list of context keys the caller
knows will be available where the rule runs. Used to surface
missing-slot issues at save time.
ok: true when the rule passes every check; otherwise
ok: false with a list of issues.
The central place primitives and rules come together.
This package only describes the contract; the actual behavior is supplied by an implementation, reached through the platform service
ruleRegistry.What the API does, by area:
Context resolution (DOM-walked providers, session-wide fallbacks, scope construction) lives on ContextRegistry. Primitives read from a ContextScope without needing to know which service built it.
Saved rules are loaded by the host client from its own config layer at boot and live in the same id namespace as primitives. They are not registered through this interface. The registry resolves references during compile and validate but exposes no public API for managing them.
Example
Compiling and evaluating a rule from a web component
Example
Test-fixture scope