Interface: PolicyBuilder<THandle>
Defined in: builders/policy-builder.ts:113
Fluent builder for capability and sandbox policies (P.policy(id)).
Aggregates ordered guard clauses (fs.protect, fs.readOnly, node.allowBinaries), quota tripwires (fs.quotaTripwire), quantitative turn/cost/duration limits, and .extend(newId).
Extends
AstBuilder<PolicyNode<THandle>>
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
THandle | unknown | Runtime handle type of the active isolation scope. |
Methods
extend()
extend(newId): PolicyBuilder<THandle>;Defined in: builders/policy-builder.ts:211
Clones this policy under newId, inheriting all existing clauses, tripwires, limits, and hooks.
Re-keys inherited guard clause IDs deterministically as "${newId}:clause:${i}".
Parameters
| Parameter | Type | Description |
|---|---|---|
newId | string | Unique identifier for the derived policy. |
Returns
PolicyBuilder<THandle>
New immutable policy builder initialized with inherited state.
guard()
guard(...guards): PolicyGuardClauseBuilder<THandle>;Defined in: builders/policy-builder.ts:126
Starts a new guard clause inspecting pre-flight or post-flight ToolEffect lists.
Returns a PolicyGuardClauseBuilder requiring .onViolation(...) to complete the clause.
Parameters
| Parameter | Type | Description |
|---|---|---|
...guards | readonly MaybeBuilder<PolicyGuardASTNode>[] | Guard AST nodes or builders. |
Returns
PolicyGuardClauseBuilder<THandle>
Pending clause builder requiring .onViolation(...).
maxCostUsd()
maxCostUsd(costUsd): PolicyBuilder<THandle>;Defined in: builders/policy-builder.ts:163
Sets the maximum cumulative USD cost allowed per actor execution under this policy.
Breaching costUsd triggers onLimitExceeded (if configured) or terminates the step.
Parameters
| Parameter | Type | Description |
|---|---|---|
costUsd | number | Positive USD cost ceiling. |
Returns
PolicyBuilder<THandle>
New immutable policy builder.
maxDurationSeconds()
maxDurationSeconds(seconds): PolicyBuilder<THandle>;Defined in: builders/policy-builder.ts:174
Sets the maximum wall-clock duration in seconds allowed per actor execution under this policy.
Breaching seconds triggers onLimitExceeded (if configured) or terminates the step.
Parameters
| Parameter | Type | Description |
|---|---|---|
seconds | number | Positive duration ceiling in seconds. |
Returns
PolicyBuilder<THandle>
New immutable policy builder.
maxTurns()
maxTurns(turns): PolicyBuilder<THandle>;Defined in: builders/policy-builder.ts:152
Sets the maximum number of model turns allowed per actor execution under this policy.
Breaching turns triggers onLimitExceeded (if configured) or terminates the step.
Parameters
| Parameter | Type | Description |
|---|---|---|
turns | number | Positive integer turn ceiling. |
Returns
PolicyBuilder<THandle>
New immutable policy builder.
onAbort()
onAbort(abortHook): PolicyBuilder<THandle>;Defined in: builders/policy-builder.ts:185
Binds a policy-level default abort hook (git.snapshotAndReset()) for unhooked .replaceWith() edges.
Satisfies Tier-1 'scope' replacement requirements when a step's .replaceWith() omits .onAbort().
Parameters
| Parameter | Type | Description |
|---|---|---|
abortHook | MaybeBuilder<AbortHookASTNode<THandle, Record<string, unknown>>> | Abort hook AST node or builder. |
Returns
PolicyBuilder<THandle>
New immutable policy builder.
onLimitExceeded()
onLimitExceeded(configure): PolicyBuilder<THandle>;Defined in: builders/policy-builder.ts:198
Configures the limit-exceeded flush interrupt and optional abort hook when a quantitative limit is reached.
Invokes configure with a PolicyLimitExceededBuilder and stores the compiled config.
Parameters
| Parameter | Type | Description |
|---|---|---|
configure | ($limit) => PolicyLimitExceededBuilder<THandle> | Limit-exceeded configurator callback. |
Returns
PolicyBuilder<THandle>
New immutable policy builder.
toAST()
toAST(): PolicyNode;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
Deeply frozen passive AST node.
Inherited from
tripwire()
tripwire(...tripwires): PolicyBuilder<THandle>;Defined in: builders/policy-builder.ts:139
Appends stateful QuotaTripwireASTNode monitors (fs.quotaTripwire) evaluated across cumulative effects.
Tripwires raise their configured interrupt when cumulative workspace mutations exceed thresholds.
Parameters
| Parameter | Type | Description |
|---|---|---|
...tripwires | readonly MaybeBuilder<FsQuotaTripwireNode>[] | Quota tripwire AST nodes or builders. |
Returns
PolicyBuilder<THandle>
New immutable policy builder.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
id | readonly | string | Unique identifier of the policy. | builders/policy-builder.ts:115 |