Kredal Docs
Adr

ADR 0012 — Deterministic-first agents (bank-match, recovery, compliance)

Agents 8–10 ship as pure deterministic functions over the scoring input, not LLM calls.

  • Status: Accepted
  • Date: 2026-07-19

Context

The roadmap's three remaining agents — rejection-recovery advisor, bank-matcher, and compliance monitor — could each be built as LLM prompts. But Kredal's core promise (ADR 0009) is that AI extracts and drafts while deterministic rules decide: every user-facing judgment must be explainable and reproducible, because banks and regulators will ask.

Decision

Ship all three as pure functions over the existing ScoringInput contract, reusing the single-source-of-truth bank tables:

  • Bank-matcher (src/lib/scoring/bank-match.ts): ranks the seven supported banks from the same signals the bank_fit rules use — BANK_ADDITIONAL_REQUIRED document gaps, HIGH_MIN_BALANCE_BANKS vs stated turnover, company age, source-of-funds posture. Rendered on the assessment page.
  • Recovery advisor (src/lib/reports/recovery-advisor.ts): keyword- categorises the bank's stated rejection reason into a known cause, emits the cause-specific playbook plus today's high-severity flags, and feeds the "Targeted recovery plan" section of the rejection recovery pack.
  • Compliance monitor (src/lib/compliance.ts): time-based exposure — document expiries (manual column and AI-extracted dates), the 30 Sept 2026 corporate-tax deadline, VAT threshold posture, WPS, and target-bank document gaps. Rendered as the "Compliance radar" card on the company page.

Each is unit-tested alongside the scoring engine's tests. LLM involvement stays where it already is: extraction and narrative drafting.

Consequences

  • Positive: agents 8–10 inherit the audit story ("explain this number" always has an answer); zero added inference cost or latency; testable in CI; no new failure modes when the AI provider is rate-limited.
  • Negative: the recovery categoriser's keyword matching is cruder than an LLM classifier — acceptable because the fallback (unknown) still produces a useful plan, and the mapping can be upgraded to AI-assisted suggestion with deterministic confirmation later without changing the contract.

On this page