tickets
All repositories: gitoria
2.7 KB
# `hl:mpackdb` — the MessagePack file databaseA document store in plain files. Server realm. The class surface and itsgenerated API docs live in `MPackDB.hl` and `cursor.hl`(`projects/homepage/docs/mpackdb.md`).```hybrielimport { MPackDB } from 'hl:mpackdb'db = new MPackDB(file = 'users.db', primaryKey = '*id', indexes = ['!email', 'age'])id = db.put({ name = "Alice"; email = "[email protected]"; age = 30; }) \\ 1```## Primary keys| declaration | key | generated by `put()` ||---|---|---|| `*name` | a number | the table's counter: **1, 2, 3, …** || `@name` | a string | a random 12-character id || `name` | a string | nothing — the record must carry it |**A fresh `*id` table starts at 1** (ticket #4, the creator's ruling "start at1"). The counter is stored as `nextId` in `<base>.meta.json`, and an existingtable keeps counting from its stored value. A table written before this ruletherefore goes on from wherever it was, and its record 0 remains record 0.A record put with an explicit key takes that key if it is free, 0 included.## One open table per process (ticket #110)Within one process, a table path has **one** open table, shared by every`open()` — another module instance, another realm, it doesn't matter, theyall get the same handle. The file is never compacted or rewritten while ahandle on it is live; compaction happens only when asked for explicitly(`compactNow()` / `#handle.compact()`) or when the **last** handle on thatpath closes. A second `open()` of an already-open table ignores its own`primaryKey`/`indexes`/`compact` arguments — the schema was fixed by whoeveropened it first.This matters because compaction rewrites `<base>.mpack` and shifts everyrecord after the first tombstone to a new offset. Before this rule, a second`open()` from anywhere in the process ran its own compact-on-open (ticket#21) against the same file, and the first handle's already-looked-up offsetswent stale under it — reads through the first handle then missed ormisread records until something compacted again. Related: ticket #21("opening a table rewrote its files").## Compatibility with the JS mpackdbThe on-disk format is the JS mpackdb 1.0.7 format: `<base>.mpack`,`<base>.meta.json`, one `<base>.<field>.txt` per index, `<base>.idxstate.json`and the `<base>.lock` protocol. Either side reads and changes the other'sfiles. The first id is not part of the format; `nextId` is. Therefore:- a table the JS mpackdb created carries `nextId` and keeps its sequence here,even when that sequence started at 0;- a table Hybriel created carries `nextId` too, and the JS mpackdb continues it;- the one divergence is a table with **no** `.meta.json` yet: Hybriel's firstid is 1, the JS mpackdb's is 0.The other documented divergences are listed at the top of `engine.zig`.
Branches
- mainmain branch
Latest commits
- a75e0279mission 010 (code order) 3/4: let only where a variable is reassigned or re-bound in a loop body (456 lets → plain declarations; Hybriel refuses a plain declaration inside a loop on its 2nd pass). gate 249/0, connect 60/0, real-data reads identical, a 50-step write sequence (API + faces) identical to the old codemre
- e9d5c618mission 010 (code order) 2/4: one lib/ file per topic — store.hl split into projects / tickets (+ relations) / events / tickets-helpers, util.hl shared helpers (env, storage dir, URLs, sorts, Vienna time), the function routes out of project.hl into lib/api.hl (thin; auth/filters/Accept in api-helpers.hl), invite + member-removal logic out of the faces/routes into invites.hl / tickets.hl; project.hl is the map. /login/callback gets req + the session store by reference. gate 249/0, connect 60/0, real-data reads identicalmre
- 97e269b5mission 010 (code order) 1/4: .hl files out of the root — lib/ (store, users, connections, invites, migrate, markdown, mdview, import = ticketfile, util = localtime, jsoncheck, api-helpers = api), tools/import.hl, components/styles.hl; import paths only. gate 249/0, connect 60/0, real-data reads identicalmre
- 38f9d10ftickets: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); gate 249/0, connect 60/0mre
- d3db6139tickets: Hybriel master 190aa11d (fc838894 GC correctness, #126 closure scopes, #127); gate 249/0, connect 60/0mre
- bce182e3tickets: Hybriel master 7eea0d32 (#126 memory, #48 lambda copies its argument); migrate.hl lambdas take &logmre
- 4137be0fantcolony#40: mission references point to the moved missionsmre
- 9bfba36aantcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
- c7bd2645tickets: Hybriel master 73267707 (#122 fixed); compactNow workaround removed (#110 covered)mre
- 2ab91ee9tickets: gate checks rows appear once (session sync); re-vendor to ff51cf46 stopped on hybriel#122, stays 837fe120mre
- e01c2b1dtickets#24: installable app (manifest, service worker, offline list), own icon; gate waits for the hello's pongmre
- 752fbb7fdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- 38bdd5e4deploy.sh: never send .git or .gitignore to Byrodinmre
- f12fa1bcState of 2026-09-27, before the move to gitoriamre