Architecture Note · Operations & RevOps
Deterministic Sales Compensation & ASC 606 Commission Engine
Why prompt-driven commission spreadsheets break payroll trust and revenue recognition—and the deterministic architecture that locks every payout behind reproducible math, SQLite audit traces, and dual sign-off.
The Problem: Multi-Region Comp Cycles Running on Fragile Spreadsheets
Quarter-end commission runs sit directly on the fault line between Revenue Operations and Corporate Finance. A single payout cycle spans Account Executives, SDRs, and Solutions Engineers across US, UK, EU, Canada, and APAC payroll currencies, each carrying distinct quota bands, co-sell split rules, multi-year spiffs, and 90- or 180-day churn clawbacks. When those calculations live in chained spreadsheet tabs, one broken lookup or stale FX rate cascades into rep disputes, delayed payroll batches, and restated ASC 606 / IFRS 15 deferred commission schedules.
Why Naive AI Wrappers Fail in Commission & Close Workflows
Dropping an LLM chat wrapper over CRM exports creates four operational failure modes that Finance controllers cannot sign off on:
- Nondeterministic payout math: Language models approximate marginal tax-style brackets poorly. A subtle rounding error between a
100%–125%cliff tier and a>125%super-accelerator—or misapplying a net payout floor after an early-churn clawback—produces numbers that shift between runs. - Silent policy drift without trace snapshots: When a plan rule changes mid-quarter, ad-hoc scripts overwrite prior calculations without preserving which
plan_rule_snapshotand FX rate produced a rep’s statement. - Uncontrolled compensation egress: Uploading raw rep quotas, closed-won deal tables, and payroll figures to public third-party model endpoints exposes sensitive compensation data outside the firm’s perimeter.
- Missing segregation of duties: Automated pipelines that export payroll CSVs directly from a calculation step bypass the boundary between RevOps quota verification and Finance general-ledger sign-off.
The Deterministic Architecture That Fixes It
Our shipped architecture separates deterministic financial computation from optional natural-language explanation, backed by SQLite in WAL mode and strict token-scoped authorization:
- Deterministic marginal tier, split, FX, and clawback engine:
POST /api/comp/calculateandPOST /api/comp/upload-batchexecute pure Python math incomp_engine.py. Deals convert to USD using explicit per-batch FX maps acrossUSD,GBP,EUR,CAD,AUD,SGD, and zero-decimalJPY, credit AE/SDR/SE splits, allocate marginal volume across base (0%–100%), cliff (100%–125%), and super-accelerator (>125%) bands, apply 24- or 36-month term spiffs, and compute full or pro-rata early-churn clawbacks bounded bynet_payout_floor_usdwith unrecovered carryforwards persisted incalc_trace_json. - Side-by-side dispute traces with offline-first explanations:
POST /api/comp/disputesstores the exact payout variance alongside immutable JSON snapshots of the deal lineage and plan rules, then resolves adjustments viaPOST /api/comp/disputes/{dispute_id}/resolve. AnLLMAdapterdefaults to deterministic offline mode (emitting structured math narratives with zero external calls) or routes to a customer-hosted OpenAI-compatible endpoint. - ASC 606 / IFRS 15 schedule separation:
GET /api/asc606/amortizationpartitions capitalizable incremental acquisition commissions from immediately expensed draws and non-incremental bonuses, deducts early-churn clawbacks and impairment write-offs under ASC 606-10-35, and generates monthly deferred-asset rollforwards across 14 edge-case pytest checks covering accelerators, zero-quota fallbacks, and clawbacks. - Scoped token auth, upload wiping, and append-only audit triggers: Every route enforces SHA-256 hashed invite tokens with SQLite sliding-window rate limiting. Staged CSV uploads are overwritten with zeros,
fsynced, and unlinked immediately in afinallyblock (backed by a 60-second sweep enforcing a 1-hour TTL), while SQLiteBEFORE UPDATEandBEFORE DELETEtriggers enforce an append-onlyaudit_logstable. - Mandatory dual human sign-off gate:
POST /api/payouts/{period}/approverequiresconfirm_human_review=truefrom both apayouts:financetoken and a distinctpayouts:sales_opstoken (returning HTTP 409 if the same actor or token attempts both approvals) beforeGET /api/payouts/{period}/export.csvreleases the RFC-4180 payroll file.
Operational Takeaway
Commission automation earns Finance and sales-floor trust when every dollar traces back to deterministic tier math, raw uploads vanish after parsing, ASC 606 adjustments stay linked to clawback events, and no payroll CSV leaves the system without verified dual human approval.