Skip to content
Skills Library
Finance & accounting · Building & coding

ledger-rules

/ledger-rules

Designs a Fragment ledger schema whose entry types enforce a money flow's invariants as ledger conditions — no negative balances, settle-once state machines, exact splits, bounded captures and refunds, fees proved on the ledger — using the kit's tested primitives. Use when writing or reviewing a Fragment schema, or when the ledger itself must check a rule on every entry.

Licence
MIT
Last repository change
04.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 04.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Designs a Fragment ledger schema whose entry types enforce a money flow's invariants as ledger conditions — no negative balances, settle-once state machines, exact splits, bounded captures and refunds, fees proved on the ledger — using the kit's tested primitives. Use when writing or reviewing a Fragment schema, or when the ledger itself must check a rule on every entry.

Original author description

Designs a Fragment ledger schema whose entry types enforce a money flow's invariants as ledger conditions — no negative balances, settle-once state machines, exact splits, bounded captures and refunds, fees proved on the ledger — using the kit's tested primitives. Use when writing or reviewing a Fragment schema, or when the ledger itself must check a rule on every entry.

How it works

  1. Rules that save hours
Original SKILL.md headings · 36 lines, 468 words
SKILL.md preview
---
name: ledger-rules
description: Designs a Fragment ledger schema whose entry types enforce a money flow's invariants as ledger conditions — no negative balances, settle-once state machines, exact splits, bounded captures and refunds, fees proved on the ledger — using the kit's tested primitives. Use when writing or reviewing a Fragment schema, or when the ledger itself must check a rule on every entry.
---

# Make the ledger enforce the rules

The kit's primitives are in `../money-flows/kit/fragment_kit/primitives.py`; each docstring says
what failure it guards against. Read [LESSONS.md](LESSONS.md) before designing: every item there cost a
failed build.

| Rule | Primitive | How |
|---|---|---|
| A balance never goes negative | `move` + `nonneg` | the source account must end ≥ 0 |
| Something happens once (settle, capture, expire) | `once` / `step` | a state account must go exactly 0→1, or n→n+1 |
| An amount can't be zero or negative | `check_ge0` on the amount | a parameter can be any number, so a spend of -5 adds 5 unless a condition refuses it; every entry type that takes an amount needs this |
| a ≥ b | `check_ge0` | post a − b into a fresh per-entry account that must end ≥ 0 |
| An account ends at an exact value (an escrow fully paid out) | `exact` | the account must end exactly at the value |
| Parts sum to a whole (a split) | `eq_zero` | the sum of the parts minus the whole must net to 0 |
| A fee is amount × rate, rounded | `proved_bps_types` | the service supplies each step; the ledger verifies it against a stored rate, with tables built by verified doubling |
| A value is set once and bound later (a price, a captured amount) | `write` / `read` | `write` sets an account once; `read` requires a parameter to equal what is stored |

Worked example: `../money-flows/kit/fragment_kit/demo_schema.py` (a hold released once at a proved
fee), with its attack tests in `../money-flows/kit/tests/test_primitives.py`.

## Rules that save hours

- Conditions read account balances only: no expressions. Amounts use only `+` and `-` (no `*`, no parentheses).
- One condition per account per entry; never a pre- and a postcondition on the same condition.
- A "must end ≥ 0" check is only sound on an account that starts at 0: use a fresh check account per entry.
  The kit keys them by each entry's idempotency key, filled in by `ServiceCore`.
- About 95 strongly consistent accounts per entry: split big proofs across entries.
- Accounts that conditions read must be strongly consistent; set `defaultConsistencyConfig` at schema level.
- Put rates and fee schedules in the schema or in ledger accounts the service can't silently change. A rate
  passed as an entry parameter lets anyone with the credential prove a 0% fee.
- Give every entry a deterministic idempotency key derived from the operation; a re-post then replays.
- `fragment verify-schema -v -p schema.jsonc` works offline: run it before every store. Stored entry type
  versions can't be removed, and a schema caps at about 385 KB.
- Correct mistakes with forward entries that are themselves checked.
Files in this package (2)
  • LESSONS.md 3 KB
  • SKILL.md 3 KB

Versions

The database has no other skills named ledger-rules.

Database snapshot: 13.11.2026 · package version eb9f2f046647 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 86money-flow-spec
    Writes the requirements spec for a money flow (credits, wallets, payouts, escrow, lending, spending limits): parties, states, amounts and rounding, time, failure, the invariants a ledger must enforce, and every field of every operation. Use when the user asks for a written spec,…
  • 90double-entry-ledger
    Use when designing or changing a ledger, wallet, balance, journal, posting or account model, or any table that answers "how much does X hold or owe". Covers immutable journal entries, postings that balance per currency, balances derived from postings, account types and normal…
  • 86judge-a-flow
    Proves a ledger-backed money flow works by writing an independent judge from the spec alone, fixing its fingerprint before the build is read, then testing the service over HTTP (amounts, races, crashes, retries) and posting forbidden entries straight to the ledger, each of which…
  • 100double-entry-ledger
    Use this skill when the user says 'double-entry ledger', 'debit credit', 'accounting equation', 'core banking ledger', 'immutable ledger', 'event-sourced ledger'. Explains balanced double-entry accounting and immutable/event-sourced ledger design for FinTech systems. Do NOT use…
  • 100fintech-ledger
    Use when work touches money movement or balances: double-entry ledger postings, wallet credit or debit, holds, capture, refunds, settlement, payouts, collections, float, multi-currency or FX, reconciliation, balance mismatches, Blnk, pgledger, or ledger tables.
  • 90kelly-money
    Busabase-backed App-in-Skill money ledger for aggregating Mercury, Stripe, Airwallex, and Creem accounts into a read-only dashboard. Use when the user invokes $kelly-money or /kelly-money, wants a total cashflow ledger, account columns, Accounts sidebar, Account Detail views,…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.