Skip to content

Interface: PolicyGuardClauseBuilder<THandle> ​

Defined in: builders/policy-builder.ts:69

Intermediate fluent builder returned by P.policy(id).guard(...guards) requiring .onViolation(...).

Forces callers to explicitly bind either 'deny-with-error' or 'raise-interrupt' for every registered guard clause before returning to PolicyBuilder.

Type Parameters ​

Type ParameterDefault typeDescription
THandleunknownRuntime handle type of the active isolation scope.

Methods ​

onViolation() ​

Call Signature ​

ts
onViolation(mode, messageMapper?): PolicyBuilder<THandle>;

Defined in: builders/policy-builder.ts:80

Rejects violating tool calls in-band and returns a structured error string to the model.

When messageMapper is omitted, the runtime injects violation.violationSummary into the tool error result.

Parameters ​
ParameterTypeDescription
mode"deny-with-error"In-band error rejection mode.
messageMapper?(violation) => stringOptional custom error formatter.
Returns ​

PolicyBuilder<THandle>

Parent PolicyBuilder with the guard clause appended.

Call Signature ​

ts
onViolation<TPayload>(
   mode, 
   interrupt, 
   mapViolation
): PolicyBuilder<THandle>;

Defined in: builders/policy-builder.ts:98

Halts the offending tool batch and raises a typed InterruptNode into the active interrupt hierarchy.

Maps the PolicyViolation into TPayload via mapViolation and validates it against interrupt.schema.

Type Parameters ​
Type ParameterDescription
TPayloadInterrupt payload type validated by interrupt.schema.
Parameters ​
ParameterTypeDescription
mode"raise-interrupt"Interrupt escalation mode.
interruptMaybeBuilder<InterruptNode<TPayload>>Target interrupt AST node or builder.
mapViolation(violation) => TPayloadViolation-to-payload projector.
Returns ​

PolicyBuilder<THandle>

Parent PolicyBuilder with the guard clause appended.

Released under the MIT License.