gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf431bdf8f431bdf8notes mission 011: notes on the layouts theme (ListFirst shell), styles cut, check-theme gate, E2E extended; reportmref431bdf8/plugins/mpackdb/README.md

2.7 KB

  1. # `hl:mpackdb` — the MessagePack file database
  2. A document store in plain files. Server realm. The class surface and its
  3. generated API docs live in `MPackDB.hl` and `cursor.hl`
  4. (`projects/homepage/docs/mpackdb.md`).
  5. ```hybriel
  6. import { MPackDB } from 'hl:mpackdb'
  7. db = new MPackDB(file = 'users.db', primaryKey = '*id', indexes = ['!email', 'age'])
  8. id = db.put({ name = "Alice"; email = "[email protected]"; age = 30; }) \\ 1
  9. ```
  10. ## Primary keys
  11. | declaration | key | generated by `put()` |
  12. |---|---|---|
  13. | `*name` | a number | the table's counter: **1, 2, 3, …** |
  14. | `@name` | a string | a random 12-character id |
  15. | `name` | a string | nothing — the record must carry it |
  16. **A fresh `*id` table starts at 1** (ticket #4, the creator's ruling "start at
  17. 1"). The counter is stored as `nextId` in `<base>.meta.json`, and an existing
  18. table keeps counting from its stored value. A table written before this rule
  19. therefore goes on from wherever it was, and its record 0 remains record 0.
  20. A record put with an explicit key takes that key if it is free, 0 included.
  21. ## One open table per process (ticket #110)
  22. Within one process, a table path has **one** open table, shared by every
  23. `open()` — another module instance, another realm, it doesn't matter, they
  24. all get the same handle. The file is never compacted or rewritten while a
  25. handle on it is live; compaction happens only when asked for explicitly
  26. (`compactNow()` / `#handle.compact()`) or when the **last** handle on that
  27. path closes. A second `open()` of an already-open table ignores its own
  28. `primaryKey`/`indexes`/`compact` arguments — the schema was fixed by whoever
  29. opened it first.
  30. This matters because compaction rewrites `<base>.mpack` and shifts every
  31. record after the first tombstone to a new offset. Before this rule, a second
  32. `open()` from anywhere in the process ran its own compact-on-open (ticket
  33. #21) against the same file, and the first handle's already-looked-up offsets
  34. went stale under it — reads through the first handle then missed or
  35. misread records until something compacted again. Related: ticket #21
  36. ("opening a table rewrote its files").
  37. ## Compatibility with the JS mpackdb
  38. The on-disk format is the JS mpackdb 1.0.7 format: `<base>.mpack`,
  39. `<base>.meta.json`, one `<base>.<field>.txt` per index, `<base>.idxstate.json`
  40. and the `<base>.lock` protocol. Either side reads and changes the other's
  41. files. The first id is not part of the format; `nextId` is. Therefore:
  42. - a table the JS mpackdb created carries `nextId` and keeps its sequence here,
  43. even when that sequence started at 0;
  44. - a table Hybriel created carries `nextId` too, and the JS mpackdb continues it;
  45. - the one divergence is a table with **no** `.meta.json` yet: Hybriel's first
  46. id is 1, the JS mpackdb's is 0.
  47. The other documented divergences are listed at the top of `engine.zig`.

Branches

Latest commits

  • f431bdf8notes mission 011: notes on the layouts theme (ListFirst shell), styles cut, check-theme gate, E2E extended; reportmre
  • 1a8603d1notes mission 011 WIP: deploy.sh gate summary also matches check-theme, browser.mjs logout via the user menumre
  • dae2e508notes mission 011 WIP: theme dbe3de7, shell on AppHeader/MainMenu/UserMenu/Sidebar + ListFirst, styles cut to the app's own, check-theme gate, e2e auditmre
  • fd36da27notes mission 010: the note editor is the Hybriel MdEditor block (components.hybriel 1442e58, verbatim); md-editor.js, its route, script tag and offlineFiles retired; gate 66/0, realdata-offline 12/0, round-trip and Chrome E2E tests; report 010mre
  • efa92170notes tests/identkit.mjs: refuse a taken ident port, cold-wait deadline, emit, identities; mission 009 reportmre
  • f3dec0f1Merge branch 'w7'mre
  • d1cf966dre-vendor hybriel 97bcf128: offlineFiles for the editor script, 44 px taps, 390 px offline checks, mission 008mre
  • 4a610a21paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • eeaea980report 007: say which runs included the removed checkmre
  • 8a8ad9banotes mission 007: report, LOG, STATUSmre
  • 2cce9c96code order: plain declarations where never reassigned (letcount 0 never); gate: scan every IndexedDB at log-out, soft mode for old-code runs, drop a check that could not failmre
  • 7f6a4090README: offline in Hybriel (hl:web offline, continuation, known md-editor gap); gate waits report instead of crash; realdata-offline checkmre
  • 632223f2notes#4: delete notes-offline.js and sw.js (hl:web's generated worker and kept state replace them)mre
  • 52a2acadgate: offline checks on hl:web's worker/queue, Chrome offline via CDP (reload offline first), one-offline conflict, log-out forgets the kept copymre
  • e5785b03notes#4: the notes page in Hybriel — hl:web offline = [Notes], queued faces notesPut/notesDrop, push notesChanged, value-form notesPull on a tick; notes-offline.js/sw.js no longer loaded or routedmre
  • 510aff75notes#4: server continues a run of saves of one login (by + since), loser keeps writing into its copy; notesFor listmre
  • 0176c4b5mission brief 007mre
  • 06cfa870notes mission 006: re-vendor hybriel 0f396652 (static), reportmre
  • 6c07bd91mission brief w6mre
  • cf64d3d5notes mission 005: stopped at a Hybriel gap (for list repainted during hl:web boot throws, rowKidless); report, LOG, STATUSmre