No-Code Commission Rules
Last Updated: December 2025Schema Version: v0
Status: Phase 3.x Schema Definition (Validation Only)
Overview
No-code commission rules allow users to define commission calculation logic without writing code. Rules are stored as JSON and validated against a strict schema that enforces decimal safety (ADR-002). Current State (Phase 3.x):- ✅ JSON schema definition (
docs/no_code_rules.schema.json) - ✅ Schema validation utility (
api/utils/rules_schema_validate.py) - 🔲 Rule evaluator/engine (Phase 4)
Schema Structure
Required Fields
schema_version: Schema version identifier (e.g.,"v0")rule_id: Unique rule identifier (UUID)rule_name: Human-readable rule nameconditions: Array of condition objects (at least one required)actions: Array of action objects (at least one required)
Optional Fields
rule_description: Optional rule descriptionpriority: Rule priority (0-1000, default: 0, higher = evaluated first)is_active: Whether rule is active (default: true)
Conditions
Conditions define when a rule applies. All conditions must evaluate totrue for the rule to execute.
Supported Operators
eq: Equalsne: Not equalsgt: Greater thangte: Greater than or equallt: Less thanlte: Less than or equalin: Value is in arraynot_in: Value is not in arraycontains: String contains substringstarts_with: String starts with prefixends_with: String ends with suffix
Condition Examples
Actions
Actions define what happens when conditions are met.Action Types
1. set_rate
Set a fixed commission rate.
target_field: Field to set (e.g.,"commission_rate","pepm_rate")rate: Rate as decimal string (e.g.,"0.15"for 15%)
rate MUST be a string, not a number. Example: "0.15" ✅, 0.15 ❌
2. apply_formula
Apply a formula expression.
target_field: Field to setformula: Formula expression with field references using{{field_name}}syntax
+, -, *, /, parentheses ()
Field References: Use {{field_name}} to reference other fields (e.g., {{pepm_rate}}, {{employee_count}})
Examples:
"{{pepm_rate}} * 12 / {{pay_periods}}"- TPA per-pay calculation"({{base_rate}} + {{bonus_rate}}) * {{employee_count}}"- Tiered calculation"{{commission_rate}} * {{gross_amount}}"- Simple percentage
3. set_split
Set a split percentage.
target_field: Field to set (typically"split_percentage")split_percentage: Split percentage as decimal string
split_percentage MUST be a string, not a number. Example: "33.333333" ✅, 33.333333 ❌
4. apply_tier
Apply tiered rates based on a value range.
target_field: Field to settiers: Array of tier definitions
min: Minimum value (inclusive)max: Maximum value (inclusive,nullfor unbounded)rate: Rate as decimal string for this tier
rate MUST be a string, not a number. Example: "0.15" ✅, 0.15 ❌
5. set_fixed_amount
Set a fixed commission amount.
target_field: Field to setfixed_amount: Fixed amount as decimal string
fixed_amount MUST be a string, not a number. Example: "1000.00" ✅, 1000.00 ❌
Complete Rule Examples
Example 1: TPA Commission Rule
Example 2: Tiered Commission Rate
Example 3: Split Commission Rule
Decimal Safety (Critical)
ADR-002: All decimal values (money, rates, percentages) MUST be strings, not numbers.✅ Correct
❌ Incorrect
Validation
Rules are validated againstdocs/no_code_rules.schema.json using the validation utility:
Phase 4 Roadmap
- Rule Evaluator: Backend engine to evaluate rules against transaction context
- Rule UI: No-code rule builder interface in dashboard
- Rule Versioning: Support for rule version history and rollback
- Rule Testing: Test rules against sample data before activation
- Rule Monitoring: Track rule execution and performance
See Also:
docs/no_code_rules.schema.json- JSON schema definitionapi/utils/rules_schema_validate.py- Validation utility- ADR-001 and ADR-002 in
Architect_Context.md- Decimal safety policy