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 Parameter | Default type | Description |
|---|---|---|
THandle | unknown | Runtime handle type of the active isolation scope. |
Methods
onViolation()
Call Signature
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
| Parameter | Type | Description |
|---|---|---|
mode | "deny-with-error" | In-band error rejection mode. |
messageMapper? | (violation) => string | Optional custom error formatter. |
Returns
PolicyBuilder<THandle>
Parent PolicyBuilder with the guard clause appended.
Call Signature
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 Parameter | Description |
|---|---|
TPayload | Interrupt payload type validated by interrupt.schema. |
Parameters
| Parameter | Type | Description |
|---|---|---|
mode | "raise-interrupt" | Interrupt escalation mode. |
interrupt | MaybeBuilder<InterruptNode<TPayload>> | Target interrupt AST node or builder. |
mapViolation | (violation) => TPayload | Violation-to-payload projector. |
Returns
PolicyBuilder<THandle>
Parent PolicyBuilder with the guard clause appended.