{"spec":"AIP-BS-LEDGER-CORE","version":"2026-11-27","standard":"ledger-core-build-standard","source":"https://aipathway.com.au/explore-ai/ledger-core-build-standard","markdown":"https://aipathway.com.au/explore-ai/ledger-core-build-standard.md","licence":"CC BY 4.0","how_to_read":"Eighteen of these twenty checks run on your own machine, against the stub, before you talk to anybody. The last one is a live tenant, and that one runs against your own live systems. One is not a software check at all: it asks what you measured before you started.","verdicts":{"pass":"asserted green here","fail":"asserted red here. This is a fixture: it names the check to price","shape_only":"shape holds on the stub, truth needs the live provider","with_us":"cannot be proved on the stub; runs against your own live systems (see with_us_next)","evidence_required":"not a software check. Attach what proves it"},"tally":{"total":20,"onStub":18,"productionOnly":1,"partial":0,"preconditions":1},"envelope_version":"1.0","port_shape":{"read_ledger":{"verb":"read","subject":"ledger"},"read_job":{"verb":"read","subject":"job"},"read_asset":{"verb":"read","subject":"asset"},"read_rule":{"verb":"read","subject":"rule"},"read_contacts":{"verb":"read","subject":"contacts"},"read_segment":{"verb":"read","subject":"segment"},"resolve_address":{"verb":"read","subject":"address"},"write_job":{"verb":"write","subject":"job"},"read_pricebook":{"verb":"read","subject":"pricebook"},"draft_quote":{"verb":"write","subject":"quote"},"write_invoice":{"verb":"write","subject":"invoice"},"write_ledger":{"verb":"write","subject":"ledger"},"record_promise":{"verb":"write","subject":"promise"},"record_service":{"verb":"write","subject":"service_record"},"release_payment":{"verb":"write","subject":"payment"},"talk":{"verb":"say","subject":"turn"},"disclose":{"verb":"say","subject":"disclosure"},"send_sms":{"verb":"say","subject":"sms"},"notify":{"verb":"say","subject":"alert"},"escalate":{"verb":"say","subject":"handoff"},"issue_notice":{"verb":"say","subject":"notice"},"answer":{"verb":"say","subject":"answer"},"publish_report":{"verb":"say","subject":"report"},"record_consent":{"verb":"write","subject":"consent"},"read_file":{"verb":"read","subject":"file"},"write_file":{"verb":"write","subject":"file"},"raise_task":{"verb":"write","subject":"task"},"read_node":{"verb":"read","subject":"node"},"write_node":{"verb":"write","subject":"node"},"read_register":{"verb":"read","subject":"register"},"write_register":{"verb":"write","subject":"register"},"index_passage":{"verb":"attach","subject":"passage"},"search_index":{"verb":"read","subject":"index"},"read_inbox":{"verb":"read","subject":"message"},"file_message":{"verb":"attach","subject":"message"},"write_order":{"verb":"write","subject":"order"},"read_quote":{"verb":"read","subject":"quote"},"write_log":{"verb":"write","subject":"log"},"read_sales":{"verb":"read","subject":"sales"},"read_sale":{"verb":"read","subject":"sale"},"draft_message":{"verb":"write","subject":"draft"},"send_message":{"verb":"say","subject":"message"},"read_memory":{"verb":"read","subject":"memory"},"propose_memory":{"verb":"write","subject":"proposal"},"write_memory":{"verb":"write","subject":"memory"},"close_job":{"verb":"write","subject":"job"},"raise_exception":{"verb":"write","subject":"exception"},"list_exceptions":{"verb":"read","subject":"exception"},"read_acceptance":{"verb":"read","subject":"acceptance"},"read_contract":{"verb":"read","subject":"contract"},"read_assessment":{"verb":"read","subject":"assessment"},"draft_claim":{"verb":"write","subject":"claim_draft"},"read_menu":{"verb":"read","subject":"menu"},"request_payment":{"verb":"write","subject":"payment_request"},"read_payment":{"verb":"read","subject":"payment"},"write_booking":{"verb":"write","subject":"booking"},"read_signoff":{"verb":"read","subject":"signoff"},"propose_journal":{"verb":"write","subject":"journal_proposal"},"set_lock_date":{"verb":"write","subject":"lock_date"},"read_link":{"verb":"read","subject":"link"},"propose_link":{"verb":"write","subject":"link_proposal"},"write_link":{"verb":"write","subject":"link"},"request_hold":{"verb":"write","subject":"hold"},"read_hold":{"verb":"read","subject":"hold"},"emit_handoff":{"verb":"write","subject":"handoff"},"read_handoffs":{"verb":"read","subject":"handoff"},"claim_record":{"verb":"write","subject":"claim"},"mark_processed":{"verb":"write","subject":"dedupe_key"},"evidence":{"verb":"attach","subject":"evidence"},"cite":{"verb":"attach","subject":"citation"},"rank":{"verb":"decide","subject":"order"},"gate":{"verb":"decide","subject":"gate"}},"provider":{"boundary":{"never":["store money as a floating point number, or parse it through one","post a journal whose debits and credits differ by any amount","change or delete a posted journal: the only correction is a reversal","post anything dated on or before the lock date, or move the lock date back","keep a running balance that a report reads instead of the journals","open from a trial balance nobody has signed off, or rewrite anything dated before the cutover"],"stays_with_person":["signing off the opening trial balance at cutover, by name","moving the lock date forward at each period end","deciding what a correction should be, before the reversal and the new journal post","explaining any difference between the build's trial balance and an independent figure","acting on a broken hash chain: who changed what, and when"]},"job":"books kept by software add up to the cent, cannot be quietly changed, and rebuild the same reports every time","skill":"ledger-core","stub":"local.mock_ledger_store","production":null,"product":null,"insert":null,"with_us":{"kind":"own_systems","note":"No hosted step runs your ledger: the build keeps its own books in its own store, and the production check runs there on a real month after a signed-off cutover. For an independent figure to compare its trial balance with, AI Pathway's check_books, on the AI Pathway connector at connect.aipathway.com.au, rebuilds the double entry from a connected ledger's own documents and compares every account with that ledger's trial balance, showing both figures for anything that differs."}},"with_us_next":"No hosted step runs your ledger: the build keeps its own books in its own store, and the production check runs there on a real month after a signed-off cutover. For an independent figure to compare its trial balance with, AI Pathway's check_books, on the AI Pathway connector at connect.aipathway.com.au, rebuilds the double entry from a connected ledger's own documents and compares every account with that ledger's trial balance, showing both figures for anything that differs. There is nothing to buy: your build does this step on the business's own systems. No production run is offered yet, because the live port map is not published, so do not run AIPATHWAY_ENV=production. Run the pass test by hand on the real systems and attach the evidence.","default_path":null,"boundary":{"never":["store money as a floating point number, or parse it through one","post a journal whose debits and credits differ by any amount","change or delete a posted journal: the only correction is a reversal","post anything dated on or before the lock date, or move the lock date back","keep a running balance that a report reads instead of the journals","open from a trial balance nobody has signed off, or rewrite anything dated before the cutover"],"stays_with_person":["signing off the opening trial balance at cutover, by name","moving the lock date forward at each period end","deciding what a correction should be, before the reversal and the new journal post","explaining any difference between the build's trial balance and an independent figure","acting on a broken hash chain: who changed what, and when"]},"substrate":{"how_to_read":"These are roles, not products. Work out which you already have by matching `providers[].detect` against the repository, then build or add only the gap. No check asserts against a vendor, so any substrate that answers the role passes the same checks.","requires":[{"role":"record","label":"Somewhere the book lives","need":"Durable storage that the workflow owns the write path to, keyed so the same record can be found twice.","when_missing":"Half a day. Any Postgres will do and the free tiers are ample at this size. The trap is not the database, it is letting people edit around the app that is supposed to own the value.","ports":["read_ledger","read_rule","write_ledger","raise_exception","set_lock_date","read_handoffs"]},{"role":"surface","label":"Something a person opens","need":"A view of the book that whoever does this job can read and act on without asking a developer.","when_missing":"Start at tier 0 and stop there until the business asks for more. The cheapest surface is not a screen, it is a scheduled email carrying the list, and for one person doing this job that is not a compromise, it is the right answer. On Microsoft 365 or Workspace you can skip straight past this: a list and a sheet are already what people open. Build upward only when two people need the same list at the same time.","tiers":[{"tier":0,"label":"A scheduled digest carrying the list","cost":"About an hour. Needs nothing you do not already have.","satisfiedBy":"send","whenYouNeedIt":"One person does this job. They want to know what is waiting when they sit down, and they act on it from their inbox."},{"tier":1,"label":"A read-only page showing the book","cost":"An afternoon. One query and one table.","whenYouNeedIt":"Somebody needs to look mid-day without waiting for tomorrow's digest, or to answer a customer on the phone."},{"tier":2,"label":"Editable rows, a queue and a log","cost":"A day or two with a coding agent, which is what agents are best at. It is bounded work: the fields are the schema, the queue is whatever escalate hands off, the log is the trace.","whenYouNeedIt":"More than one person shares the book and they need to correct it without treading on each other, and you need to see afterwards who changed what."}],"ports":["publish_report"]}],"registry":"https://aipathway.com.au/substrates.json"},"checks":[{"id":"money-in-whole-cents","n":1,"title":"Money is whole cents, parsed without floats","statement":"Every amount is stored as a whole number of cents. Money arrives as decimal text and is parsed digit by digit, never through a floating point number: thousands separators are allowed, anything past the cent rounds half away from zero, and text that is not a number is refused as NOT_MONEY.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception"],"stimulus":"Journals for 0.10 + 0.20 against 0.30, 1,234.565, 19.99, 2.675, and one line of \"12 dollars\".","assertion":"The first four post with 10 + 20 = 30, 123,457, 1,999 and 268 cents; the fifth is refused NOT_MONEY and nothing of it is stored."},{"id":"balanced-or-refused","n":2,"title":"A journal posts only if debits equal credits","statement":"A journal is stored only when its lines sum to zero to the cent. A journal out by any amount is refused as UNBALANCED; one naming an account the chart does not hold as UNKNOWN_ACCOUNT; one with no lines as NO_LINES; one reusing an id as DUPLICATE_JOURNAL. A refused journal leaves nothing in the store.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception"],"stimulus":"A balanced three-line journal, one a cent out, one on an unknown account, one with no lines, and one that repeats the first id.","assertion":"Only the first is stored; the other four are refused with those four codes; every stored journal sums to zero."},{"id":"posted-journals-frozen","n":3,"title":"A posted journal is never changed or deleted","statement":"Once a journal is stored, nothing about it changes and it is never removed. A request to edit or delete one is refused as POSTED_IS_FROZEN. The store offers no way to do either, so the only way to change what the books say is a new journal.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception"],"stimulus":"Two journals posted; on the next run, a request to change the first one's amount and a request to delete the second.","assertion":"Both requests are refused POSTED_IS_FROZEN, nothing new is stored, and both journals end exactly as they were appended."},{"id":"reversal-only-correction","n":4,"title":"The only correction is a reversal journal","statement":"A mistake is corrected by a reversal: a new journal, in an open period, that negates every line of the original (amount and GST), names the journal it reverses, and nets it to zero. The right entry then goes in as a journal of its own. A journal already reversed is not reversed again (ALREADY_REVERSED), and an id the store does not hold is refused as UNKNOWN_JOURNAL.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"Rent keyed at $1,500.00 instead of $1,050.00: reverse it, post the right amount, try to reverse it again, and try to reverse an id that does not exist.","assertion":"One reversal, dated as asked, whose lines are the original's negated and which names it; two refusals; July's profit shows rent of $1,050.00."},{"id":"period-lock","n":5,"title":"Nothing posts on or before the lock date","statement":"Once the books are locked through a date, any journal, reversal or document dated on or before it is refused as PERIOD_LOCKED. A correction to a locked period goes in dated after the lock. The lock date only moves forward; an earlier one is refused as LOCK_BACKWARDS.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","set_lock_date"],"stimulus":"July locked; then a journal dated 31 July, a journal dated 1 August, a reversal dated in July, the same reversal dated in August, a lock back to 30 June and an invoice dated in July.","assertion":"The July journal, the July reversal and the July invoice are refused PERIOD_LOCKED, the backwards lock LOCK_BACKWARDS; the August journal and reversal post; the lock stays at 31 July."},{"id":"hash-chain","n":6,"title":"Every posted journal is chained by sha256","statement":"Each stored journal carries a sequence number, the hash of the journal before it (64 zeros for the first) and its own hash: sha256, in lower-case hex, of its canonical text as this standard defines it. The build can check the whole chain on request and say whether it is intact.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"Three journals and an invoice posted, then a request to check the chain.","assertion":"Sequence numbers run 1 to 4; each prevHash is the previous hash; each hash is sha256 of the journal's canonical text; the build reports the chain intact."},{"id":"tamper-detected","n":7,"title":"Tampering with a stored journal is detected","statement":"The chain check recomputes every hash from what is stored now, never from a copy the build kept. If any stored journal has been changed, even in a way that still balances, the check reports the chain broken and names the first journal that no longer matches.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"Three journals and a chain check; between runs, the second journal's $700.00 becomes $70.00 on both sides, hash untouched; then another chain check.","assertion":"The first check reports intact; the second reports broken, first bad journal T-2."},{"id":"trial-balance-and-profit","n":8,"title":"The trial balance and profit are rebuilt from journals","statement":"Reports are rebuilt from the stored journals every time, never from a running balance. The trial balance at a date shows balance sheet accounts to that date and income and expense accounts for the financial year to that date, with total debits equal to total credits. The profit and loss for a period is income less expenses on journals dated in it.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"Blue Gum Plumbing's July: capital in, two sales, a materials bill, rent, a customer payment, and an August journal.","assertion":"The trial balance at 31 July and July's profit match the golden figures to the cent, each published after a read of the store that followed the last journal."},{"id":"balance-sheet-and-year-end","n":9,"title":"The year ends on 30 June and last year's profit rolls into retained earnings","statement":"The financial year runs 1 July to 30 June. On the balance sheet this year's profit shows as current year earnings, and every earlier year's profit is added to the retained earnings account; on the trial balance income and expense accounts start again at nil on 1 July. Assets equal liabilities plus equity.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"Trading in May and June, equipment brought in on 30 June, a sale on 1 July and depreciation on 31 July.","assertion":"The balance sheets at 30 June and 31 July, the trial balance at 31 July and the year's profit to 30 June match the golden figures, with $5,000.00 rolled into Retained Profits on 1 July."},{"id":"only-live-documents-post","n":10,"title":"Only approved documents post","statement":"An invoice, bill, credit note or bank transaction posts only when it is authorised or paid. Draft, submitted (awaiting approval), voided and deleted documents post nothing. A document already posted is not posted again (DUPLICATE_DOCUMENT); a change to it is a reversal and a new document.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"Six invoices, one in each state, a draft bill and an approved one, a deleted spend money, and an approved invoice sent twice.","assertion":"Journals exist for the authorised and paid invoices and the approved bill only; the repeat is refused DUPLICATE_DOCUMENT; the trial balance matches."},{"id":"transfer-posts-once","n":11,"title":"A transfer between your own accounts posts once and is not cash in or out","statement":"Money moved between two of the business's own bank accounts posts once, from the transfer itself: the receiving account debited, the paying one credited. The two bank transactions that describe the same move post nothing. Cash received and cash spent leave transfers out.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"A cash sale, $3,500.00 moved from the cheque account to savings (as a transfer and its two bank lines), and tolls paid from savings.","assertion":"One journal for the transfer and none for its two bank lines; August's cash received is $1,100.00 and spent $220.00; the trial balance matches."},{"id":"line-maths","n":12,"title":"Each line is worked out from quantity, price, discount and the line's own tax","statement":"A line's amount is quantity x unit price x (1 - discount), rounded to the cent half away from zero. The GST on a line entered before tax is amount x rate; on a line entered including tax it is amount x rate / (1 + rate); rounded to the cent on each line, never once on the total. The journal posts each line's amount before tax to its account, the GST to the GST account and the total to the debtor, creditor or bank. A tax code the business does not hold is refused as UNKNOWN_TAX_CODE.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception"],"stimulus":"An invoice with a 15% discount, 2.5 hours, a half-cent of tax and a GST-free line; a bill entered including GST; a sales credit note at half price; an invoice on a tax code the business does not have.","assertion":"Each posted journal's lines match the golden lines to the cent; the last invoice is refused UNKNOWN_TAX_CODE and nothing of it is stored."},{"id":"credit-allocation-date","n":13,"title":"A credit note counts from the later of its own date and the allocation date","statement":"Applying a credit note to an invoice or bill takes effect on the later of the date it is applied and the credit note's own date: a credit cannot reduce what is owed before it exists. Payments and allocations name the document they settle, so what is still open on each document at any date is rebuilt from journals alone.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"A customer credit note dated 8 September applied with a date of 25 August, a supplier credit applied after its own date, and a payment in September.","assertion":"The customer allocation is dated 8 September and the supplier one 20 August; what is open on each document at four dates matches the golden figures."},{"id":"cash-basis","n":14,"title":"Cash basis counts each payment's share of the lines, on the day it is paid","statement":"On a cash basis, each payment counts (payment / document total) of every line's amount before GST, on the payment date. A credit note allocation counts as a payment on both documents, on its effective date. Spend money, receive money and journals count in full on their own date; the documents themselves count nothing until paid. Shares are added exactly and rounded once per account.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"An invoice paid in halves across July and August, a bill paid a third, a bill paid $25.00 of $77.00, a credit note applied, spend money and depreciation.","assertion":"The cash basis profit for July and for August matches the golden figures, account by account, to the cent."},{"id":"tracking-follows-line","n":15,"title":"Tracking follows the line","statement":"Each income or expense line carries its own tracking option (a crew, a site, a region), and a report by that category counts every line under its own option. Lines with none count under Unassigned. Bank, debtor, creditor and GST lines are never tracked.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"An invoice and a bill with lines for the North and South crews and lines with no crew, and a journal tracked to South.","assertion":"July by crew matches the golden figures for North, South and Unassigned, and no balance sheet account appears under any option."},{"id":"gst-labels","n":16,"title":"GST labels add up, and 1A less 1B equals the GST account","statement":"For a period, G1 is total sales including GST, GST-free sales and exports, less sales credit notes; G2 is exports; G3 is other GST-free sales; G10 is capital purchases including GST; G11 is other purchases including GST; 1A is GST on sales and 1B is GST on purchases. 1A less 1B equals the movement on the GST account for the same period.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"A September quarter with taxable, GST-free and export sales, a credit note, a capital purchase, ordinary and GST-free purchases, an owner's drawing, and an October invoice.","assertion":"Every label matches the golden figures, and 1A less 1B equals the GST account's movement of -$273.00."},{"id":"opening-position-at-cutover","n":17,"title":"The opening position is the old system's trial balance, signed off by the accountant","statement":"A ledger that takes over from another system opens with one journal at the cutover date: the old system's trial balance, which has to balance and has to be signed off by the business's accountant by name (OPENING_NOT_SIGNED_OFF otherwise). The books are then locked through the cutover. The ledger owns everything after it only: an error found in an earlier period is corrected by an adjusting journal in the current period.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","set_lock_date","publish_report"],"stimulus":"An opening trial balance that does not balance, the right one unsigned, the right one signed, a late find dated before the cutover, and its fix dated after.","assertion":"The first two are refused UNBALANCED and OPENING_NOT_SIGNED_OFF; one opening journal equal to the trial balance, locked through 30 September; the late find refused PERIOD_LOCKED; October's trial balance and balance sheet match."},{"id":"fuzz-stays-balanced","n":18,"title":"Random balanced journals always leave the books balanced","statement":"Whatever journals arrive, in whatever order and across year ends, every balanced one posts, every unbalanced one is refused, the trial balance at any date balances and agrees with the journals, the balance sheet balances, and the chain is intact.","assertable":"stub","ports":["read_rule","read_handoffs","read_ledger","write_ledger","raise_exception","publish_report"],"stimulus":"A seeded run of 300 journals over two financial years, every seventh out by a cent, then reports at four dates and a chain check.","assertion":"258 journals stored, 42 refused UNBALANCED; each trial balance matches the journals and balances; each balance sheet balances; the chain is intact."},{"id":"survives-the-builder","n":19,"title":"It keeps working if the person who built it leaves","statement":"Someone other than the person who built it can explain what it does, and it runs on an account the business owns.","assertable":"precondition","ports":["read_rule"],"stimulus":"No stimulus. The builder names who else can explain it and whose account the ledger and its store runs on.","assertion":"The runner reports what was declared and never scores it green on its own say-so.","stubLimit":"Not a runtime property. Software cannot prove a second person understands it, and outliving its author is precisely what is being asked about."},{"id":"pass-test","n":20,"title":"The pass test passes","statement":"In the business's own books: open at a month end from the old system's trial balance, signed off by the accountant. Post one real month of documents through the build. At the next month end the build's trial balance, rebuilt from its journals, agrees to the cent with an independent figure for the same documents; 1A less 1B equals the GST account's movement; the chain check is intact; and one real journal, reversed, nets to zero.","assertable":"production","ports":["read_ledger","write_ledger","publish_report","set_lock_date"],"stimulus":"One real month after a signed-off cutover, then a trial balance, a GST report, a chain check and one reversal.","assertion":"Every account on the build's trial balance agrees with the independent figure to the cent, or the difference is named and explained by a person; the GST tie holds; the chain is intact; the reversal nets to zero.","stubLimit":"Deliberately unpassable on a stub. The golden books are invented and the runner chose every figure; only the business's own documents, its own accountant's sign-off and an independent figure for the same month prove the build keeps real books right."}]}