Skip to main content

Custom Rules Overview

The LLMTAG plugin’s custom rules engine allows you to create sophisticated, conditional protection rules that go beyond basic global and path-based policies.

Advanced Rule Engine

Conditional LogicComplex ScenariosDynamic PoliciesFlexible Configuration

Rule Types

Conditional Rules

Create rules that apply different policies based on specific conditions:

Time-Based Rules

Example: Block AI training during business hours Use Case: Protect sensitive content during peak usage

User-Based Rules

Example: Different policies for logged-in vs. anonymous users Use Case: Protect premium content for subscribers

Content-Type Rules

Example: Different policies for images vs. text content Use Case: Allow AI training for text but block for images

Geographic Rules

Example: Different policies based on visitor location Use Case: Comply with regional AI regulations

Dynamic Rules

Rules that change based on real-time conditions:

Traffic-Based Rules

Example: Stricter policies during high traffic periods Use Case: Protect content during viral moments

Threat-Based Rules

Example: Block suspicious AI agents automatically Use Case: Adaptive protection against new threats

Content-Age Rules

Example: Allow AI training for older content Use Case: Gradual content release strategy

Performance-Based Rules

Example: Adjust protection based on server load Use Case: Balance protection with performance

Rule Builder Interface

Visual Rule Builder

1

Select Rule Type

Choose from predefined rule types or create a custom rule.
2

Define Conditions

Set the conditions that trigger the rule.
3

Configure Actions

Define what happens when conditions are met.
4

Set Priorities

Determine rule execution order and precedence.
5

Test and Deploy

Test the rule in a safe environment before deploying.

Rule Configuration

{
  "rule_name": "Business Hours Protection",
  "conditions": {
    "time": {
      "start": "09:00",
      "end": "17:00",
      "timezone": "UTC",
      "days": ["monday", "tuesday", "wednesday", "thursday", "friday"]
    },
    "content_type": "premium"
  },
  "actions": {
    "ai_training_data": "disallow",
    "ai_use": ["search_indexing"],
    "block_agents": ["all_commercial"]
  },
  "priority": 100,
  "enabled": true
}

Advanced Rule Examples

E-commerce Protection

{
  "rule_name": "E-commerce Product Protection",
  "conditions": {
    "path": "/products/",
    "user_status": "anonymous",
    "content_value": "high"
  },
  "actions": {
    "ai_training_data": "disallow",
    "ai_use": ["search_indexing"],
    "verification_required": true,
    "custom_message": "Product information protected"
  }
}

News Site Protection

{
  "rule_name": "Breaking News Protection",
  "conditions": {
    "content_age": "< 24 hours",
    "content_category": "breaking_news",
    "traffic_level": "high"
  },
  "actions": {
    "ai_training_data": "disallow",
    "ai_use": ["search_indexing"],
    "block_agents": ["all_ai_agents"],
    "temporary_duration": "24 hours"
  }
}

Educational Content

{
  "rule_name": "Educational Content Policy",
  "conditions": {
    "path": "/education/",
    "content_license": "creative_commons",
    "user_type": "student"
  },
  "actions": {
    "ai_training_data": "allow",
    "ai_use": ["search_indexing", "generative_synthesis", "research"],
    "attribution_required": true
  }
}

Rule Execution Engine

Execution Order

Rules are executed in the following order:
1

Priority Sorting

Rules are sorted by priority (higher numbers first).
2

Condition Evaluation

Each rule’s conditions are evaluated in order.
3

Action Application

Actions from matching rules are applied.
4

Conflict Resolution

Conflicting actions are resolved based on precedence.
5

Final Policy

The final policy is applied to the request.

Conflict Resolution

Last Rule Wins

Method: Later rules override earlier ones Use Case: General rules with specific exceptions

Most Restrictive

Method: Apply the most restrictive policy Use Case: Security-focused configurations

Most Permissive

Method: Apply the most permissive policy Use Case: User-friendly configurations

Custom Logic

Method: Define custom conflict resolution Use Case: Complex business requirements

Performance Optimization

Rule Caching

1

Rule Compilation

Compile rules into efficient execution trees.
2

Condition Caching

Cache condition evaluation results.
3

Action Caching

Cache action results for repeated conditions.
4

Invalidation

Invalidate cache when rules change.

Performance Monitoring

Rule Execution Time

Metric: Time taken to evaluate rules Target: < 10ms per request Optimization: Cache frequently used rules

Memory Usage

Metric: Memory consumed by rule engine Target: < 5MB additional usage Optimization: Efficient data structures

Cache Hit Rate

Metric: Percentage of cache hits Target: > 80% hit rate Optimization: Improve cache strategies

Testing and Debugging

Rule Testing

1

Unit Testing

Test individual rules in isolation.
2

Integration Testing

Test rule interactions and conflicts.
3

Performance Testing

Test rule execution performance.
4

User Acceptance Testing

Test rules with real user scenarios.

Debugging Tools

Rule Execution Log

Feature: Detailed log of rule execution Use: Debug rule logic and performance

Condition Evaluator

Feature: Test conditions with sample data Use: Verify condition logic

Performance Profiler

Feature: Profile rule execution performance Use: Identify performance bottlenecks

Rule Simulator

Feature: Simulate rule execution Use: Test rules before deployment

Best Practices

Rule Design

Keep Rules Simple

Design rules that are easy to understand and maintain.

Use Descriptive Names

Use clear, descriptive names for rules and conditions.

Document Rules

Document the purpose and logic of complex rules.

Test Thoroughly

Test rules extensively before deploying to production.

Performance Best Practices

Follow these tips to optimize rule performance:
  • Minimize condition complexity to reduce evaluation time
  • Use efficient data structures for condition matching
  • Cache frequently used rules to avoid repeated compilation
  • Monitor performance metrics and optimize as needed

Security Considerations

Always consider security implications when creating custom rules:
  • Validate all inputs to prevent injection attacks
  • Use secure condition evaluation to prevent code execution
  • Implement proper access controls for rule management
  • Audit rule changes to maintain security posture

Advanced Features

Rule Templates

Pre-built Rule Templates

E-commerce ProtectionNews Site RulesEducational ContentCorporate Policies

Rule Import/Export

1

Export Rules

Export rules to JSON format for backup or sharing.
2

Import Rules

Import rules from JSON files or other sources.
3

Rule Sharing

Share rule configurations with other sites.
4

Version Control

Track rule changes over time.

API Integration

// Example: Create rule via API
const rule = {
  name: "Custom Protection Rule",
  conditions: {
    path: "/premium/",
    user_agent: "CommercialAI"
  },
  actions: {
    ai_training_data: "disallow",
    ai_use: ["search_indexing"]
  }
};

fetch('/wp-json/llmtag/v1/rules', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify(rule)
});

Troubleshooting

Common Issues

Possible causes:
  • Rules disabled or misconfigured
  • Condition logic errors
  • Priority conflicts
Solutions:
  • Check rule status and configuration
  • Verify condition logic
  • Review rule priorities
Possible causes:
  • Too many complex rules
  • Inefficient condition evaluation
  • Cache configuration problems
Solutions:
  • Optimize rule complexity
  • Improve condition evaluation
  • Adjust cache settings
Possible causes:
  • Rule conflicts
  • Condition evaluation errors
  • Action application issues
Solutions:
  • Review rule conflicts
  • Debug condition logic
  • Check action configuration
I