Deep dive into lim’s 3-step judgment engine: Rule Match, History Match, AI Inference, and Escalate.
Judgment Engine
The judgment engine is the core of lim’s automation. It takes a business event (a bank transaction, a natural language description, an invoice) and decides how to classify it into a journal entry.
The 4-Step Pipeline
Every transaction passes through four steps, in order. The engine stops at the first step that produces a confident result.
Input: { counterparty: "AWS", amount: 11000, direction: "outflow" } │ ▼┌──────────────────────────────┐│ Step 1: RULE MATCH │ ← Zero cost. Instant.│ Check learned rules. ││ Confidence threshold: 0.85 │└──────────┬───────────────────┘ │ No match ▼┌──────────────────────────────┐│ Step 2: HISTORY MATCH │ ← Zero cost. SQL lookup.│ Find similar past entries. ││ Confidence threshold: 0.70 │└──────────┬───────────────────┘ │ No match ▼┌──────────────────────────────┐│ Step 3: AI INFERENCE │ ← LLM API call. Last resort.│ Ask Claude/LLM to classify. ││ Confidence threshold: 0.60 │└──────────┬───────────────────┘ │ Low confidence ▼┌──────────────────────────────┐│ Step 4: ESCALATE │ ← Human review required.│ Flag for manual review. ││ Confidence: 0 │└──────────────────────────────┘
Step 1: Rule Match
The fastest and cheapest step. Rules are deterministic pattern-matching conditions stored in the matching_rule table.
How Rules Work
Each rule has:
Conditions — Pattern to match (counterparty name, direction, amount range)
Template — The journal entry to produce (accounts, tax code, amounts)
Confidence — How reliable this rule is (0.00 to 0.99)
Auto-post threshold — Confidence level at which entries are posted without human confirmation (default: 0.95)
When a bank transaction with counterparty “Amazon Web Services” arrives, this rule matches on counterparty_contains: "aws" and produces:
Debit Communication (5101) ¥10,000 (90.9% of ¥11,000)Debit Input VAT (1501) ¥1,000 (9.1% of ¥11,000)Credit Accounts payable (2101) ¥11,000
Rule Matching Priority
When multiple rules match, they’re evaluated by priority (lower number = higher priority):
Priority
Source
Example
1-10
Manual rules (user-created)
“All Stripe payments go to Payment Processing Fees”
50
Learned rules (auto-created from confirmations)
“AWS = Communication”
100
Default rules (system)
“Unknown outflow = Miscellaneous expense”
Step 2: History Match
When no rule matches, lim searches past journal entries for similar transactions.The history matcher looks for entries with:
Similar counterparty name (fuzzy string matching)
Same direction (inflow/outflow)
Similar amount range
If a match is found with sufficient similarity, it suggests the same account classification.
Input: { counterparty: "Amazon Web Svcs", amount: 13200 }History search: Found: "Amazon Web Services" → Communication (5101) — used 3 times Similarity: 0.92 Confidence: 0.78Suggestion: Communication (5101) + Input VAT (1501)
History matches always require human confirmation. They never auto-post, even if confidence is
high. This is because the match is probabilistic, not deterministic.
Step 3: AI Inference
When rules and history can’t resolve the transaction, lim calls an LLM to classify it.The AI receives:
The transaction details (counterparty, amount, description, date)
The company’s chart of accounts (codes and names)
Recent journal entry examples for context
The AI returns:
Suggested account classification
Confidence score
Reasoning
Input: { counterparty: "WeWork", amount: 55000, description: "coworking space March" }AI Response: Account: Rent expense (7101) + Input VAT (1501) Confidence: 0.82 Reasoning: "Coworking space is an office rent expense. Standard 10% consumption tax applies."
AI inference results always require human confirmation. This is by design — the confirmation is what powers the learning loop.
AI Provider / Model Configuration
# Provider (current implementation: anthropic)export LIM_AI_PROVIDER=anthropic# Shared model for all AI tasksexport LIM_AI_MODEL=claude-haiku-4-5-20251001# Or task-specific overridesexport LIM_AI_MODEL_JUDGMENT=claude-haiku-4-5-20251001export LIM_AI_MODEL_NL_JOURNAL=claude-haiku-4-5-20251001export LIM_AI_MODEL_VISION=claude-haiku-4-5-20251001
The current engine switches AI runtime behavior via LIM_AI_PROVIDER and LIM_AI_MODEL*
environment variables. The LIM_ prefix avoids collisions with generic AI_MODEL settings
used by other tools or services in the same environment. vertex and local are prepared as
injection points, but only the Anthropic adapter is implemented in this slice.
Step 4: Escalate
When all three steps fail to produce a confident classification, the transaction is escalated to a human.This happens when:
No rule matches
No similar history exists
AI confidence is below 0.60
The transaction is genuinely ambiguous
Escalated transactions appear as draft journal entries that need manual classification.
Confidence Scores
Confidence scores range from 0.00 to 0.99 and drive automation decisions.
How Confidence Changes
Action
Effect
Example
Confirmed
+0.03 per confirmation (cap 0.99)
Rule at 0.85 → 0.88 after confirmation
Edited
No change to confidence (template is updated)
Rule template corrected but confidence stays
Rejected
-0.10 per rejection
Rule at 0.85 → 0.75 after rejection
Deactivated
Rule disabled when confidence drops below 0.50
Consistently wrong rule is turned off
Confidence Thresholds
Threshold
Behavior
>= 0.95
Auto-post. Entry is created without human confirmation.
0.85 - 0.94
Suggest. Entry is created as draft, shown to user for confirmation.
0.60 - 0.84
Low confidence. Entry is created as draft with a warning.
< 0.60
Escalate. Marked for human review.
The Learning Flywheel
The judgment engine improves through a feedback loop:
┌─────────────────────────────────────────────────────────┐│ ││ Transaction arrives ││ │ ││ ▼ ││ Judgment engine classifies it ││ │ ││ ├─ Rule match (auto-post if confidence >= 0.95) ││ │ ││ ├─ History/AI match (suggest to human) ││ │ │ ││ │ ▼ ││ │ Human confirms or edits ││ │ │ ││ │ ▼ ││ │ learnFromConfirmedEntry() ││ │ │ ││ │ ├─ Existing rule? → Reinforce (+0.03) ││ │ │ ││ │ └─ No rule? → Create new rule │──┐│ │ confidence: 0.85 │ ││ │ source: "learned" │ ││ │ │ ││ └─ Escalated (human classifies from scratch) │ ││ │ │ ││ ▼ │ ││ New rule created ────────────────────────────────┘ ││ ││ Next similar transaction → Rule match (no AI cost) ◄────────┘│ │└──────────────────────────────────────────────────────────┘
Learning in Practice
When learnFromConfirmedEntry() is called:
Existing rule found (same counterparty pattern) — the rule’s confidence is increased by 0.03 and the template is updated to match the confirmed entry.
source: "learned" (distinguishes from manually created rules)
priority: 50 (lower priority than manual rules)
Counterparty pattern derived from the confirmed entry
After 4 more confirmations (0.85 + 0.03 x 4 = 0.97), the rule crosses the auto-post threshold and future matching transactions are posted without human input.
Cost Trajectory
For a typical company processing 300 transactions/month:
Month
Rule Match
History
AI
Escalated
AI Cost
1
20%
10%
50%
20%
~$15
2
55%
15%
20%
10%
~$6
3
75%
10%
10%
5%
~$3
6
90%
5%
3%
2%
~$1
12
95%
3%
1%
1%
~$0.30
The key insight: AI costs are front-loaded. The system learns quickly and AI inference becomes
rare. By month 6, most companies see less than $1/month in AI costs for transaction
classification.
Rule Management
Viewing Rules
lim stats# Shows rule count, match rates, and confidence distribution
Manual Rule Creation
For transactions you know in advance, create rules manually for instant classification:
Manual rules have higher priority (lower number) than learned rules, so they take precedence.
Architecture
The judgment engine lives in the @repo/engine package:
packages/engine/src/judgment/├── engine.ts # Main 4-step pipeline├── rule-matcher.ts # Step 1: Pattern matching against rules├── history-matcher.ts # Step 2: Similar transaction lookup├── ai-inferrer.ts # Step 3: LLM classification├── confidence.ts # Confidence score management├── learner.ts # Learning from confirmed entries└── nl-engine.ts # Natural language input processing
Each step is independently testable and the pipeline is extensible — new steps can be inserted without changing the overall flow.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"lim","colors":{"primary":"#18181B","light":"#F4F4F5","dark":"#18181B"},"logo":{"light":"https://mintcdn.com/ship-81dac153/mOROYUi8HgK4gxX2/images/logo-light.svg?fit=max\u0026auto=format\u0026n=mOROYUi8HgK4gxX2\u0026q=85\u0026s=5cbee52fbb53f79b9c10eddcf5863726","dark":"https://mintcdn.com/ship-81dac153/mOROYUi8HgK4gxX2/images/logo-dark.svg?fit=max\u0026auto=format\u0026n=mOROYUi8HgK4gxX2\u0026q=85\u0026s=46d582a37762e2c7bff74aca9107a0e3"},"favicon":"/images/favicon.svg","navbar":{"primary":{"type":"button","label":"Get Started","href":"https://app.uselim.com"}},"footer":{},"seo":{"metatags":{"canonical":"https://docs.uselim.com"}},"styling":{"latex":false},"navigation":{"languages":[{"language":"en","default":true,"href":"introduction"},{"language":"ja","href":"ja/introduction"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"ship-81dac153","hasAudioNarration":false,"actualSubdomain":"ship-81dac153","customDomains":["docs.uselim.com"],"gitSource":{"type":"github","owner":"ship-hq","repo":"lim","deployBranch":"main","contentDirectory":"apps/docs","isPrivate":true,"mountPath":"","label":""},"entitlements":{},"buildId":"6ae940148e17361c5bf925f3:success","clientVersion":"0.0.4227","searchFilterCounts":[{"language":"en","tag":"Guides","count":34},{"language":"ja","tag":"ガイド","count":34},{"language":"en","tag":"CLI","count":17},{"language":"ja","tag":"CLI","count":17},{"language":"en","tag":"CLI Basics","count":9},{"language":"ja","tag":"CLI 基本","count":9},{"language":"en","tag":"AI Agents","count":8},{"language":"en","tag":"Money In \u0026 Money Out","count":4},{"language":"en","tag":"Operations \u0026 Compliance","count":4},{"language":"en","tag":"Concepts","count":4},{"language":"ja","tag":"AI Agent","count":4},{"language":"ja","tag":"AI Agent連携","count":4},{"language":"ja","tag":"入出金と書類","count":4},{"language":"ja","tag":"運用と内部統制","count":4},{"language":"ja","tag":"コンセプト","count":4},{"language":"en","tag":"Getting Started","count":2},{"language":"ja","tag":"はじめに","count":2},{"language":"en","tag":"API","count":1},{"language":"en","tag":"API Reference","count":1},{"language":"ja","tag":"API","count":1}]},"assistantConfig":{"enableStarterQuestions":false},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"agents/judgment-engine","slug":"/agents/judgment-engine","pageMetadata":{"title":"Judgment Engine","sidebarTitle":"Judgment Engine","description":"Deep dive into lim's 3-step judgment engine: Rule Match, History Match, AI Inference, and Escalate.","href":"/agents/judgment-engine"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Deep dive into lim’s 3-step judgment engine: Rule Match, History Match, AI Inference, and Escalate.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`1`,id:`judgment-engine`,children:`Judgment Engine`}),`\n`,_jsx(_components.p,{children:`The judgment engine is the core of lim’s automation. It takes a business event (a bank transaction, a natural language description, an invoice) and decides how to classify it into a journal entry.`}),`\n`,_jsx(Heading,{level:`2`,id:`the-4-step-pipeline`,children:`The 4-Step Pipeline`}),`\n`,_jsx(_components.p,{children:`Every transaction passes through four steps, in order. The engine stops at the first step that produces a confident result.`}),`\n`,_jsx(CodeBlock,{numberOfLines:`30`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`30`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Input: { counterparty: \"AWS\", amount: 11000, direction: \"outflow\" }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` ▼`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`┌──────────────────────────────┐`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Step 1: RULE MATCH │ ← Zero cost. Instant.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Check learned rules. │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Confidence threshold: 0.85 │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└──────────┬───────────────────┘`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` │ No match`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` ▼`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`┌──────────────────────────────┐`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Step 2: HISTORY MATCH │ ← Zero cost. SQL lookup.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Find similar past entries. │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Confidence threshold: 0.70 │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└──────────┬───────────────────┘`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` │ No match`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` ▼`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`┌──────────────────────────────┐`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Step 3: AI INFERENCE │ ← LLM API call. Last resort.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Ask Claude/LLM to classify. │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Confidence threshold: 0.60 │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└──────────┬───────────────────┘`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` │ Low confidence`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` ▼`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`┌──────────────────────────────┐`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Step 4: ESCALATE │ ← Human review required.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Flag for manual review. │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Confidence: 0 │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└──────────────────────────────┘`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`2`,id:`step-1-rule-match`,children:`Step 1: Rule Match`}),`\n`,_jsxs(_components.p,{children:[`The fastest and cheapest step. Rules are deterministic pattern-matching conditions stored in the `,_jsx(_components.code,{children:`matching_rule`}),` table.`]}),`\n`,_jsx(Heading,{level:`3`,id:`how-rules-work`,children:`How Rules Work`}),`\n`,_jsx(_components.p,{children:`Each rule has:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Conditions`}),` — Pattern to match (counterparty name, direction, amount range)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Template`}),` — The journal entry to produce (accounts, tax code, amounts)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Confidence`}),` — How reliable this rule is (0.00 to 0.99)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Auto-post threshold`}),` — Confidence level at which entries are posted without human confirmation (default: 0.95)`]}),`\n`]}),`\n`,_jsx(_components.p,{children:`Example rule:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`16`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`16`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Auto: AWS\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"conditions\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"counterparty_contains\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"aws\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"direction\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"outflow\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"template\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"lines\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"side\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"debit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"accountCode\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"5101\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"ratio\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.909`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"side\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"debit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"accountCode\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"1501\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"ratio\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.091`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"side\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"credit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"accountCode\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"2101\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"ratio\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1.0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"confidence\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.91`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"autoPostThreshold\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.95`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`When a bank transaction with counterparty “Amazon Web Services” arrives, this rule matches on `,_jsx(_components.code,{children:`counterparty_contains: \"aws\"`}),` and produces:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Debit Communication (5101) ¥10,000 (90.9% of ¥11,000)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Debit Input VAT (1501) ¥1,000 (9.1% of ¥11,000)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Credit Accounts payable (2101) ¥11,000`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`3`,id:`rule-matching-priority`,children:`Rule Matching Priority`}),`\n`,_jsx(_components.p,{children:`When multiple rules match, they’re evaluated by priority (lower number = higher priority):`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Priority`}),_jsx(_components.th,{children:`Source`}),_jsx(_components.th,{children:`Example`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`1-10`}),_jsx(_components.td,{children:`Manual rules (user-created)`}),_jsx(_components.td,{children:`“All Stripe payments go to Payment Processing Fees”`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`50`}),_jsx(_components.td,{children:`Learned rules (auto-created from confirmations)`}),_jsx(_components.td,{children:`“AWS = Communication”`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`100`}),_jsx(_components.td,{children:`Default rules (system)`}),_jsx(_components.td,{children:`“Unknown outflow = Miscellaneous expense”`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`step-2-history-match`,children:`Step 2: History Match`}),`\n`,_jsx(_components.p,{children:`When no rule matches, lim searches past journal entries for similar transactions.`}),`\n`,_jsx(_components.p,{children:`The history matcher looks for entries with:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Similar counterparty name (fuzzy string matching)`}),`\n`,_jsx(_components.li,{children:`Same direction (inflow/outflow)`}),`\n`,_jsx(_components.li,{children:`Similar amount range`}),`\n`]}),`\n`,_jsx(_components.p,{children:`If a match is found with sufficient similarity, it suggests the same account classification.`}),`\n`,_jsx(CodeBlock,{numberOfLines:`9`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`9`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Input: { counterparty: \"Amazon Web Svcs\", amount: 13200 }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`History search:`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` Found: \"Amazon Web Services\" → Communication (5101) — used 3 times`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` Similarity: 0.92`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` Confidence: 0.78`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Suggestion: Communication (5101) + Input VAT (1501)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`History matches always require human confirmation. They never auto-post, even if confidence is\nhigh. This is because the match is probabilistic, not deterministic.`})}),`\n`,_jsx(Heading,{level:`2`,id:`step-3-ai-inference`,children:`Step 3: AI Inference`}),`\n`,_jsx(_components.p,{children:`When rules and history can’t resolve the transaction, lim calls an LLM to classify it.`}),`\n`,_jsx(_components.p,{children:`The AI receives:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`The transaction details (counterparty, amount, description, date)`}),`\n`,_jsx(_components.li,{children:`The company’s chart of accounts (codes and names)`}),`\n`,_jsx(_components.li,{children:`Recent journal entry examples for context`}),`\n`]}),`\n`,_jsx(_components.p,{children:`The AI returns:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Suggested account classification`}),`\n`,_jsx(_components.li,{children:`Confidence score`}),`\n`,_jsx(_components.li,{children:`Reasoning`}),`\n`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`7`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Input: { counterparty: \"WeWork\", amount: 55000, description: \"coworking space March\" }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`AI Response:`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` Account: Rent expense (7101) + Input VAT (1501)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` Confidence: 0.82`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` Reasoning: \"Coworking space is an office rent expense. Standard 10% consumption tax applies.\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`AI inference results always require human confirmation. This is by design — the confirmation is what powers the learning loop.`}),`\n`,_jsx(Heading,{level:`3`,id:`ai-provider-/-model-configuration`,children:`AI Provider / Model Configuration`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`10`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Provider (current implementation: anthropic)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LIM_AI_PROVIDER`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`anthropic`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Shared model for all AI tasks`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LIM_AI_MODEL`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`claude-haiku-4-5-20251001`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Or task-specific overrides`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LIM_AI_MODEL_JUDGMENT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`claude-haiku-4-5-20251001`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LIM_AI_MODEL_NL_JOURNAL`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`claude-haiku-4-5-20251001`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LIM_AI_MODEL_VISION`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`claude-haiku-4-5-20251001`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The current engine switches AI runtime behavior via `,_jsx(_components.code,{children:`LIM_AI_PROVIDER`}),` and `,_jsx(_components.code,{children:`LIM_AI_MODEL*`}),`\nenvironment variables. The `,_jsx(_components.code,{children:`LIM_`}),` prefix avoids collisions with generic `,_jsx(_components.code,{children:`AI_MODEL`}),` settings\nused by other tools or services in the same environment. `,_jsx(_components.code,{children:`vertex`}),` and `,_jsx(_components.code,{children:`local`}),` are prepared as\ninjection points, but only the Anthropic adapter is implemented in this slice.`]}),`\n`,_jsx(Heading,{level:`2`,id:`step-4-escalate`,children:`Step 4: Escalate`}),`\n`,_jsx(_components.p,{children:`When all three steps fail to produce a confident classification, the transaction is escalated to a human.`}),`\n`,_jsx(_components.p,{children:`This happens when:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`No rule matches`}),`\n`,_jsx(_components.li,{children:`No similar history exists`}),`\n`,_jsx(_components.li,{children:`AI confidence is below 0.60`}),`\n`,_jsx(_components.li,{children:`The transaction is genuinely ambiguous`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Escalated transactions appear as draft journal entries that need manual classification.`}),`\n`,_jsx(Heading,{level:`2`,id:`confidence-scores`,children:`Confidence Scores`}),`\n`,_jsx(_components.p,{children:`Confidence scores range from 0.00 to 0.99 and drive automation decisions.`}),`\n`,_jsx(Heading,{level:`3`,id:`how-confidence-changes`,children:`How Confidence Changes`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Action`}),_jsx(_components.th,{children:`Effect`}),_jsx(_components.th,{children:`Example`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Confirmed`})}),_jsx(_components.td,{children:`+0.03 per confirmation (cap 0.99)`}),_jsx(_components.td,{children:`Rule at 0.85 → 0.88 after confirmation`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Edited`})}),_jsx(_components.td,{children:`No change to confidence (template is updated)`}),_jsx(_components.td,{children:`Rule template corrected but confidence stays`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Rejected`})}),_jsx(_components.td,{children:`-0.10 per rejection`}),_jsx(_components.td,{children:`Rule at 0.85 → 0.75 after rejection`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Deactivated`})}),_jsx(_components.td,{children:`Rule disabled when confidence drops below 0.50`}),_jsx(_components.td,{children:`Consistently wrong rule is turned off`})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`confidence-thresholds`,children:`Confidence Thresholds`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Threshold`}),_jsx(_components.th,{children:`Behavior`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`>= 0.95`}),_jsxs(_components.td,{children:[_jsx(_components.strong,{children:`Auto-post.`}),` Entry is created without human confirmation.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`0.85 - 0.94`}),_jsxs(_components.td,{children:[_jsx(_components.strong,{children:`Suggest.`}),` Entry is created as draft, shown to user for confirmation.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`0.60 - 0.84`}),_jsxs(_components.td,{children:[_jsx(_components.strong,{children:`Low confidence.`}),` Entry is created as draft with a warning.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`\u003c 0.60`}),_jsxs(_components.td,{children:[_jsx(_components.strong,{children:`Escalate.`}),` Marked for human review.`]})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`the-learning-flywheel`,children:`The Learning Flywheel`}),`\n`,_jsx(_components.p,{children:`The judgment engine improves through a feedback loop:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`32`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`32`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`┌─────────────────────────────────────────────────────────┐`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Transaction arrives │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ ▼ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Judgment engine classifies it │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ ├─ Rule match (auto-post if confidence >= 0.95) │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ ├─ History/AI match (suggest to human) │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ ▼ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ Human confirms or edits │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ ▼ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ learnFromConfirmedEntry() │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ ├─ Existing rule? → Reinforce (+0.03) │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ └─ No rule? → Create new rule │──┐`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ confidence: 0.85 │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ source: \"learned\" │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ └─ Escalated (human classifies from scratch) │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ ▼ │ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ New rule created ────────────────────────────────┘ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ Next similar transaction → Rule match (no AI cost) ◄────────┘`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ │`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└──────────────────────────────────────────────────────────┘`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`3`,id:`learning-in-practice`,children:`Learning in Practice`}),`\n`,_jsxs(_components.p,{children:[`When `,_jsx(_components.code,{children:`learnFromConfirmedEntry()`}),` is called:`]}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Existing rule found`}),` (same counterparty pattern) — the rule’s confidence is increased by 0.03 and the template is updated to match the confirmed entry.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`No existing rule`}),` — a new rule is created with:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`confidence: 0.85`}),` (starts below auto-post threshold)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`source: \"learned\"`}),` (distinguishes from manually created rules)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`priority: 50`}),` (lower priority than manual rules)`]}),`\n`,_jsx(_components.li,{children:`Counterparty pattern derived from the confirmed entry`}),`\n`]}),`\n`]}),`\n`]}),`\n`,_jsx(_components.p,{children:`After 4 more confirmations (0.85 + 0.03 x 4 = 0.97), the rule crosses the auto-post threshold and future matching transactions are posted without human input.`}),`\n`,_jsx(Heading,{level:`3`,id:`cost-trajectory`,children:`Cost Trajectory`}),`\n`,_jsx(_components.p,{children:`For a typical company processing 300 transactions/month:`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Month`}),_jsx(_components.th,{children:`Rule Match`}),_jsx(_components.th,{children:`History`}),_jsx(_components.th,{children:`AI`}),_jsx(_components.th,{children:`Escalated`}),_jsx(_components.th,{children:`AI Cost`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`1`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`20%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`10%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`50%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`20%`}),_jsx(_components.td,{children:`~$15`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`2`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`55%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`15%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`20%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`10%`}),_jsx(_components.td,{children:`~$6`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`3`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`75%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`10%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`10%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`5%`}),_jsx(_components.td,{children:`~$3`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`6`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`90%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`5%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`3%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`2%`}),_jsx(_components.td,{children:`~$1`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`12`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`95%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`3%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`1%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`1%`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`~$0.30`})]})]})]}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`The key insight: AI costs are front-loaded. The system learns quickly and AI inference becomes\nrare. By month 6, most companies see less than $1/month in AI costs for transaction\nclassification.`})}),`\n`,_jsx(Heading,{level:`2`,id:`rule-management`,children:`Rule Management`}),`\n`,_jsx(Heading,{level:`3`,id:`viewing-rules`,children:`Viewing Rules`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`lim`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` stats`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Shows rule count, match rates, and confidence distribution`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`manual-rule-creation`,children:`Manual Rule Creation`}),`\n`,_jsx(_components.p,{children:`For transactions you know in advance, create rules manually for instant classification:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`17`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Via the REST API`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` /v1/companies/:id/matching-rules`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Stripe processing fee\",`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` \"conditions\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` \"counterparty_contains\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"stripe\",`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` \"direction\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"outflow\",`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` \"amount_max\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 50000`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` \"template\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` \"lines\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`\"side\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"debit\",`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"accountCode\":`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"5401\",`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"ratio\":`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1.0`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`\"side\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"credit\",`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"accountCode\":`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"1102\",`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"ratio\":`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1.0`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` \"priority\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 5`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Manual rules have higher priority (lower number) than learned rules, so they take precedence.`}),`\n`,_jsx(Heading,{level:`2`,id:`architecture`,children:`Architecture`}),`\n`,_jsxs(_components.p,{children:[`The judgment engine lives in the `,_jsx(_components.code,{children:`@repo/engine`}),` package:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`9`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`9`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`packages/engine/src/judgment/`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├── engine.ts # Main 4-step pipeline`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├── rule-matcher.ts # Step 1: Pattern matching against rules`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├── history-matcher.ts # Step 2: Similar transaction lookup`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├── ai-inferrer.ts # Step 3: LLM classification`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├── confidence.ts # Confidence score management`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├── learner.ts # Learning from confirmed entries`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└── nl-engine.ts # Natural language input processing`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Each step is independently testable and the pipeline is extensible — new steps can be inserted without changing the overall flow.`})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Judgment Engine","sidebarTitle":"Judgment Engine","description":"Deep dive into lim's 3-step judgment engine: Rule Match, History Match, AI Inference, and Escalate.","href":"/agents/judgment-engine"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Judgment Engine","slug":"judgment-engine","depth":1,"children":[]},{"title":"The 4-Step Pipeline","slug":"the-4-step-pipeline","depth":2,"children":[]},{"title":"Step 1: Rule Match","slug":"step-1-rule-match","depth":2,"children":[{"title":"How Rules Work","slug":"how-rules-work","depth":3,"children":[]},{"title":"Rule Matching Priority","slug":"rule-matching-priority","depth":3,"children":[]}]},{"title":"Step 2: History Match","slug":"step-2-history-match","depth":2,"children":[]},{"title":"Step 3: AI Inference","slug":"step-3-ai-inference","depth":2,"children":[{"title":"AI Provider / Model Configuration","slug":"ai-provider-/-model-configuration","depth":3,"children":[]}]},{"title":"Step 4: Escalate","slug":"step-4-escalate","depth":2,"children":[]},{"title":"Confidence Scores","slug":"confidence-scores","depth":2,"children":[{"title":"How Confidence Changes","slug":"how-confidence-changes","depth":3,"children":[]},{"title":"Confidence Thresholds","slug":"confidence-thresholds","depth":3,"children":[]}]},{"title":"The Learning Flywheel","slug":"the-learning-flywheel","depth":2,"children":[{"title":"Learning in Practice","slug":"learning-in-practice","depth":3,"children":[]},{"title":"Cost Trajectory","slug":"cost-trajectory","depth":3,"children":[]}]},{"title":"Rule Management","slug":"rule-management","depth":2,"children":[{"title":"Viewing Rules","slug":"viewing-rules","depth":3,"children":[]},{"title":"Manual Rule Creation","slug":"manual-rule-creation","depth":3,"children":[]}]},{"title":"Architecture","slug":"architecture","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"ship-81dac153","siteName":"lim","title":"Judgment Engine - lim","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"en":{"href":"/agents/judgment-engine","matchLevel":0},"ja":{"href":"/ja/agents/judgment-engine","matchLevel":1}}},"lastModified":"2026-03-21T14:10:22.663Z","originalFileLocation":"agents/judgment-engine.mdx","locale":"en"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Deep dive into lim\u0026#x27;s 3-step judgment engine: Rule Match, History Match, AI Inference, and Escalate.\">\u003cmeta data-mint-head name=\"application-name\" content=\"lim\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Judgment Engine - lim\">\u003cmeta data-mint-head property=\"og:description\" content=\"Deep dive into lim\u0026#x27;s 3-step judgment engine: Rule Match, History Match, AI Inference, and Escalate.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"lim\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.uselim.com/agents/judgment-engine\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://ship-81dac153.mintlify.site/_mintlify/api/og/v2?division=AI+Agents\u0026amp;title=Judgment+Engine\u0026amp;description=Deep+dive+into+lim%27s+3-step+judgment+engine%3A+Rule+Match%2C+History+Match%2C+AI+Inference%2C+and+Escalate.\u0026amp;theme=c8bcb6cabcf1745c835da490\u0026amp;signature=0d13b1b3ea09fab79b50cac6fb4e7c0e0bf2c26935c7c5ca7dc0ef2fd75e41fc\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Judgment Engine - lim\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Deep dive into lim\u0026#x27;s 3-step judgment engine: Rule Match, History Match, AI Inference, and Escalate.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://ship-81dac153.mintlify.site/_mintlify/api/og/v2?division=AI+Agents\u0026amp;title=Judgment+Engine\u0026amp;description=Deep+dive+into+lim%27s+3-step+judgment+engine%3A+Rule+Match%2C+History+Match%2C+AI+Inference%2C+and+Escalate.\u0026amp;theme=c8bcb6cabcf1745c835da490\u0026amp;signature=0d13b1b3ea09fab79b50cac6fb4e7c0e0bf2c26935c7c5ca7dc0ef2fd75e41fc\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/ship-81dac153/ocalmLxiSejS9oPG/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"lim\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#18181B\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.uselim.com/agents/judgment-engine\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/agents/judgment-engine.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://docs.uselim.com/agents/judgment-engine\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"ja\" href=\"https://docs.uselim.com/ja/agents/judgment-engine\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://docs.uselim.com/agents/judgment-engine\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.uselim.com/#organization\",\"name\":\"lim\",\"url\":\"https://docs.uselim.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/ship-81dac153/mOROYUi8HgK4gxX2/images/logo-light.svg?fit=max\u0026auto=format\u0026n=mOROYUi8HgK4gxX2\u0026q=85\u0026s=5cbee52fbb53f79b9c10eddcf5863726\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.uselim.com#website\",\"name\":\"lim\",\"url\":\"https://docs.uselim.com\",\"publisher\":{\"@id\":\"https://docs.uselim.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.uselim.com/agents/judgment-engine#webpage\",\"url\":\"https://docs.uselim.com/agents/judgment-engine\",\"name\":\"Judgment Engine\",\"description\":\"Deep dive into lim's 3-step judgment engine: Rule Match, History Match, AI Inference, and Escalate.\",\"dateModified\":\"2026-03-21T14:10:22.663Z\",\"isPartOf\":{\"@id\":\"https://docs.uselim.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.uselim.com/agents/judgment-engine#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.uselim.com/agents/judgment-engine#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"AI Agents\",\"item\":\"https://docs.uselim.com/agents/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Judgment Engine\",\"item\":\"https://docs.uselim.com/agents/judgment-engine\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.uselim.com/agents/judgment-engine#article\",\"headline\":\"Judgment Engine\",\"name\":\"Judgment Engine\",\"description\":\"Deep dive into lim's 3-step judgment engine: Rule Match, History Match, AI Inference, and Escalate.\",\"url\":\"https://docs.uselim.com/agents/judgment-engine\",\"mainEntityOfPage\":{\"@id\":\"https://docs.uselim.com/agents/judgment-engine#webpage\"},\"dateModified\":\"2026-03-21T14:10:22.663Z\",\"publisher\":{\"@id\":\"https://docs.uselim.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.uselim.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"lim\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"lim\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/agents/judgment-engine.md","siteName":"lim","nav":{"global":null,"languages":[{"language":"en","default":true,"tabs":[{"tab":"Guides","pages":[{"title":"Guides","href":"/introduction"}]},{"tab":"CLI","pages":[{"title":"CLI","href":"/cli/overview"}]},{"tab":"API","pages":[{"title":"API","href":"/api/overview"}]},{"tab":"AI Agents","groups":[{"group":"AI Agents","pages":[{"title":"AI Agent Integration","sidebarTitle":"Overview","href":"/agents/overview"},{"title":"MCP Server","sidebarTitle":"MCP Server","href":"/agents/mcp-server"},{"title":"Claude Code Skills","sidebarTitle":"Claude Code Skills","description":"Register lim commands as Claude Code skills for natural terminal-based accounting.","href":"/agents/claude-code-skills"},{"title":"Judgment Engine","sidebarTitle":"Judgment Engine","href":"/agents/judgment-engine"}]}]}]},{"language":"ja","pages":[{"title":"ja","href":"/ja/agents/judgment-engine"}]}]},"basePath":"","title":"Judgment Engine - lim","deploymentId":"dpl_vSEmv961Ncyvz1psVwgUnTXQMSYk","buildId":"dpl_vSEmv961Ncyvz1psVwgUnTXQMSYk","dynamics":[],"chunks":[]}