Skip to Content
EngineeringStatement flow

Statement flow

What happens between “user picks a file” and “report on screen”. The two invariants: money math never touches the LLM, and every failure path has a designed exit.

Each pipeline stage commits as it completes, so the console’s stage strip shows live progress (the running stage pulses). The Statements list does the same at the feed level: it refetches on every visit and polls while any job is queued/processing, so a user can upload several files back-to-back and watch each settle from “working” to its band — no waiting for one to finish first. Per-call token usage lands in llm_usage with page ranges; scripts/token_usage.py turns it into ₹-per-page economics priced at the DB-stored FX rate.

Retain-mode orgs keep originals in the vault: GET /v1/statements/{id}/source streams the file back (audited), DELETE …/source soft-deletes it, and the hourly sweep hard-purges after the compliance hold (SP_VAULT_PURGE_HOLD_DAYS, default 30).

A Borrower Case is a layer on top of this: it groups several finished statements and consolidates them into one reconciled per-borrower picture (multi-account, inter-account transfer dedup, and duplicate-upload dedup — same account + period + closing balance is one statement), running asynchronously on the same worker. See product/borrower-case.md.

The decision layer sits above the report, on demand — it is not a worker stage. Once a report (or case) exists, POST /v1/statements/{id}/decision runs the deterministic engine: Layer 3 eligibility (supportable EMI, max/recommended loan, cost of credit) and Layer 4 decision (approve / approve-with-conditions / counter-offer / refer / decline) against the tenant’s per-product policy. The engine recommends; a human decides. With queue=true (or a refer/decline), it enqueues to the approvals queue (/v1/queue), where an underwriter with sufficient delegated authority (L1/L2/L3) claims and resolves it — reason-coded, append-only, with KYC/fraud/tamper hard-blocks that can’t be overridden. See product/override-workflow.md and domain/decision.md.