Pre-release — The API surface may change. Unaudited.
Callcium LogoCallcium
API

PolicyBuilder

Fluent API for drafting policies from constraints.

Git Source

Functions

createRaw

Creates a selectorless draft from a comma-separated type list.

Git Source

function createRaw(string memory typesCsv) internal pure returns (PolicyDraft memory draft);

Parameters

NameTypeDescription
typesCsvstringThe comma-separated ABI types (e.g. "uint256,address").

Returns

NameTypeDescription
draftPolicyDraftThe initialized draft.

create

Creates a draft from a function signature.

Git Source

function create(string memory signature) internal pure returns (PolicyDraft memory draft);

Parameters

NameTypeDescription
signaturestringThe function signature.

Returns

NameTypeDescription
draftPolicyDraftThe initialized draft.

add

Adds a constraint to the active group with validation.

Git Source

function add(PolicyDraft memory draft, Constraint memory constraint) internal pure returns (PolicyDraft memory);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state.
constraintConstraintThe constraint to add.

Returns

NameTypeDescription
<none>PolicyDraftThe updated draft state with the constraint appended.

or

Starts a new constraint group (OR semantics between groups).

Git Source

function or(PolicyDraft memory draft) internal pure returns (PolicyDraft memory);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state.

Returns

NameTypeDescription
<none>PolicyDraftThe updated draft state with a new empty group.

build

Builds the final policy blob with strict validation.

Validates the policy and reverts on any issue.

Git Source

function build(PolicyDraft memory draft) internal pure returns (bytes memory);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state to build from.

Returns

NameTypeDescription
<none>bytesThe encoded policy blob.

buildUnsafe

Builds the final policy blob without validation.

Skips validation. The resulting policy may be invalid.

Git Source

function buildUnsafe(PolicyDraft memory draft) internal pure returns (bytes memory);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state to build from.

Returns

NameTypeDescription
<none>bytesThe encoded policy blob.

validate

Validates the policy without building.

Use for inspection, debugging, or custom error handling.

Git Source

function validate(PolicyDraft memory draft) internal pure returns (Issue[] memory);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state to validate.

Returns

NameTypeDescription
<none>Issue[]All validation issues found.

Errors

NoConstraintOperators

Thrown when the constraint has no operators.

Git Source

error NoConstraintOperators();

DuplicatePathInGroup

Thrown when the same (scope,path) appears twice within a group.

Git Source

error DuplicatePathInGroup(uint8 scope, bytes path);

Parameters

NameTypeDescription
scopeuint8The constraint scope.
pathbytesThe encoded be16 path.

InvalidScope

Thrown when an unsupported scope value is provided.

Git Source

error InvalidScope(uint8 scope);

Parameters

NameTypeDescription
scopeuint8The invalid scope value.

ArgIndexOutOfBounds

Thrown when the first path step exceeds the number of arguments.

Git Source

error ArgIndexOutOfBounds(uint256 argIndex, uint256 paramCount);

Parameters

NameTypeDescription
argIndexuint256The provided argument index.
paramCountuint256The parameter count from descriptor.

InvalidPathNavigation

Thrown when the path cannot be navigated according to scope rules.

Git Source

error InvalidPathNavigation(bytes path, uint256 stepIndex);

Parameters

NameTypeDescription
pathbytesThe encoded be16 path that failed validation.
stepIndexuint256The step index at which navigation failed.

TupleFieldOutOfBounds

Thrown when a tuple field index is out of bounds.

Git Source

error TupleFieldOutOfBounds(uint256 fieldIndex, uint256 fieldCount);

Parameters

NameTypeDescription
fieldIndexuint256The provided field index.
fieldCountuint256The tuple field count.

QuantifierOnNonArray

Thrown when a quantifier is used on a non-array node.

Git Source

error QuantifierOnNonArray(bytes path, uint256 stepIndex);

Parameters

NameTypeDescription
pathbytesThe encoded be16 path.
stepIndexuint256The step index of the invalid quantifier.

NestedQuantifier

Thrown when a path contains more than one quantifier step.

Git Source

error NestedQuantifier(bytes path, uint256 stepIndex);

Parameters

NameTypeDescription
pathbytesThe encoded be16 path.
stepIndexuint256The step index of the second quantifier.

EmptyGroup

Thrown when a group is empty.

Git Source

error EmptyGroup(uint256 groupIndex);

Parameters

NameTypeDescription
groupIndexuint256The index of the empty group.

Git Source

struct PolicyDraft {
    /// The canonical policy data.
    PolicyData data;
    /// Path hashes used per group for duplicate detection.
    bytes32[][] usedPathHashes;
}

On this page