DEV Community

Irvan Gerhana Septiyana
Irvan Gerhana Septiyana

Posted on

Building a Reconciliation Engine for Enterprise AI Systems

Part 5 of the Building Enterprise AI Automation Systems Series


Introduction

Artificial Intelligence has dramatically improved how machines understand unstructured information.

Modern language models can extract entities from documents.

Named Entity Recognition systems can identify invoices, contracts, customers, and payment references.

Entity Resolution engines can map those entities to master records.

Many AI tutorials stop here.

The extracted entities are displayed.

The demo ends.

However, enterprise automation has only completed the first half of the journey.

Understanding information is not the same as making business decisions.

Imagine an AI model successfully extracts the following entities:

{
    "customer_id":"CUS-00002",
    "invoice_number":"MFG-INV-000157",
    "contract_id":"CNT-2024-587",
    "amount":3979.85
}
Enter fullscreen mode Exit fullscreen mode

Can the transaction be reconciled?

Not necessarily.

A business still needs to answer questions such as:

  • Does the invoice exist?
  • Is the invoice already paid?
  • Does the invoice belong to this customer?
  • Is the payment amount correct?
  • Is partial payment allowed?
  • Has the contract expired?
  • Is manual approval required?

These questions are not language problems.

They are business problems.

This is where the Reconciliation Engine becomes the heart of enterprise automation.


Understanding Reconciliation

Many people associate reconciliation with matching numbers.

In reality, reconciliation is the process of validating business relationships.

A payment is not considered reconciled simply because the amount matches.

It must also satisfy business constraints.

For example:

Customer
↓

Contract
↓

Invoice
↓

Payment
Enter fullscreen mode Exit fullscreen mode

Every relationship must be validated.

A payment that references the correct invoice but belongs to the wrong customer is still incorrect.

Business context always matters.


Why AI Alone Is Not Enough

Large Language Models are excellent at understanding text.

They are not designed to enforce financial policies.

Suppose an AI model predicts:

{
    "invoice":"MFG-INV-000157"
}
Enter fullscreen mode Exit fullscreen mode

Should the invoice automatically be marked as paid?

No.

The AI has identified an invoice.

It has not validated the business.

Validation requires deterministic logic.

Enterprise software depends on deterministic behavior.

This is why rule engines continue to play a critical role in modern AI architectures.


Designing the Reconciliation Pipeline

Our reconciliation pipeline consists of several independent stages.

Bank Statement
        │
        ▼
Canonical Transformation
        │
        ▼
Named Entity Recognition
        │
        ▼
Entity Resolution
        │
        ▼
Business Validation
        │
        ▼
Decision Engine
        │
        ▼
Reconciliation Result
Enter fullscreen mode Exit fullscreen mode

Each stage contributes information.

Only the Decision Engine determines the final outcome.


Business Validation Rules

The Decision Engine evaluates multiple business constraints.

Instead of asking a single question, it evaluates many.


Customer Validation

Does the payment belong to the expected customer?

Example:

Payment

↓

ALPHABRIDGE SOLUTIONS

↓

Invoice Owner

↓

ALPHABRIDGE SOLUTIONS

↓

PASS
Enter fullscreen mode Exit fullscreen mode

Invoice Validation

Does the invoice exist?

Invoice

↓

MFG-INV-000157

↓

Invoice Database

↓

FOUND
Enter fullscreen mode Exit fullscreen mode

Contract Validation

Does the invoice belong to an active contract?

Invoice

↓

Contract

↓

Status

↓

ACTIVE
Enter fullscreen mode Exit fullscreen mode

Amount Validation

Does the payment amount satisfy business expectations?

Possible scenarios include:

Exact Payment
Enter fullscreen mode Exit fullscreen mode
Partial Payment
Enter fullscreen mode Exit fullscreen mode
Overpayment
Enter fullscreen mode Exit fullscreen mode
Underpayment
Enter fullscreen mode Exit fullscreen mode

Different organizations implement different policies.

The Decision Engine should support configurable rules.


Currency Validation

Example:

Invoice

EUR
Enter fullscreen mode Exit fullscreen mode

Payment

USD
Enter fullscreen mode Exit fullscreen mode

Automatic reconciliation should probably stop.


Duplicate Payment Detection

A second payment for the same invoice may indicate:

  • duplicate transfer
  • accounting error
  • fraud
  • intentional split payment

The engine must detect these situations before reconciliation.


Decision Categories

Instead of returning only True or False, the engine produces business decisions.

For example:

AUTO_RECONCILED
Enter fullscreen mode Exit fullscreen mode

Everything is valid.

No human intervention required.


PARTIAL_PAYMENT
Enter fullscreen mode Exit fullscreen mode

Invoice remains open.

Outstanding balance exists.


OVERPAYMENT
Enter fullscreen mode Exit fullscreen mode

Customer paid more than expected.

Refund or credit note may be required.


UNDERPAYMENT
Enter fullscreen mode Exit fullscreen mode

Payment received.

Invoice remains partially unpaid.


MULTIPLE_INVOICES
Enter fullscreen mode Exit fullscreen mode

One transaction settles multiple invoices.


REVIEW_REQUIRED
Enter fullscreen mode Exit fullscreen mode

Business confidence is insufficient.

Escalate to finance.

These decisions become the language of downstream automation.


Rule Engine Design

A common misconception is that rule engines are obsolete.

The opposite is true.

AI identifies possibilities.

Rules enforce certainty.

A simplified evaluation flow looks like this:

Invoice Exists?

↓

NO

↓

REVIEW_REQUIRED
Enter fullscreen mode Exit fullscreen mode

Customer Match?

↓

NO

↓

MANUAL_REVIEW
Enter fullscreen mode Exit fullscreen mode

Amount Correct?

↓

YES

↓

AUTO_RECONCILED
Enter fullscreen mode Exit fullscreen mode

Notice that every decision is deterministic.

No hallucinations.

No ambiguity.

Exactly what enterprise software requires.


Confidence-Based Decisions

Not every prediction should trigger automation.

Suppose Entity Resolution returns:

{
    "customer_id":"CUS-00002",
    "confidence":0.98
}
Enter fullscreen mode Exit fullscreen mode

Automatic reconciliation is probably acceptable.

Now imagine:

{
    "customer_id":"CUS-00017",
    "confidence":0.54
}
Enter fullscreen mode Exit fullscreen mode

Should the ERP be updated?

Probably not.

Confidence thresholds allow organizations to balance automation with operational risk.

For example:

Confidence ≥ 0.95

↓

Automatic Processing
Enter fullscreen mode Exit fullscreen mode
Confidence ≥ 0.80

↓

Human Verification
Enter fullscreen mode Exit fullscreen mode
Confidence < 0.80

↓

Manual Review
Enter fullscreen mode Exit fullscreen mode

This approach dramatically reduces costly reconciliation mistakes.


Building Explainable Decisions

One advantage of rule-based reconciliation is explainability.

Instead of returning:

Rejected
Enter fullscreen mode Exit fullscreen mode

The engine should explain why.

Example:

{
    "status":"REVIEW_REQUIRED",
    "reason":"Invoice amount does not match payment amount."
}
Enter fullscreen mode Exit fullscreen mode

Or:

{
    "status":"PARTIAL_PAYMENT",
    "remaining_balance":620.50
}
Enter fullscreen mode Exit fullscreen mode

Explainability increases trust.

Finance teams are far more likely to adopt AI systems that justify their decisions.


Integrating AI with Business Rules

One of the most important architectural lessons from this project is that AI should not replace business rules.

Instead, AI should enrich them.

Think of the relationship like this.

NER

↓

Extracts Business Entities

↓

Entity Resolution

↓

Identifies Business Objects

↓

Business Rules

↓

Evaluates Policies

↓

Decision Engine

↓

Determines Outcome

↓

Automation
Enter fullscreen mode Exit fullscreen mode

Every layer has a single responsibility.

This separation makes systems easier to test, explain, and maintain.


Lessons Learned

Building the reconciliation engine fundamentally changed how I think about enterprise AI.

Initially, I assumed machine learning would solve most of the problem.

Instead, machine learning solved understanding.

Business rules solved trust.

This distinction became one of the most valuable lessons in the project.

Organizations rarely automate because they understand language.

They automate because they trust decisions.

Trust comes from deterministic validation.

Not prediction alone.


Conclusion

Artificial Intelligence is exceptionally good at understanding documents.

Enterprise software, however, must also enforce policies.

A reconciliation engine bridges these two worlds.

It transforms extracted entities into validated business decisions.

By combining AI with deterministic business logic, organizations can automate financial operations without sacrificing reliability, auditability, or explainability.

The future of enterprise automation is therefore not AI versus rules.

It is AI working together with rules.


What's Next?

Part 6 — Building a Transaction Intelligence API with FastAPI

In the next article, we'll expose the entire pipeline as a production-ready REST API.

We'll cover:

  • Designing clean API contracts
  • Request and response schemas
  • Inference pipelines
  • Streaming predictions
  • Error handling
  • Confidence reporting
  • Production deployment with FastAPI

We'll transform our Transaction Intelligence pipeline into a service that ERP systems, finance platforms, AI agents, and enterprise applications can consume in real time.

Top comments (15)

Collapse
 
jugeni profile image
Mike Czerwinski

The "trust comes from deterministic validation, not prediction alone" line is the one I want to pull out, because it inverts the framing enterprise-AI posts default to. The post explicitly resists collapsing identification (AI's job) into authorization (rules' job), and the REVIEW_REQUIRED category is the operationalized version of that split: instead of forcing a binary outcome, the engine produces a state that names what it could not decide on its own.

Same shape as a few other threads landing this week from different angles. Vinothsingh's FRIDAY agent uses a "Suspected" tag for findings that don't meet the confirmation bar, instead of dropping them or overstating them. Whatsonyourmind's decision-ledger architecture requires the bijection between executed actions and authorized decisions to be verifiable independently, not asserted. Different domains, same composition primitive: the layer that decides has to be a different layer than the one that perceives, and the failure mode has to be a first-class output rather than a silence.

One forward observation on the confidence thresholds: the 0.95 / 0.80 / <0.80 split is doing real work, but the audit question one floor under is how those thresholds get calibrated against actual reconciliation outcomes over time. The threshold that's correct at month one is not necessarily correct at month twelve. Is there a feedback loop where REVIEW_REQUIRED outcomes get classified post-hoc and the confidence boundaries adjust, or does the threshold stay locked once set?

Collapse
 
uigerhana profile image
Irvan Gerhana Septiyana

That's a fantastic observation.

I really like how you framed it as "the failure mode has to be a first-class output rather than a silence." That's exactly the behavior I was aiming for with REVIEW_REQUIRED.

One thing I wanted to avoid was creating the illusion that the system always has enough information to make a binary decision. In production finance systems, uncertainty is itself valuable information, so surfacing it explicitly is much safer than forcing an automated outcome.

And I think your point about confidence calibration is where the next architectural layer begins.

The thresholds in the article are intentionally static to illustrate the decision flow, but I don't think they should remain static in a production environment.

My current thinking is that every REVIEW_REQUIRED case should eventually receive a human resolution, and those outcomes become labeled feedback. Over time, that feedback can be used to measure precision, false positives, false negatives, and confidence drift, allowing the thresholds to be recalibrated based on actual operational performance rather than fixed values.

In that sense, the reconciliation engine doesn't just make decisions, it continuously learns where its own decision boundaries should be.

Collapse
 
jugeni profile image
Mike Czerwinski

Yes — and the feedback loop has a sample-selection problem worth naming: REVIEW_REQUIRED only fires on cases the current thresholds flag. The labeled outcomes flowing back into recalibration are entirely within the gate's current field of view. False negatives — the cases auto-resolved that should have been escalated — never enter the feedback set, so they can't move the threshold that's hiding them.

Which means continuous learning from gate-output is structurally bounded by gate-output. To get the missing axis you need an externally-authored sampling pass on the auto-resolved population — a periodic shadow review of a random slice of cases the engine said it was sure about, resolved by humans without seeing the engine's confidence. That gives you false-negative rate as a measured signal rather than an inferred one, and lets the boundary move into territory the boundary currently can't see.

Thread Thread
 
uigerhana profile image
Irvan Gerhana Septiyana

That's a really insightful point.

You're right, the feedback loop becomes conditioned on the gate itself. If we only learn from REVIEW_REQUIRED, we're effectively sampling from the uncertainty region while assuming the "confident" region remains correct.

I like your idea of a shadow review because it breaks that assumption.

A periodic, randomly sampled audit of auto-reconciled cases would expose false negatives that never enter the feedback loop, giving us a much more representative picture of real-world performance. More importantly, it turns threshold calibration into an evidence-driven process rather than one based solely on observed uncertainty.

It also makes me think the reconciliation engine shouldn't just output business decisions, it should output evaluation opportunities. Some cases are reconciled because the business is finished with them, while others should be revisited because the system needs to keep learning where its confidence boundaries actually are.

That feels much closer to how production AI systems should evolve: not just through human corrections, but through deliberately designed feedback mechanisms.

Thread Thread
 
jugeni profile image
Mike Czerwinski

Yes — and the second output type (evaluation opportunity, distinct from business decision) is the right structural move, but it has a quiet authorship question worth surfacing. If the engine decides which auto-reconciled cases get tagged as evaluation opportunities, you've recreated the sample-selection problem one level up: the audit pool is still authored by the system being audited, just with a different selection rule.

The version that breaks out of that recursion: the evaluation tag is assigned by stratified random draw over the confident-decision population, not by any engine-internal heuristic about which cases "seem worth revisiting." The engine's role collapses to dice-roll, and the audit pool stops being a downstream artifact of the engine's own uncertainty model. Stratify by features the engine doesn't weight strongly — that way the sample over-represents the regions where the engine's confidence might be misplaced for reasons it can't see.

The framing "deliberately designed feedback mechanisms" carries a lot here. The deliberateness has to include who picks the sample, on what basis, and whether that basis is authored outside the thing being measured.

Thread Thread
 
uigerhana profile image
Irvan Gerhana Septiyana

I think you've identified something even more fundamental.

At that point, the discussion stops being about model evaluation and becomes a governance question.

If the engine is allowed to decide what gets audited, then the evaluation process is no longer independent from the system being evaluated. Even if the selection rule changes, the authorship hasn't.

I like your suggestion of treating the audit pool as an externally governed process rather than an engine capability. A stratified random sample over the "confident" population creates an independent measurement channel, which is exactly what's needed if we want to estimate false negatives instead of simply observing uncertainty.

It also reinforces something I've been thinking about more generally: in enterprise AI, the evaluation system shouldn't be owned by the decision system. They should be separate components with different responsibilities and different sources of authority.

That separation feels very similar to how financial audits, quality assurance, and security reviews work in mature organizations. The AI shouldn't be responsible for proving that its own decisions are trustworthy.

Thread Thread
 
jugeni profile image
Mike Czerwinski

Yes, and the financial-audit analogy is worth pushing on, because it's the canonical case of separation working on paper and failing in practice. The Big Four model has the right structural separation. The decision system doesn't own the evaluation system. But the economic relationship (audit fees paid by the audited firm, partner rotation but not firm rotation) keeps re-introducing the same problem the separation was supposed to solve. Arthur Andersen had Enron as a client for sixteen years. Auditor capture isn't a violation of the structure, it's a feature of the structure under the wrong incentives.

Translates back. In your domain, the separation has to be load-bearing economically and politically, not just architecturally. Who pays for the evaluation pool? Who can shut it down if its results are inconvenient? Who decides when its sampling methodology changes? If the answer to any of those is "the team running the decision system," then the separation is formal but not real.

Thread Thread
 
uigerhana profile image
Irvan Gerhana Septiyana

That's a great extension of the analogy.

You're right, architectural separation doesn't automatically produce institutional independence.

The audit model only works if the incentives protecting that separation are as carefully designed as the architecture itself.

I hadn't been thinking deeply enough about the governance of the evaluation process itself, but your examples make that distinction very clear. An independently designed evaluation pipeline can still become ineffective if the authority to fund it, redefine it, or ignore its findings remains coupled to the system being evaluated.

It makes me think there are really three independent layers here:

  • Decision – the system that produces business outcomes.
  • Evaluation – the system that measures whether those outcomes were correct.
  • Governance – the system that defines who owns, oversees, and can change the evaluation process itself.

The more we've discussed this, the more I'm convinced Enterprise AI isn't just an engineering discipline. It's also an organizational design problem.

Thread Thread
 
jugeni profile image
Mike Czerwinski

The three-layer split is a useful structural cut. One observation about Layer 3 worth flagging: governance can be captured too, which is what made the financial-audit case break despite SEC and PCAOB existing on paper. The fix that mature compliance regimes converge on is a fourth role. An adversarial actor whose incentive is to prove the system wrong, with funding that doesn't depend on the system being right. Short-sellers in equities, whistleblower bounties in fraud, bug bounties in security. Without that, governance is just one more layer the system can quietly socialize.

Agreed on the organizational-design framing. The bit you've landed is the part a lot of "AI governance" framework writing skips. Separation isn't a diagram, it's a question of where the money and the authority actually live.

Thread Thread
 
uigerhana profile image
Irvan Gerhana Septiyana

I think that's an important distinction.

It's tempting to keep adding layers every time we identify a new failure mode, but at some point the goal isn't to build a taller hierarchy, it's to build checks that remain independent.

Your examples all share the same underlying principle: trust doesn't emerge from adding another control layer. It emerges from aligning incentives so that someone has both the authority and the motivation to challenge the system.

That shifts the conversation beyond software architecture and into institutional design.

A decision engine can be audited.

An evaluation process can be governed.

But governance itself also needs mechanisms that make it accountable rather than self-reinforcing.

The financial audit analogy makes that very clear. Independence isn't something you achieve once by drawing the right boxes on an architecture diagram. It's something that has to be continuously protected through incentives, transparency, and the ability to challenge assumptions from outside the system.

I didn't expect a discussion about a reconciliation engine to end up here, but I think this is exactly where Enterprise AI becomes most interesting. At scale, we're not only engineering software, we're engineering organizations that need to remain trustworthy over time.

Thread Thread
 
jugeni profile image
Mike Czerwinski

Authority plus motivation to challenge is the single load-bearing line in this whole thread, and it's the part a lot of "AI governance" writing leaves out by treating governance as architecture rather than as continuous practice. You can ship a clean architecture diagram on day one and have institutional drift collapse it by day 365 without anyone noticing, because no diagram tracks whether the challenge function is still funded, staffed, and listened to.

The closing reframe is the part I'm taking away: at scale, we're engineering organizations that need to remain trustworthy over time. The "over time" is doing more work in that sentence than a lot of enterprise-AI conversations notice. Trust isn't a property of the architecture, it's a property of how the architecture is maintained against its own entropy. Good thread.

Thread Thread
 
uigerhana profile image
Irvan Gerhana Septiyana

I really appreciate this discussion.

I think you've articulated something I was intuitively feeling but hadn't yet put into words:

Trust isn't a property of the architecture. It's a property of how the architecture is maintained against its own entropy.

That idea will probably stay with me for a long time.

When I started writing about Enterprise AI, I was mostly thinking in terms of models, pipelines, and system architecture.

This conversation gradually shifted my perspective toward governance, incentives, and ultimately organizational resilience.

You're absolutely right that the phrase "over time" carries the real weight here.

Anyone can design a trustworthy system on day one.

The much harder challenge is designing an organization that continues to deserve that trust years later, even as people, incentives, priorities, and models inevitably change.

Thanks for pushing the discussion in that direction. I genuinely learned a lot from it.

I hope we get to have more discussions like this in the future. Conversations like this are exactly why I enjoy sharing ideas publicly.

Much respect.

Thread Thread
 
jugeni profile image
Mike Czerwinski

Much respect back. The reason this thread worked is that you kept synthesizing forward instead of just defending the original frame. The three-layer split, the institutional-design reframe, the "authority plus motivation to challenge" line — those were your moves, and they're what made the recursion productive instead of just clever. Looking forward to the next one.

Thread Thread
 
uigerhana profile image
Irvan Gerhana Septiyana

Thank you, that genuinely means a lot.

One thing I've come to appreciate is that publishing isn't the end of the thinking process—it's the beginning of it, this discussion pushed my thinking well beyond the original article, and I'm grateful for that, I have a feeling a few future articles have already been written in the comments. 🙂

Looking forward to crossing paths again. Until the next discussion.

Thread Thread
 
jugeni profile image
Mike Czerwinski

I have a big que waiting already, but I try to stop myself from spamming ;)