Skip to content

Cognition flow

This is how I turn a FinanceEvent into a logged, reviewable finance decision.

Runtime path

1
Event
FinanceEventZod union: card authorization, payout, foreign exchange, receipt, bill, scheduled pulse.
2
Route
Skill triggersRegistry asks each skill if this event is relevant for the tenant.
3
Context
Context loadTenant chart of accounts, vendors, rules, balances, past decisions, receipts.
4
Cognition
Deterministic first, large language model behind schemasRules and math run first. The model is invoked only where typed classification is the cheapest right answer.
rule hitDeterministic shortcutKnown vendor, typed policy rule, accounts-payable due-date math, pulse ranking.
model pathStructured classifierAuto-tagging calls OpenRouter through the Vercel Artificial Intelligence Software Development Kit generateObject and validates with Zod.
refusalDo not guessMissing input, off-chart-of-accounts, unsafe model output, malformed pulse window.
5
Policy
Outcome policyautoApply, suggest, refuse, or escalate — each with confidence and reason code.
6
Gate
Autonomy gateTenant + skill rung can downgrade automation to review.
7
Log
Decision logPrompt/model/rules versions, evidence, idempotency hash, rationale.
8
Surface
Operator surfaceQueue, decision detail, /brief, bills, treasury, forecast.

Outcome policy

autoApplyHigh-confidence, low-riskAllowed only where the autonomy rung and skill policy permit it. Vendor-rule auto-tagging can qualify; accounts-payable money movement cannot.
suggestHuman ratifiesDefault path for medium-confidence coding, policy flags, accounts-payable plans, and Daily Chief Financial Officer Pulse recommendations.
refuseStructured noSchema failure, missing input, off-chart-of-accounts, policy conflict, or invalid pulse window. Refusal is visible and testable.
escalateNamed role neededUsed for overdue bills, dual-control-sensitive accounts-payable work, and cases requiring controller review.

Auto-tagging branch

The large-language-model-heavy path is intentionally narrow. I wanted the model to help with classification, not own the workflow:

  1. Check per-tenant vendor rule. A hit short-circuits with deterministic confidence.
  2. Retrieve tenant-specific chart-of-accounts candidates and vendor/merchant-category-code hints.
  3. Call generateObject through OpenRouter with a Zod schema.
  4. Reject anything off-chart-of-accounts or below confidence threshold.
  5. Stamp prompt/model/chart-of-accounts versions before the decision is logged.

Review and learning loop

AcceptMarks the decision executed. Real ledger/payment adapters remain behind mocked boundaries.
OverrideCaptures the corrected coding/verdict, operator reason, and evidence.
LearnCreates a superseding vendor rule, flags retrieval, and can append an eval golden case.
ReplayEval replay checks whether the current system would still reverse the decision.

This is the core product bet: the system should become more autonomous only after the audit trail proves it deserves that autonomy.

Submission pack — Reap Chief Financial Officer Agent take-home