{
  "id": 15658567,
  "title": "Modelling a month-end close as a state machine, with a lock date and an undo log",
  "url": "https://urgent.news/2026/10/19/modelling-a-month-end-close-as-a-state-machine-with-a-lock-date-and",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-19T21:45:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/damin_mutti_e213ac1a11bf4/modelling-a-month-end-close-as-a-state-machine-with-a-lock-date-and-an-undo-log-202m"
  },
  "original_language": "en",
  "account": "A month-end close is a state machine with two levels for each account. The month moves from open to tied to finalized. AI can draft entries in open periods, but every write path, whether human or model, goes through a lock check, and every AI action is logged for reversal.\n\nZeraBooks, an AI-native general ledger, bank statement converter, and bookkeeping service for small businesses and accounting firms, has designed this system. The code is a sketch of the shape, not the source.\n\nAn account's month goes through these states: UPLOADED, TIED, NOT_TIED, FINALIZED, and TIED again. Three invariants must hold for a period to become TIED: the amounts in integer cents must match, the chains must be consistent, and the ledger balance must agree. If not, a gap is returned in cents.\n\nFinalizing is per account, while locking is per book. Locking is a single date, not a set of months. The book closes through a certain date, and nothing dated on or before that day can be added, edited, or deleted. A password can be added for extra security, and reopening is blunt, clearing the closedThrough field entirely.\n\nThe AI part, Autopilot, prepares a few kinds of month-end journal entries, like depreciation, loan interest, and prepaid cost slices. Each draft is dated the last day of the month, carries an AUTO- reference, and is posted through the same canWrite function as anything else. Locked periods are skipped.\n\nLogging every AI action is crucial for an audit trail. Each action becomes a row in the ActionLog type, with fields for ID, date, actor (either autopilot or user), entry date, before and after states, reason for the model's action, and an undoOf field set when this row reverses another. Two rules ensure honesty: undo goes through canWrite, and an undo is itself a new row that can knock a finalized month back to TIED.",
  "summary": "A month-end close is a state machine on two levels. Each account's month moves from open to tied to finalized, and the book as a whole is locked through a single date. AI can draft entries in open periods, but every write path, human or model, goes through the same lock check, and every AI action is logged so a person can reverse it. Get those rules right and the AI part is the easy bit. I run…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}