> ## Documentation Index
> Fetch the complete documentation index at: https://base-a060aa97-docs-sync-code-change-be6d045.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# IPolicyRegistry.createCompositePolicy

> Creates a new composite policy combining existing simple policies under a logic gate.

## Signature

```solidity IPolicyRegistry.sol theme={null}
function createCompositePolicy(address admin, PolicyType policyType, uint64[] calldata childPolicyIds) external returns (uint64 newPolicyId);
```

| Field               | Value                                           |
| ------------------- | ----------------------------------------------- |
| Selector            | `0x6fdd1491`                                    |
| Canonical signature | `createCompositePolicy(address,uint8,uint64[])` |

## Description

Creates a new composite policy that combines 2–4 existing simple (`ALLOWLIST` or `BLOCKLIST`) policies under a `UNION` (OR) or `INTERSECT` (AND) logic gate. The composite references its children live: `isAuthorized` reads current child membership on every call, so updating a child's membership immediately affects what the composite authorizes.

The new policy is assigned a `uint64` ID whose top byte encodes `PolicyType`; the low 56 bits come from a global counter.

## Parameters

| Name             | Type                   | Description                                                                                                                                                                                                    |
| ---------------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `admin`          | `address`              | Initial admin authorized to update child policies and transfer or renounce administration. Must not be `address(0)`.                                                                                           |
| `policyType`     | `PolicyType` (`uint8`) | Must be `UNION` or `INTERSECT`.                                                                                                                                                                                |
| `childPolicyIds` | `uint64[]`             | Existing simple policy IDs to combine. Must contain 2–4 entries (`MIN_COMPOSITE_CHILD_POLICIES` to `MAX_COMPOSITE_CHILD_POLICIES`). No composites and no built-in sentinels (`ALWAYS_ALLOW` / `ALWAYS_BLOCK`). |

## Returns

| Name          | Type     | Description                             |
| ------------- | -------- | --------------------------------------- |
| `newPolicyId` | `uint64` | The newly assigned composite policy ID. |

## Revert Conditions

| Error                         | Condition                                                                                                          |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `ZeroAddress`                 | `admin` is `address(0)`.                                                                                           |
| `IncompatiblePolicyType`      | `policyType` is not `UNION` or `INTERSECT`.                                                                        |
| `ChildPoliciesOutsideOfRange` | `childPolicyIds.length` is outside `[MIN_COMPOSITE_CHILD_POLICIES, MAX_COMPOSITE_CHILD_POLICIES]` (2–4 inclusive). |
| `PolicyNotFound`              | Any child policy ID does not exist.                                                                                |
| `InvalidChildPolicy`          | Any child is a composite policy or a built-in sentinel.                                                            |
| `Panic(0x11)`                 | The global policy counter has reached its maximum value (arithmetic overflow).                                     |

## Access Control

Permissionless creation, but this call reverts with `FeatureNotActivated` while the PolicyRegistry feature is inactive.

## Events Emitted

On success, three events are emitted:

* `PolicyCreated(newPolicyId, creator, policyType)`
* `PolicyAdminUpdated(newPolicyId, address(0), admin)`
* `CompositePolicyUpdated(newPolicyId, creator, childPolicyIds)`

## Example

```solidity Usage Example theme={null}
IPolicyRegistry(target).createCompositePolicy(admin, PolicyType.UNION, childPolicyIds);
```
