Skip to content

Interface: ScopedRuleBuilder ​

Defined in: builders/scoped-rule-builder.ts:13

Fluent builder for partition- or effect-scoped rules (P.scopedRule(idOrSource)).

Compiles inline or frontmatter-sourced scoped rules with .when() activation predicates, .directive() prompt blocks, and optional .enforceBeforeStop() check gates.

Extends ​

Methods ​

directive() ​

ts
directive(directiveSource): ScopedRuleBuilder;

Defined in: builders/scoped-rule-builder.ts:37

Sets the rule directive text or SourceASTNode<string> injected when when matches.

Normalizes inline strings and source builders into a passive SourceValue<string>.

Parameters ​

ParameterTypeDescription
directiveSourceMaybeSource<string>Inline directive string or source node/builder.

Returns ​

ScopedRuleBuilder

New immutable scoped rule builder.


enforceBeforeStop() ​

ts
enforceBeforeStop<THandle>(...checks): ScopedRuleBuilder;

Defined in: builders/scoped-rule-builder.ts:50

Attaches deterministic CheckASTNode gates enforced during beforeStop when this rule is active and scope mutations occur.

Appends checks in declaration order to the rule's enforceBeforeStopChecks list.

Type Parameters ​

Type ParameterDefault typeDescription
THandleunknownIsolation scope handle type.

Parameters ​

ParameterTypeDescription
...checksreadonly MaybeBuilder<BuiltInCheckASTNode<THandle>>[]Deterministic check AST nodes or builders.

Returns ​

ScopedRuleBuilder

New immutable scoped rule builder.


toAST() ​

ts
toAST(): ScopedRuleNode;

Defined in: ast/ast-builder.ts:20

Compiles the current builder configuration into a deeply frozen passive AST node.

Validates required builder invariants at compilation time and returns an immutable plain-object AST representation containing zero execution methods.

Returns ​

ScopedRuleNode

Deeply frozen passive AST node.

Inherited from ​

AstBuilder.toAST


when() ​

ts
when(predicate): ScopedRuleBuilder;

Defined in: builders/scoped-rule-builder.ts:26

Configures the partition and/or reactive tool-effect predicate triggering rule injection.

Rules matching predicate.partitions are injected pre-flight at Turn 0; rules matching predicate.effects are injected post-call.

Parameters ​

ParameterTypeDescription
predicateScopePredicateInputPartition list and optional effect matcher.

Returns ​

ScopedRuleBuilder

New immutable scoped rule builder.

Properties ​

PropertyModifierTypeDescriptionDefined in
idreadonlystringUnique identifier of the scoped rule.builders/scoped-rule-builder.ts:15

Released under the MIT License.