EngineeringFeb 15, 202610 min read

Why We Built an Event-Sourced Payroll Engine

Immutable ledger, hash-chain verification, and compensating events — the architecture behind PeopleOS's ledger-grade payroll accuracy.

The Problem with Mutable Payroll Data

Most payroll systems store the current state of a payroll run. When a correction is needed — a missed deduction, a salary revision backdated to last month — the system overwrites the original record. This creates several problems:

  • No audit trail of what was originally calculated
  • Impossible to explain discrepancies to auditors
  • Reconciliation requires manual comparison of before/after states
  • Compliance risk if statutory filings were based on the original (now overwritten) data

Event Sourcing: Every Change Is an Event

In PeopleOS, every payroll action is an immutable event appended to an event log. The current state is derived by replaying events — never by updating a row in place.

Key event types include:

  • PAYROLL_INITIATED — Payroll run started for a given month
  • SALARY_CALCULATED — Individual employee salary computed
  • DEDUCTION_APPLIED — Statutory deduction (PF, ESI, PT, TDS) applied
  • PAYROLL_APPROVED — Run approved by authorised user
  • CORRECTION_APPLIED — Compensating event for a post-approval correction

Hash-Chain Tamper Evidence

Each event in the log includes a SHA-256 hash of the previous event. This creates a chain where tampering with any single entry would break the hash chain — making it immediately detectable.

During audits, PeopleOS can verify the entire chain and produce a certificate of integrity for any payroll period.

Compensating Events (Not Deletions)

Need to correct a payroll run? PeopleOS doesn't delete or overwrite. Instead, it creates a compensating event — a new entry that reverses the original and applies the corrected values. Both the original and the correction remain in the immutable log, creating a complete audit trail.