Rule
The fundamental statement within a policy, connecting an action with an effect.
A Rule is the core building block of a PD-REL policy. It defines whether a specific action is permitted or prohibited, under what conditions (constraints), and what obligations (duties) must be fulfilled. Rules can be simple statements or complex expressions with multiple conditions and obligations.
Per the PD-REL v1.0 specification: "The fundamental statement within a policy. It connects an Action with an effect (permit or prohibit)."
Examples
// Simple permit rule allowing usage
const basicRule: Rule = {
action: 'USE',
effect: 'permit'
};
// Rule with time constraint and payment duty
const restrictedRule: Rule = {
action: 'REPRODUCE',
effect: 'permit',
description: 'Allow reproduction for one year with payment',
constraints: [{
type: 'TIME_PERIOD',
value: {
start: Date.now() / 1000,
end: Date.now() / 1000 + 31536000 // One year
}
}],
duties: [{
type: 'PAYMENT',
value: {
amount: '50.00',
currency: 'USD',
recipient: 'creator-wallet-address'
}
}]
};
// Prohibition rule with specific target
const prohibitRule: Rule = {
action: 'COMMERCIALIZE',
effect: 'prohibit',
description: 'Commercial use prohibited for this specific asset',
target: 'ipfs://QmXxx123...' // Overrides policy-level target
};
// Complex rule with multiple constraints and duties
const complexRule: Rule = {
action: 'MODIFY',
effect: 'permit',
description: 'Allow modifications with attribution and token gate',
constraints: [
{
type: 'TOKEN_GATED',
value: {
chainId: 1,
contractAddress: '0xNFT...',
minBalance: 1
}
},
{
type: 'USAGE_COUNT',
value: 100
}
],
duties: [
{
type: 'ATTRIBUTION',
value: 'Modified from original work by Creator Name'
},
{
type: 'SHARE_ALIKE',
value: 'ipfs://QmPolicy123...'
}
]
};
Definition
interface Rule {
/**
* The specific action being regulated. Must be from the PD-REL vocabulary (Action) or a custom URI. This defines what activity the rule is governing.
*/
action: string;
/**
* The deontic effect of the rule. - `'permit'`: Allows the action (may require duties to be fulfilled) - `'prohibit'`: Forbids the action (duties are not applicable)
*/
effect: 'permit' | 'prohibit';
/**
* A human-readable description of this specific rule. Provides context and clarification for the rule's purpose. Useful for UI display and policy documentation.
*/
description?: string;
/**
* An optional, specific asset identifier that this rule applies to. Overrides the policy-level target for this specific rule. Useful when a policy governs multiple assets with different rules.
*/
target?: string;
/**
* An array of constraints that must ALL be met for this rule to be active. Constraints define the conditions under which the rule applies. All constraints use AND logic - every constraint must be satisfied. An empty array or undefined means no constraints (always active).
*/
constraints?: Constraint[];
/**
* An array of obligations that must be fulfilled to exercise a 'permit' rule. Duties define what the user must do to gain permission. Only applicable to 'permit' rules - 'prohibit' rules cannot have duties. All duties must be fulfilled to exercise the permission.
*/
duties?: Duty[];
}
Properties
action
The specific action being regulated.
Must be from the PD-REL vocabulary (Action) or a custom URI. This defines what activity the rule is governing.
Type: string
Examples
action: 'USE' // Standard action
action: 'TRANSFER' // Standard action
action: 'https://example.com/actions/stream' // Custom action
effect
The deontic effect of the rule.
'permit': Allows the action (may require duties to be fulfilled)'prohibit': Forbids the action (duties are not applicable)
Type: 'permit' | 'prohibit'
description
A human-readable description of this specific rule.
Provides context and clarification for the rule's purpose. Useful for UI display and policy documentation.
Type: string
Optional
Examples
description: 'Allow personal use only, no commercial exploitation'
target
An optional, specific asset identifier that this rule applies to.
Overrides the policy-level target for this specific rule. Useful when a policy governs multiple assets with different rules.
Type: string
Optional
Examples
target: 'ipfs://QmXxx...' // IPFS hash
target: 'ar://abc123...' // Arweave ID
target: 'caip19:eip155:1/erc721:0x123.../1' // CAIP-19 format
constraints
An array of constraints that must ALL be met for this rule to be active.
Constraints define the conditions under which the rule applies. All constraints use AND logic - every constraint must be satisfied. An empty array or undefined means no constraints (always active).
Type: Constraint[]
Optional
duties
An array of obligations that must be fulfilled to exercise a 'permit' rule.
Duties define what the user must do to gain permission. Only applicable to 'permit' rules - 'prohibit' rules cannot have duties. All duties must be fulfilled to exercise the permission.
Type: Duty[]
Optional
See Also
-
- Action for predefined action types
- Constraint for rule conditions
- Duty for rule obligations
- Policy for how rules are organized
- RuleBuilder for fluent rule creation
Since
Version 1.0.0