{"slug": "yggthreads-a-tree-of-names-as-the-database-and-an-app-as-a-text-file-of-forms", "title": "Yggthreads: A tree of names as the database, and an app as a text file of forms", "summary": "A developer released yggthreads, a proof-of-concept development tool written in about 4,300 lines of Go plus one HTML page, that replaces a conventional schema, ORM, CRUD screens, permissions table and audit log with a tree of names and append-only threads. In yggthreads, every tracked object gets a domain-style name such as eh.north.i100001, each name carries a thread of form entries recording who filled in what and when, and the app itself is defined in a single .forms text file; the developer reports having built four apps with it so far. The tool derives current state and a rebuildable search index from the threads, and grants roles at a name so they hold for everything beneath it, with no separate permissions table.", "body_md": "# yggthreads: a tree of names as the database, and an app as a text file of forms\n\nTHis was written by Claude based on my request, it is really useful development tool so I want to share it.\n\nMost of the software small businesses need comes down to the same few things: some objects, the forms people fill in about them, who is allowed to fill in which form, what state each object is in now, and some totals. A tool-hire shop, a building contractor tracking snags, a ward tracking beds, a company running road signs. Each of these normally becomes a schema, an ORM, a set of CRUD screens, a permissions table and an audit log added later.\n\nyggthreads is my attempt to make that whole stack one idea. It's a proof of concept, about 4,300 lines of Go and one HTML page, and I've written four apps in it so far. This post is what it is, why it's shaped the way it is, and where it falls short.\n\n## The idea\n\nEverything the app tracks gets a **name in a tree**, like a domain name read the other way:\n\n```\neh                     a rental company\neh.north               its north depot\neh.north.i100001       a rotary hammer drill at that depot\neh.c-013               a customer\n```\n\nEvery name has a **thread**: a list of entries, only ever added to. An entry is a form someone\n        filled in, with who, when and from where. The thread *is* the record. There are no tables and no rows\n        to update. The drill's thread is its whole life: bought, safety-checked, hired out, returned damaged, sent for\n        repair, back, counted in a stock take, written off.\n\nThe current state (out, due back Friday, with customer 13) is worked out from the thread, and a search index is built from all the threads. Delete the index and nothing is lost: it's rebuilt at start.\n\n## An app is a text file\n\nThe app itself is a `.forms` file. Here is part of the rental one:\n\n```\napp rental \"Equipment rental\"\n\nrole manager: process at company branch customer item, read, give roles\nrole counter: process at company branch customer item, read\nrole workshop: process at item, read\n\nkind branch\n  form add-item \"Add an item\" -> new item\n    title from name\n    barcode \"Barcode\": barcode required\n    name \"Item\": text required\n    day_rate \"Day rate (R)\": number required\n    cost \"Bought for (R)\": number total\n    sets status = in\n\nkind item\n  form rent \"Rent out\" -> here\n    only if status = in\n    customer \"Customer\": ref customer required\n    due \"Due back\": time required\n    sets status = out\n    sets customer = $customer\n    sets due = $due\n    also to customer\n\n  form check-in \"Check in\" -> here\n    only if status = out\n    condition \"Came back\": choice Good | Damaged | Parts missing required\n    charged \"Rental charged (R)\": number required total\n    sets status = in\n    sets customer = none\n    also to state customer\n```\n\nThat's most of what there is to the language:\n\n- **Kinds and forms.** A form belongs to a kind of name.`-> new item` makes a\n          new name under the one you're on;`-> here` adds to this name's own thread.\n- **A workflow is `only if` plus `sets`.** You can't rent out a drill\n          that's already out, or check in one that's on the shelf. The server refuses, and says why (\"Rotary hammer\n          drill is out, not in\").\n- **`also to` copies the entry into another thread.** Renting a drill to a customer\n          also lands in the customer's thread, so their page shows what they have out and everything they've ever\n          hired.`also to state customer` means \"whoever the drill is out to now\", so the check-in follows\n          the rental there.\n- **Roles are given at a name and hold for everything under it.** Making someone counter\n          staff at`eh.north` lets them work that depot and nothing else. There is no permissions table;\n          the grant is itself an entry in`eh.north` 's thread.\n- **`total` adds a number up the tree.** Every depot, and the company, shows what\n          its stock cost and what it has earned, and counts its items by status (32 out, 55 in, 1 in repair).\n\nThe page is generic. It reads the forms files at start and draws every app from them: the tree, the forms you're allowed to fill in where you are, the threads, the totals, search. The rental app also has a barcode field type, so the page grew a scan box and prints Code 128 label sheets. Scan a label and the item opens; pick \"Rent out\", fill in the customer once and scan five laptops in a row.\n\n## What's on disk\n\nOne folder per name, and one file per thread, one JSON line per entry:\n\n```\ndata/eh/north/i100001/_thread.jsonl\n\n{\"id\":\"01786693320000000000-e733f422\",\"at\":\"2026-08-14T07:42:00Z\",\n \"by\":\"Counter Adams\",\"from\":\"eh.north.i100001\",\"form\":\"rent\",\n \"fields\":{\"customer\":\"eh.c-013\",\"due\":\"2026-08-15T19:00\",\"contract\":\"C10438\"},\n \"sets\":{\"status\":\"out\",\"customer\":\"eh.c-013\",\"due\":\"2026-08-15T19:00\"}}\n```\n\nYou can `cat` any object's history. You can `grep` the whole company. A backup is a copy\n        of a folder. The index is SQLite with FTS5 next to it, and searching \"everything under `eh.north`\"\n        is a range scan on the name, so it stays fast however deep the tree goes.\n\nOn my desktop, a hospital example with 2,000 patients (21,349 entries) builds its index in 3.9 seconds at start, and searches take 1 to 13 ms. The rental example, 176 items and 120 days of business (4,250 entries), builds in 3.3 seconds.\n\n## Why it's shaped like this\n\nI didn't start from \"databases are bad\". I started from storage. I run a small group of machines in homes\n        and offices ([the first post](https://peterretief.org/posts/build-without-the-cloud/) has more), and the storage spreads\n        each file across them as encrypted pieces, six data and four spare, so any four machines can be off.\n        That's good for files written once. It's terrible for a database file that changes in place.\n\nAppend-only threads fit it well:\n\n- **Merging is taking both.** Two copies of a thread merge by union on the entry ID. An entry\n          that arrives late from a box that was offline goes into its place by time. No conflicts to resolve, because\n          nothing is ever edited.\n- **Every machine builds its own index.** The index is a cache, not the truth, so it never has\n          to be replicated.\n- **Batches, not files.** New entries are gathered per company and stored about once a minute\n          as one encrypted batch. A wiped box gets every thread back from the group. In a test, 1,773 entries came\n          back exactly with two of six machines switched off.\n- **The audit log is free.** It isn't a feature, it's the data. \"Who changed this and when\"\n          is always the thread.\n\n## What it's like next to things you know\n\n- **Event sourcing,** without the infrastructure. The events are forms people filled in, the\n          projection is \"state\" and \"totals\", and the event store is a folder.\n- **Lotus Notes,** which had documents, forms, workflow by mail and replication between\n          servers in 1989. A lot of this is me rediscovering it.\n- **Access, FileMaker, Airtable:** the same promise of \"describe it, get an app\". The\n          difference is that history comes first and the current state is derived, rather than the other way round.\n- **DNS, LDAP:** the tree of names, and delegation down it. Roles given at a name work like\n          delegating a zone.\n\n## Where it falls short\n\nPlenty, so far:\n\n- **No real sign-in yet.** The page asks \"You are\" and believes you. Roles are enforced on the\n          server, but against a name you typed. My public demo sits behind a shared password for this reason.\n- **Only the questions the index knows.** Counts by status, totals by field, text search,\n          \"under this name\". Anything else (which customers hire laptops in winter?) means reading the threads\n          yourself. There is no query language, and I'm not sure there should be.\n- **One object, one place in the tree.** Moving a drill to the other depot means a new name,\n          or a move form that both threads record. I haven't built that yet.\n- **Old entries keep their old shape.** Change a form and last year's entries still have last\n          year's fields. The page shows whatever is there, which works, but there's no version or migration story\n          yet.\n- **It's meant for small businesses, not high write rates.** One box writes a company's\n          threads; other boxes catch up. Tens of entries a minute is fine. A trading system is not what this is for.\n- **The code isn't public yet.** It will be once sign-in is in and the forms language has\n          settled.\n\n## What I'd like to know\n\nWhether the forms language holds up in an app I didn't design. If you have a small, real process (a\n        workshop, a lab's sample tracking, a club's equipment), I'd like to try writing it as a `.forms`\n        file and see what's missing. And if you've built on Notes, or on an event-sourced system, I'd like to hear\n        what hurt later on, before it hurts me.", "url": "https://wpnews.pro/news/yggthreads-a-tree-of-names-as-the-database-and-an-app-as-a-text-file-of-forms", "canonical_source": "https://peterretief.org/posts/names-as-the-database/", "published_at": "2026-12-05 18:44:59+00:00", "updated_at": "2026-12-05 19:15:12.216984+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools"], "entities": ["yggthreads", "Go", "Claude"], "also_reported_by": [], "takeaway": "yggthreads replaces schema, ORM, CRUD screens, permissions and audit log with a .forms text file plus append-only per-name threads, where 'only if' and 'sets' rules enforce workflow state server-side and roles granted at a name apply to everything under it.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/yggthreads-a-tree-of-names-as-the-database-and-an-app-as-a-text-file-of-forms", "markdown": "https://wpnews.pro/news/yggthreads-a-tree-of-names-as-the-database-and-an-app-as-a-text-file-of-forms.md", "text": "https://wpnews.pro/news/yggthreads-a-tree-of-names-as-the-database-and-an-app-as-a-text-file-of-forms.txt", "jsonld": "https://wpnews.pro/news/yggthreads-a-tree-of-names-as-the-database-and-an-app-as-a-text-file-of-forms.jsonld"}}