H6.ai 用 Lakebase 构建 AI 财务自动化

H6.ai 为每位客户提供专属的 Lakebase Postgres 数据库,从而在多租户的应付账款(AP)自动化平台上保持每位客户财务数据的隔离。
写时复制分支会保存任一发票问题背后的精确数据库状态,因此团队可以复现真实的客户案例,既不需要模拟数据(mock),也不会触碰实时数据或 ERP。
一次性的、已完成 schema 迁移的分支,再加上一组 AI 评审,让 H6.ai 能在新模型和引擎改动上线之前,用真实案例对其进行测试。
传统的应付账款和发票处理工具往往迫使企业陷入两难:要么借助 AI 自动化快速推进、却面临失去控制的风险,要么维持繁琐的人工审核。H6.ai 正是为解决这一问题而创立。
H6.ai 在企业现有的 ERP 之上实现应付账款自动化。它读取每张发票,将其与采购订单匹配,把发票各行分配到正确的科目,并依据企业自身的政策进行核对。我们的方法将 AI 辅助的理解与经过审批的、确定性的、可审计的政策执行结合起来。我们面临的挑战是找到一种能够大规模支持频繁回归测试的后端解决方案。
挑战:财务数据从不停滞
在这个行业里,没有两个客户是一样的。每个客户都有自己的 ERP、供应商、采购订单、会计科目表和政策。发票的形式从只有一行的服务账单到包含数百行的文档不等。
而且数据一直在变动。上午 10 点,一张发票能与一张尚有足够剩余数量的未结采购订单匹配。到了下午,该订单可能已被部分消耗、修改或关闭。再次处理同一张发票,结果就会改变,尽管我们的代码并没有变。
这让回归测试变得困难。当结果发生变化时,我们需要知道是我们的改动造成的,还是客户的数据造成的。
解决方案:Lakebase 架构
我们的工程团队需要一个可扩展的解决方案,既能隔离客户数据,又能让我们排查错误。在了解到 Lakebase 架构——它将存储与计算分离、能把闲置计算缩容至零,并支持分支——之后,我们选择它作为平台的核心记录系统。
如今,每个 H6.ai 客户都有一个专属的 Lakebase Postgres 数据库。它承载着客户完整的财务上下文:从 ERP 同步的采购订单与供应商、会计科目表与维度、历史交易,以及他们的 H6 策略。每个客户一个数据库,使各客户的数据保持隔离。
它还让我们能够冻结快照。Lakebase 分支是数据库在某一时间点的写时复制副本。创建分支不会复制任何数据:分支与父库共享存储,只存储在其上发生的变更。
当我们发现 H6 处理某张发票有误时,我们会为该客户的数据库创建一个分支,并将该分支保留为快照。一张原本处于开启状态的采购订单在快照中依然开启,剩余数量和价格不变,即便 ERP 中它已被关闭。供应商、科目、维度、历史和策略设置同样如此。我们不再试图重建问题背后的条件,而是把它们保留下来。
阴影带中的每个方块都是同一个客户数据库的一个分支。测试框架对线上数据库做一次分支以取得快照,之后不再写入该库。测试写入的所有内容都留在其各自的运行分支上,并随分支一起被删除。
发票处理测试如何运行
在我们的测试框架中,每个测试用例将一张发票与一个快照以及我们预期的结果配对:它应当匹配哪个采购订单、它的各行属于哪些账户,以及它是否应被挂起以待审核。一次运行包含四个步骤:
让快照保持最新。我们的数据库 schema 一直在演进,因此几个月前生成的快照会落后于被测代码。我们只对快照做一次分支,把当前的迁移应用到该分支上,并在同一代码版本的每一次运行中复用它。我们迁移一次,分叉多次。快照本身从不被修改。
分叉出运行分支。每次运行都会从那份最新的副本中分出属于自己的短生命周期分支。
真实地处理发票。我们流水线的候选版本像读写客户数据库一样读写运行分支。它完全按照生产环境中的方式,对原始发票文件进行抽取、匹配、分类和校验。
评判结果并删除分支。我们将流水线的实际行为与预期进行比对,然后删除运行分支。快照保持原样,为下一次运行做好准备。
一个测试计划可以混合来自多个客户、多种 ERP 和多种发票格式的用例,每个用例都针对各自保留的数据库运行。由于每次运行都从同一个冻结状态开始,同一个测试在今天、下周和下一季度都会给出相同的起点。
保护财务数据
我们不对数据库或流水线做 mock。隔离本身就完成了这项工作。测试写入的一切(审核项、校验结果、草稿文档)都会落在运行分支上,并随分支一起被删除。测试绝不会向客户的 ERP 提交数据,也绝不会写入实时数据库。
这对一个金融平台来说很重要。我们可以用生产环境所用客户数据的副本、走生产环境相同的代码路径进行测试,而客户的账簿保持不受影响。分支管理使用拥有最小权限访问的专用服务主体,且分支防护机制会拒绝触碰客户的线上分支。
AI 测试:不止于通过或失败
确认一张发票已被处理是不够的。一张发票可能被完美读取,却仍被匹配到错误的采购订单、记入错误的账户,或在处理过程中违反客户的政策。
因此,每一次运行都通过两种方式加以评判:
确定性断言检查我们能够精确陈述的事实,例如文档的最终状态、匹配到的采购订单以及各项合计。
由来自不同供应商的模型组成的 AI 评审小组会对照预期结果审查完整输出,并返回通过、失败或无法判定,同时给出其推理理由。
两者结合,能告诉我们结果是否正确,而不仅仅是处理是否完成。这让我们可以尝试新模型、改进抽取效果、降低成本、更换匹配与策略引擎,并在真实客户案例上于上线之前发现回归问题。
每一张异常发票都会成为一项回归测试
我们不会修好一个问题就继续往前走。我们会把该问题的数据库状态保存为快照,附上发票和预期结果,使其成为一个永久性的测试用例。随着我们接入更多客户、ERP 和发票格式,测试覆盖率也随着我们所服务业务的复杂度而增长。
Lakebase Postgres 为我们提供了四项我们所依赖的能力:
隔离:每个客户一个数据库,这是多租户金融平台所必需的。
冻结状态:分支会保留某个问题背后的确切财务状态,无论此后实时数据发生多大变化。
低成本、可丢弃的副本:写时复制(copy-on-write)分支让每次运行都能从一个干净且完全一致的状态开始,并在之后被丢弃。
模式安全的回放:旧快照可以在其自己的分支上向前迁移,因此随着我们代码的演进,它依然可用。
对 H6.ai 而言,Lakebase 的数据库分支功能不只是基础设施层面的便利。它正是我们构建客户可信任的、由 AI 驱动的财务自动化的方式。
未来,我们期待利用针对 Lakebase 表的 Lakehouse//RT 查询,这将使我们能够在 Lakebase 上运行只读分析查询而无需复制数据。这将让我们无需数据管道即可获得最新的分析结果。
如果你想进一步了解我们在 H6.ai 正在构建的产品,请访问我们的网站。如果你想了解 Lakebase Postgres 的数据库分支功能,请观看这个视频。
lakebase 是一种事务型数据库,将数据保留在数据湖上,面向现代化的智能体式应用栈。传统数据库运行在单台机器上。lakebase 运行无状态的数据库引擎,并将数据保存在持久化的云对象存储中,因此计算可以独立扩展,存储则按需使用。
2. 什么是 Lakebase Postgres?
Lakebase Postgres 是一个全托管的无服务器 Postgres 数据库,集成在 Databricks 平台中。团队用它来在湖仓数据旁构建实时事务型应用。它包含自动扩缩容、缩容至零、即时分支、只读副本、即时恢复、高可用性以及原生 Unity Catalog 集成。
3. Lakebase Postgres 适合 AI 用例吗?
是的。Lakebase 可作为智能体记忆和实时特征服务的后端。智能体可以把对话状态和长期记忆存储在 Postgres 中,模型则可以通过由 Lakebase 驱动的在线特征存储读取低延迟的特征数据。分支功能也让测试 AI 系统变得更加容易。例如,H6.ai 会针对冻结的数据库快照重放真实的发票案例,以便在更换模型或逻辑时捕获回归问题。
4. 分支功能是如何工作的?
原文较长,译文为节选;译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。
查看英文原文(How H6.ai builds AI-powered financial automation with Lakebase Postgres)
H6.ai gives every customer a dedicated Lakebase Postgres database, which keeps each customer's financial data isolated on a multi-tenant AP automation platform.
Copy-on-write branches save the exact database state behind any invoice issue, so the team can replay real customer cases without mocks and without touching live data or the ERP.
Disposable, schema-migrated branches and a panel of AI judges let H6.ai test new models and engine changes against real cases before they reach production.
Traditional accounts payable and invoice processing tools often force companies into a trade-off: moving quickly using AI automation and risk losing control, or maintaining tedious manual oversight. H6.ai was founded to solve this problem.
H6.ai automates accounts payable on top of a company's existing ERP. It reads each invoice, matches it to a purchase order, assigns its lines to the right accounts and checks it against the company's own policies. Our approach combines AI-assisted understanding with approved, deterministic and auditable policy execution. Our challenge was finding a backend solution that could support frequent regression testing at scale.
The challenge: financial data never stands still
In this industry, no two customers look alike. Each has its own ERP, suppliers, purchase orders, chart of accounts and policies. Invoices range from a one-line service bill to documents with hundreds of lines.
And the data keeps moving. At 10 AM an invoice matches an open purchase order with enough quantity left. By the afternoon that order may be partly consumed, amended or closed. Process the same invoice again and the answer changes, even though our code has not.
That makes regression testing hard. When a result changes, we need to know whether our change caused it or the customer's data did.
The solution: Lakebase architecture
Our engineering team needed a scalable solution that could isolate our customers' data and allow us to investigate errors. After learning about the lakebase architecture which separates storage from compute, scales idle compute to zero, and enables branching, we selected it as the core system of record for our platform.
Today, every H6.ai customer has a dedicated Lakebase Postgres database. It holds their whole financial context: purchase orders and suppliers synced from the ERP, the chart of accounts and dimensions, past transactions, and their H6 policies. A database per customer keeps each customer's data isolated.
It also allows us to freeze snapshots. A Lakebase branch is a copy-on-write copy of a database at a point in time. Creating one copies no data: the branch shares storage with its parent and only stores what changes on it.
When we find an invoice H6 handled incorrectly, we branch that customer's database and keep the branch as a snapshot. A purchase order that was open stays open in the snapshot, with the same remaining quantities and prices, even after the ERP closes it. The same holds for suppliers, accounts, dimensions, history and policy settings. We no longer try to recreate the conditions behind an issue. We keep them.

Every box in the shaded band is a branch of the same customer database. The harness branches the live database once to take a snapshot and never writes to it. Everything a test writes stays on its own run branch and is deleted with it.
How an invoice processing test runs
Each test case in our harness pairs one invoice with one snapshot and the outcome we expect: which purchase order it should match, which accounts its lines belong to, and whether it should be held for review. A run has four steps:
Bring the snapshot up to date. Our database schema keeps evolving, so a snapshot taken months ago is behind the code under test. We branch the snapshot once, apply the current migrations to that branch, and reuse it for every run on the same code version. We migrate once and fork many times. The snapshot itself is never changed.
Fork a run branch. Each run gets its own short-lived branch of that up-to-date copy.
Process the invoice for real. The candidate version of our pipeline reads and writes the run branch as if it were the customer's database. It extracts, matches, classifies and validates the original invoice file exactly as it would in production.
Judge the result and delete the branch. We compare what the pipeline did with what we expected, then delete the run branch. The snapshot stays as it was, ready for the next run.
A test plan can mix cases from many customers, ERPs and invoice formats, each running against its own preserved database. Because every run starts from the same frozen state, the same test gives the same starting point today, next week and next quarter.
Protecting financial data
We don't mock the database or the pipeline. Isolation does that job. Everything a test writes (review items, validation results, draft documents) lands on the run branch and is deleted with it. A test never posts to the customer's ERP, and the live database is never written to.
This matters for a financial platform. We can test against copies of production customer data with the same code paths production uses, while the customer's books stay untouched. Branch management uses dedicated service principals with least-privilege access, and the branching guards refuse to touch a customer's live branch.
Testing AI beyond pass or fail
Checking that an invoice was processed is not enough. An invoice can be read perfectly and still be matched to the wrong purchase order, assigned to the wrong account, or processed in breach of the customer's policies.
So each run is judged two ways:
Deterministic assertions check the facts we can state exactly, such as the document's final status, the purchase order it matched and the totals.
A panel of AI judges built on models from different providers reviews the full outcome against the expected result and returns pass, fail or inconclusive, with its reasoning.
Together they tell us whether the outcome was right, not only whether processing finished. That lets us try new models, improve extraction, cut cost and change our matching and policy engines, and spot a regression on a real customer case before it reaches production.
Every unusual invoice becomes a regression test
We don't fix an issue and move on. We keep its database state as a snapshot, add the invoice and the expected outcome, and it becomes a permanent test case. As we onboard more customers, ERPs and invoice formats, test coverage grows with the complexity of the businesses we serve.
Lakebase Postgres gives us four things we rely on:
Isolation: one database per customer, as a multi-tenant financial platform needs.
Frozen state: a branch keeps the exact financial picture behind an issue, however much the live data changes afterwards.
Cheap, disposable copies: copy-on-write branches let every run start from a clean, identical state and be thrown away afterwards.
Schema-safe replays: an old snapshot can be migrated forward on its own branch, so it stays usable as our code evolves.
For H6.ai, Lakebase’s database branching isn't just an infrastructure convenience. It is how we build AI-powered financial automation that customers can trust.
In the future, we look forward to leveraging Lakehouse//RT queries on Lakebase tables which will allow us to run read-only analytical queries on Lakebase without copying data. This will allow us to get fresh analytics without a pipeline.
If you’d like to learn more about what we are building at H6.ai, visit our website. If you want to learn more about database branching with Lakebase Postgres, watch this video.
A lakebase is a transactional database that keeps its data on the lake, for a modern, agentic app stack. Traditional databases run on single machines. A lakebase runs a stateless database engine and keeps data in durable cloud object storage, so compute can scale on its own and storage is used on demand.
2. What is Lakebase Postgres?
Lakebase Postgres is a fully-managed, serverless Postgres database integrated into the Databricks platform. Teams use it to build real-time transactional applications alongside their lakehouse data. It includes autoscaling, scale-to-zero, instant branching, read replicas, instant restore, high availability and native Unity Catalog integration.
3. Is Lakebase Postgres a good fit for AI use cases?
Yes. Lakebase serves as the backend for agent memory and real-time feature serving. Agents can store conversation state and long-term memory in Postgres, and models can read low-latency feature data through online feature stores powered by Lakebase. Branching also makes it easier to test AI systems. H6.ai, for example, replays real invoice cases against frozen database snapshots to catch regressions when it changes models or logic.
4. How does branching work?
A Lakebase branch is an instant, isolated copy of a database, much like a Git branch for your data. It uses copy-on-write: a new branch shares storage with its parent, and only changed data is written separately. As a result, branches appear instantly no matter how large the database is, and creating one doesn't slow down production. Teams use branches for development, testing and schema changes. They can also create a new branch from any point in time within the history window.
5. Does Lakebase Postgres support multi-tenancy?
Yes, in two ways. You can give each tenant its own database, as H6.ai does with a dedicated Lakebase Postgres database per customer to keep each customer's data isolated. Or you can keep tenants in shared tables and use PostgreSQL row-level security so users see only their own or their organization's data. Scale-to-zero suspends inactive compute, which keeps per-tenant databases cost-efficient.
Get the latest posts in your inbox
原文为英文,正文由自动抓取并保留原文。
原文发布于 Databricks Blog(How H6.ai builds AI-powered financial automation with Lakebase Postgres),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。