Skip to main content

Overview

The Compliance Engine is a rule evaluation system that lets you define conditions, evaluate candidate and employee data against those conditions, and trigger actions based on the results. It’s the decision-making brain behind automated hiring, onboarding, and workforce compliance.

How Rules Work

A Rule is a condition tree that evaluates to true or false. Rules are composed of Rule Nodes — atomic conditions connected with AND/OR logic.

Rule Nodes

Each Rule Node contains:
FieldDescription
Field PathThe data field to evaluate (using Object Graph)
OperatorThe comparison operator
ValueThe expected value
LogicAND / OR connection to sibling nodes

Operators

OperatorDescriptionExample
equalsExact matchstatus == "ACTIVE"
not_equalsNot equalstatus != "REJECTED"
greater_thanNumeric comparisonage > 18
less_thanNumeric comparisonexperience < 5
containsString containsemail contains "@gmail"
not_containsString does not containname not_contains "test"
inValue in liststate in ["CA", "NY", "TX"]
not_inValue not in listcountry not_in ["restricted"]
is_emptyField is emptyphone is_empty
is_not_emptyField has valueresume is_not_empty
regexRegular expressionssn regex "^\d{3}-\d{2}-\d{4}$"

Object Graph Integration

Rules reference data using the Object Graph (OG) path system:
{{application.candidate.date_of_birth}}
{{form_submission.elements.work_authorization.value}}
{{contract.legal_entity.state}}
{{application.hiring_flow.name}}
This allows rules to evaluate any data point in the system without hardcoding field references.

Rule Instances

A Rule Instance is a rule configured for a specific context. The same rule definition can be reused across multiple contexts with different parameters. Contexts where rules are used:
  • Hiring Flow stages — Gate stage transitions
  • Automations — Conditional action execution
  • Form compliance — Validate form submissions
  • Document requirements — Verify document data

Rule Instance Values

Rule Instance Values provide context-specific parameters:
Rule: "Field >= Threshold"
Instance 1: field = "age", threshold = 18 (for US hiring)
Instance 2: field = "age", threshold = 16 (for UK hiring)

Rule Executions

Every rule evaluation is recorded as a Rule Execution:
FieldDescription
Rule InstanceWhich rule was evaluated
ResultPass or fail
Input DataThe data that was evaluated
TimestampWhen the evaluation occurred
TriggerWhat triggered the evaluation
This provides a complete audit trail of all compliance decisions.

AI-Powered Rules

Firstwork supports AI-powered rule evaluation where complex conditions can be assessed by LLM:
  • Natural language conditions (“Is this document a valid government-issued ID?”)
  • Document content analysis
  • Sentiment analysis on text responses
  • Complex multi-factor assessments
AI rules use LangChain and LiteLLM to integrate with multiple AI providers (OpenAI, Anthropic, Google).

Using Rules in Automations

Rules serve as the conditional logic in Automations: When an automation fires:
  1. The trigger event occurs
  2. The rule is evaluated against current data
  3. If the rule passes, the associated actions execute
  4. If the rule fails, alternative actions can execute (or nothing happens)

Best Practices

Create small, focused rules that check one thing. Combine them using AND/OR logic for complex conditions. This makes rules easier to debug and reuse.
Name rules descriptively: “US Work Authorization Check” is better than “Rule 1”. This helps when reviewing rule executions and debugging compliance issues.
Use the rule evaluation preview to test rules against sample data before applying them to active hiring flows.
Regularly review rule execution logs to identify:
  • Rules that always pass or fail (may need adjustment)
  • Unexpected evaluation results
  • Performance bottlenecks in complex rule trees