@eloxiv/cli 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/AgentSkills.d.ts +51 -0
  4. package/dist/AgentSkills.d.ts.map +1 -0
  5. package/dist/AgentSkills.js +264 -0
  6. package/dist/AgentSkills.js.map +1 -0
  7. package/dist/AgentWeb.d.ts +83 -0
  8. package/dist/AgentWeb.d.ts.map +1 -0
  9. package/dist/AgentWeb.js +436 -0
  10. package/dist/AgentWeb.js.map +1 -0
  11. package/dist/App.d.ts +213 -0
  12. package/dist/App.d.ts.map +1 -0
  13. package/dist/App.js +357 -0
  14. package/dist/App.js.map +1 -0
  15. package/dist/Blueprint.d.ts +47 -0
  16. package/dist/Blueprint.d.ts.map +1 -0
  17. package/dist/Blueprint.js +241 -0
  18. package/dist/Blueprint.js.map +1 -0
  19. package/dist/Brand.d.ts +42 -0
  20. package/dist/Brand.d.ts.map +1 -0
  21. package/dist/Brand.js +370 -0
  22. package/dist/Brand.js.map +1 -0
  23. package/dist/Changelog.d.ts +22 -0
  24. package/dist/Changelog.d.ts.map +1 -0
  25. package/dist/Changelog.js +117 -0
  26. package/dist/Changelog.js.map +1 -0
  27. package/dist/Cli.d.ts +17 -0
  28. package/dist/Cli.d.ts.map +1 -0
  29. package/dist/Cli.js +810 -0
  30. package/dist/Cli.js.map +1 -0
  31. package/dist/DbAdmin.d.ts +18 -0
  32. package/dist/DbAdmin.d.ts.map +1 -0
  33. package/dist/DbAdmin.js +91 -0
  34. package/dist/DbAdmin.js.map +1 -0
  35. package/dist/Dependencies.d.ts +53 -0
  36. package/dist/Dependencies.d.ts.map +1 -0
  37. package/dist/Dependencies.js +132 -0
  38. package/dist/Dependencies.js.map +1 -0
  39. package/dist/Deploy.d.ts +39 -0
  40. package/dist/Deploy.d.ts.map +1 -0
  41. package/dist/Deploy.js +458 -0
  42. package/dist/Deploy.js.map +1 -0
  43. package/dist/Docs.d.ts +71 -0
  44. package/dist/Docs.d.ts.map +1 -0
  45. package/dist/Docs.js +240 -0
  46. package/dist/Docs.js.map +1 -0
  47. package/dist/Doctor.d.ts +56 -0
  48. package/dist/Doctor.d.ts.map +1 -0
  49. package/dist/Doctor.js +368 -0
  50. package/dist/Doctor.js.map +1 -0
  51. package/dist/Dossier.d.ts +23 -0
  52. package/dist/Dossier.d.ts.map +1 -0
  53. package/dist/Dossier.js +92 -0
  54. package/dist/Dossier.js.map +1 -0
  55. package/dist/Emit.d.ts +26 -0
  56. package/dist/Emit.d.ts.map +1 -0
  57. package/dist/Emit.js +51 -0
  58. package/dist/Emit.js.map +1 -0
  59. package/dist/Errors.d.ts +26 -0
  60. package/dist/Errors.d.ts.map +1 -0
  61. package/dist/Errors.js +17 -0
  62. package/dist/Errors.js.map +1 -0
  63. package/dist/Evals.d.ts +52 -0
  64. package/dist/Evals.d.ts.map +1 -0
  65. package/dist/Evals.js +126 -0
  66. package/dist/Evals.js.map +1 -0
  67. package/dist/Files.d.ts +47 -0
  68. package/dist/Files.d.ts.map +1 -0
  69. package/dist/Files.js +145 -0
  70. package/dist/Files.js.map +1 -0
  71. package/dist/Generate.d.ts +80 -0
  72. package/dist/Generate.d.ts.map +1 -0
  73. package/dist/Generate.js +310 -0
  74. package/dist/Generate.js.map +1 -0
  75. package/dist/Guards.d.ts +45 -0
  76. package/dist/Guards.d.ts.map +1 -0
  77. package/dist/Guards.js +530 -0
  78. package/dist/Guards.js.map +1 -0
  79. package/dist/Inspect.d.ts +125 -0
  80. package/dist/Inspect.d.ts.map +1 -0
  81. package/dist/Inspect.js +270 -0
  82. package/dist/Inspect.js.map +1 -0
  83. package/dist/Keychain.d.ts +57 -0
  84. package/dist/Keychain.d.ts.map +1 -0
  85. package/dist/Keychain.js +73 -0
  86. package/dist/Keychain.js.map +1 -0
  87. package/dist/Lock.d.ts +13 -0
  88. package/dist/Lock.d.ts.map +1 -0
  89. package/dist/Lock.js +145 -0
  90. package/dist/Lock.js.map +1 -0
  91. package/dist/Mcp.d.ts +91 -0
  92. package/dist/Mcp.d.ts.map +1 -0
  93. package/dist/Mcp.js +128 -0
  94. package/dist/Mcp.js.map +1 -0
  95. package/dist/Merge.d.ts +18 -0
  96. package/dist/Merge.d.ts.map +1 -0
  97. package/dist/Merge.js +43 -0
  98. package/dist/Merge.js.map +1 -0
  99. package/dist/Migrate.d.ts +78 -0
  100. package/dist/Migrate.d.ts.map +1 -0
  101. package/dist/Migrate.js +288 -0
  102. package/dist/Migrate.js.map +1 -0
  103. package/dist/Plugins.d.ts +36 -0
  104. package/dist/Plugins.d.ts.map +1 -0
  105. package/dist/Plugins.js +304 -0
  106. package/dist/Plugins.js.map +1 -0
  107. package/dist/Postgres.d.ts +73 -0
  108. package/dist/Postgres.d.ts.map +1 -0
  109. package/dist/Postgres.js +294 -0
  110. package/dist/Postgres.js.map +1 -0
  111. package/dist/Publish.d.ts +23 -0
  112. package/dist/Publish.d.ts.map +1 -0
  113. package/dist/Publish.js +59 -0
  114. package/dist/Publish.js.map +1 -0
  115. package/dist/Registry.d.ts +539 -0
  116. package/dist/Registry.d.ts.map +1 -0
  117. package/dist/Registry.js +340 -0
  118. package/dist/Registry.js.map +1 -0
  119. package/dist/Remote.d.ts +90 -0
  120. package/dist/Remote.d.ts.map +1 -0
  121. package/dist/Remote.js +1006 -0
  122. package/dist/Remote.js.map +1 -0
  123. package/dist/Run.d.ts +120 -0
  124. package/dist/Run.d.ts.map +1 -0
  125. package/dist/Run.js +477 -0
  126. package/dist/Run.js.map +1 -0
  127. package/dist/SyncGen.d.ts +118 -0
  128. package/dist/SyncGen.d.ts.map +1 -0
  129. package/dist/SyncGen.js +392 -0
  130. package/dist/SyncGen.js.map +1 -0
  131. package/dist/Update.d.ts +301 -0
  132. package/dist/Update.d.ts.map +1 -0
  133. package/dist/Update.js +627 -0
  134. package/dist/Update.js.map +1 -0
  135. package/dist/bin.d.ts +3 -0
  136. package/dist/bin.d.ts.map +1 -0
  137. package/dist/bin.js +42 -0
  138. package/dist/bin.js.map +1 -0
  139. package/dist/docs/backlog.md +56 -0
  140. package/dist/docs/ci.md +277 -0
  141. package/dist/docs/cli.md +696 -0
  142. package/dist/docs/connectors/google.md +115 -0
  143. package/dist/docs/connectors/http-openapi.md +7 -0
  144. package/dist/docs/connectors/mcp.md +8 -0
  145. package/dist/docs/connectors/microsoft-graph.md +75 -0
  146. package/dist/docs/connectors/openai.md +25 -0
  147. package/dist/docs/connectors/slack.md +162 -0
  148. package/dist/docs/connectors/workos.md +39 -0
  149. package/dist/docs/contracts/README.md +173 -0
  150. package/dist/docs/contracts/action-consent.md +92 -0
  151. package/dist/docs/contracts/action-registry.md +85 -0
  152. package/dist/docs/contracts/actor.md +100 -0
  153. package/dist/docs/contracts/agent-resources.md +90 -0
  154. package/dist/docs/contracts/agent-runtime.md +257 -0
  155. package/dist/docs/contracts/approvals.md +126 -0
  156. package/dist/docs/contracts/audit.md +75 -0
  157. package/dist/docs/contracts/auth-provider.md +74 -0
  158. package/dist/docs/contracts/calendar-provider.md +46 -0
  159. package/dist/docs/contracts/client-sdk.md +245 -0
  160. package/dist/docs/contracts/collab-document.md +151 -0
  161. package/dist/docs/contracts/command.md +44 -0
  162. package/dist/docs/contracts/connections.md +235 -0
  163. package/dist/docs/contracts/context-accounting.md +50 -0
  164. package/dist/docs/contracts/daemon.md +243 -0
  165. package/dist/docs/contracts/db-tx.md +53 -0
  166. package/dist/docs/contracts/delegation.md +68 -0
  167. package/dist/docs/contracts/device-control.md +103 -0
  168. package/dist/docs/contracts/directory-provider.md +36 -0
  169. package/dist/docs/contracts/directory.md +161 -0
  170. package/dist/docs/contracts/document-source.md +33 -0
  171. package/dist/docs/contracts/files.md +115 -0
  172. package/dist/docs/contracts/flags.md +83 -0
  173. package/dist/docs/contracts/host.md +68 -0
  174. package/dist/docs/contracts/http-api.md +43 -0
  175. package/dist/docs/contracts/ingestion.md +130 -0
  176. package/dist/docs/contracts/ingress.md +141 -0
  177. package/dist/docs/contracts/invocation.md +260 -0
  178. package/dist/docs/contracts/local-client.md +108 -0
  179. package/dist/docs/contracts/locale.md +56 -0
  180. package/dist/docs/contracts/machine-identity.md +117 -0
  181. package/dist/docs/contracts/mail-provider.md +49 -0
  182. package/dist/docs/contracts/memory.md +53 -0
  183. package/dist/docs/contracts/messaging.md +40 -0
  184. package/dist/docs/contracts/metering.md +139 -0
  185. package/dist/docs/contracts/model-provider.md +84 -0
  186. package/dist/docs/contracts/module-manifest.md +213 -0
  187. package/dist/docs/contracts/notification-channel.md +90 -0
  188. package/dist/docs/contracts/notifications.md +123 -0
  189. package/dist/docs/contracts/outbox.md +80 -0
  190. package/dist/docs/contracts/privacy.md +110 -0
  191. package/dist/docs/contracts/progress.md +52 -0
  192. package/dist/docs/contracts/query-surface.md +108 -0
  193. package/dist/docs/contracts/readiness.md +63 -0
  194. package/dist/docs/contracts/release.md +142 -0
  195. package/dist/docs/contracts/result-rendering.md +61 -0
  196. package/dist/docs/contracts/sandbox.md +186 -0
  197. package/dist/docs/contracts/scheduler.md +148 -0
  198. package/dist/docs/contracts/screen-context.md +81 -0
  199. package/dist/docs/contracts/search.md +120 -0
  200. package/dist/docs/contracts/secrets.md +74 -0
  201. package/dist/docs/contracts/settings.md +109 -0
  202. package/dist/docs/contracts/sharing.md +77 -0
  203. package/dist/docs/contracts/slot.md +48 -0
  204. package/dist/docs/contracts/space.md +67 -0
  205. package/dist/docs/contracts/storage-adapter.md +45 -0
  206. package/dist/docs/contracts/storage-backend.md +56 -0
  207. package/dist/docs/contracts/sync.md +213 -0
  208. package/dist/docs/contracts/telemetry.md +80 -0
  209. package/dist/docs/contracts/theme-tokens.md +50 -0
  210. package/dist/docs/contracts/tool-source.md +58 -0
  211. package/dist/docs/contracts/versioning.md +99 -0
  212. package/dist/docs/contracts/view.md +65 -0
  213. package/dist/docs/contracts/work-items.md +99 -0
  214. package/dist/docs/contracts/workflow.md +82 -0
  215. package/dist/docs/decisions.md +163 -0
  216. package/dist/docs/example-app.md +192 -0
  217. package/dist/docs/getting-started.md +927 -0
  218. package/dist/docs/goal.md +54 -0
  219. package/dist/docs/parity.md +29 -0
  220. package/dist/docs/performance.md +129 -0
  221. package/dist/docs/registry/README.md +74 -0
  222. package/dist/docs/registry/app.md +38 -0
  223. package/dist/docs/registry/approvals-ui-foldkit.md +28 -0
  224. package/dist/docs/registry/calendar-ui-foldkit.md +27 -0
  225. package/dist/docs/registry/calendar.md +35 -0
  226. package/dist/docs/registry/chat-ui-foldkit.md +30 -0
  227. package/dist/docs/registry/desktop-rune.md +49 -0
  228. package/dist/docs/registry/desktop.md +32 -0
  229. package/dist/docs/registry/eloxiv-action.md +25 -0
  230. package/dist/docs/registry/eloxiv-connector.md +25 -0
  231. package/dist/docs/registry/eloxiv-module.md +25 -0
  232. package/dist/docs/registry/eloxiv-policy.md +25 -0
  233. package/dist/docs/registry/eloxiv-view.md +25 -0
  234. package/dist/docs/registry/hello-ui-foldkit.md +29 -0
  235. package/dist/docs/registry/hello.md +39 -0
  236. package/dist/docs/registry/home-ui-foldkit.md +27 -0
  237. package/dist/docs/registry/home.md +29 -0
  238. package/dist/docs/registry/inbox-ui-foldkit.md +27 -0
  239. package/dist/docs/registry/mail-ui-foldkit.md +27 -0
  240. package/dist/docs/registry/mail.md +34 -0
  241. package/dist/docs/registry/meeting-prep.md +26 -0
  242. package/dist/docs/registry/members-ui-foldkit.md +28 -0
  243. package/dist/docs/registry/mobile.md +37 -0
  244. package/dist/docs/registry/notes-ui-foldkit.md +27 -0
  245. package/dist/docs/registry/notes.md +26 -0
  246. package/dist/docs/registry/people-ui-foldkit.md +28 -0
  247. package/dist/docs/registry/people.md +38 -0
  248. package/dist/docs/registry/shell-foldkit.md +34 -0
  249. package/dist/docs/registry/theme.md +25 -0
  250. package/dist/docs/registry/ui-conformance.md +30 -0
  251. package/dist/docs/release.md +100 -0
  252. package/dist/docs/scaffold.md +826 -0
  253. package/dist/docs/security/threat-model.md +299 -0
  254. package/dist/docs/upstream/zero-cache-socket-handoff.md +105 -0
  255. package/dist/index.d.ts +8 -0
  256. package/dist/index.d.ts.map +1 -0
  257. package/dist/index.js +8 -0
  258. package/dist/index.js.map +1 -0
  259. package/package.json +48 -3
  260. package/src/AgentSkills.ts +329 -0
  261. package/src/AgentWeb.ts +507 -0
  262. package/src/App.ts +435 -0
  263. package/src/Blueprint.ts +276 -0
  264. package/src/Brand.ts +415 -0
  265. package/src/Changelog.ts +136 -0
  266. package/src/Cli.ts +1458 -0
  267. package/src/DbAdmin.ts +115 -0
  268. package/src/Dependencies.ts +170 -0
  269. package/src/Deploy.ts +563 -0
  270. package/src/Docs.ts +309 -0
  271. package/src/Doctor.ts +424 -0
  272. package/src/Dossier.ts +148 -0
  273. package/src/Emit.ts +68 -0
  274. package/src/Errors.ts +18 -0
  275. package/src/Evals.ts +153 -0
  276. package/src/Files.ts +152 -0
  277. package/src/Generate.ts +402 -0
  278. package/src/Guards.ts +541 -0
  279. package/src/Inspect.ts +358 -0
  280. package/src/Keychain.ts +107 -0
  281. package/src/Lock.ts +174 -0
  282. package/src/Mcp.ts +159 -0
  283. package/src/Merge.ts +70 -0
  284. package/src/Migrate.ts +331 -0
  285. package/src/Plugins.ts +347 -0
  286. package/src/Postgres.ts +353 -0
  287. package/src/Publish.ts +64 -0
  288. package/src/Registry.ts +405 -0
  289. package/src/Remote.ts +1158 -0
  290. package/src/Run.ts +541 -0
  291. package/src/SyncGen.ts +570 -0
  292. package/src/Update.ts +873 -0
  293. package/src/bin.ts +46 -0
  294. package/src/index.ts +7 -0
@@ -0,0 +1,826 @@
1
+ # Walking skeleton
2
+
3
+ Status of Eloxiv's walking skeleton as of 2026-11-02 (revised the same day after five rounds of independent review: see "Review fixes"; accepted limits are in [backlog.md](backlog.md)), updated through 2026-11-04 for the full build so far (the manifest and directory, durable work, registry updates, the inbox, machine identity and ingress, release, the query surface, settings and flags, the agent, sharing, connections and connectors, the daemon and devices, the desktop and React Native CI lanes, and setup's owner-session migrations, fail-closed modules and recorded security state; progress is recorded in [progress.md](progress.md)): what exists, how to run it, where things live, what is minimal or stubbed, the measured baselines, the spike outcomes and every known gap. Read [decisions.md](decisions.md) first; this document does not change it.
4
+
5
+ The skeleton has no product behaviour. It proves that every building block exists on its chosen technology and is wired end to end, so the next agent adds features to proven wiring.
6
+
7
+ ## Quick start
8
+
9
+ ```sh
10
+ mise install # Node 24.22.2, Bun 1.4.4, pnpm 10.34.9, PostgreSQL 17.11, Rust 1.99.1
11
+ mise run install # pnpm install --frozen-lockfile
12
+ pnpm exec playwright install chromium # once, for the browser tests
13
+ mise run dev # PostgreSQL, kernel (:4100), zero-cache (:4848), shell (:5173)
14
+ ```
15
+
16
+ Sign in at <http://localhost:5173> as `alice@example.com` or `bob@example.com` with password `eloxiv-dev-password` (organisation `acme`; Alice also belongs to `globex`, and the header's organisation switcher moves her between them), open **Hello** and greet. A second browser signed in as the other user sees org-visible greetings appear; private ones stay with their owner.
17
+
18
+ | Task | What it runs |
19
+ | --- | --- |
20
+ | `mise run dev` | [`tools/dev/src/dev.ts`](../tools/dev/src/dev.ts): starts PostgreSQL, the kernel (which runs the app's `setup` and `seed` first, in the same process: `server/main.ts prepare-and-serve`), zero-cache and the shell (its dependencies pre-bundled by `vite optimize` in a short-lived, lower-priority process first, so the dev server does not hold the bundler's memory; Rolldown's allocator told to return freed memory, `MIMALLOC_PURGE_DELAY=0`), and prints when each was ready. Defaults to `examples/hello-app`; `ELOXIV_APP_DIR` picks another app, `ELOXIV_RUNTIME=node` runs the kernel on Node, `--no-shell` skips Vite. Before zero-cache starts it names the database's inactive replication slots and the WAL each holds back, in one line, and drops none (a slot nobody reads holds back WAL without end; `eloxiv doctor` gives the command to drop one) |
21
+ | `mise run check` | The full check, as CI runs it: `lint` (oxfmt, Oxlint type-aware, fallow), `typecheck`, `build`, `test`, `bench` |
22
+ | `mise run audit` | `fallow audit` of the branch's changes, with its base-snapshot cache in `.eloxiv/tmp` (see "Tests leave nothing behind") |
23
+ | `mise run test` | [`tools/scripts/test.sh`](../tools/scripts/test.sh): every Vitest project, then Playwright (`ELOXIV_SKIP_E2E=1` skips the browser; `ELOXIV_E2E_KERNEL_PORT`, `ELOXIV_E2E_ZERO_PORT`, `ELOXIV_E2E_SHELL_PORT` and `ELOXIV_E2E_DATABASE` move the suite off its default ports 4200, 4858, 5183 and database `eloxiv_e2e`, so several checkouts can run it at once) |
24
+ | `mise run bench` | [`tools/scripts/bench.sh`](../tools/scripts/bench.sh): the browser benchmarks, then [`bench/src/run.ts`](../bench/src/run.ts); fails on a budget breach. The benchmarks that start their own system use the e2e ports (and their overrides) and drop their databases afterwards; on CI it first prints an environment snapshot ([`env-snapshot.sh`](../tools/scripts/env-snapshot.sh)) |
25
+ | `mise run db:start` / `db:stop` / `db:reset` | [`tools/scripts/pg.sh`](../tools/scripts/pg.sh): the local cluster in `.eloxiv/pg` |
26
+ | `tools/scripts/neon-emulate.sh` | A cluster (give it its own `PGDATA`/`PGPORT`) with Neon's privilege model ([`neon-emulate.sql`](../tools/scripts/neon-emulate.sql)); then `ELOXIV_TEST_ADMIN_URL=postgres://neondb_owner:neondb_owner@localhost:<port>/neondb ELOXIV_DATABASE_ROLE_PASSWORDS=plaintext tools/scripts/test.sh <files>` runs tests with no superuser in the app's path. [`neon-branch.ts`](../tools/scripts/neon-branch.ts) makes and deletes a real Neon branch for the live job ([Release](contracts/release.md#database-hosts)) |
27
+ | `pnpm eloxiv <command>` | The CLI from source |
28
+
29
+ `ELOXIV_RUNTIME=bun|node` selects the runtime for every task (default Bun). Both pass `mise run check` on this machine.
30
+
31
+ ## What exists
32
+
33
+ ### Toolchain and repository
34
+
35
+ - **mise** pins every tool ([`mise.toml`](../mise.toml)). PostgreSQL comes from prebuilt, relocatable binaries through mise's GitHub backend (`github:theseus-rs/postgresql-binaries`), with `wal_level=logical` written by `pg.sh` into `.eloxiv/pg/data/eloxiv.conf` on every start. No containers.
36
+ - **pnpm workspaces** ([`pnpm-workspace.yaml`](../pnpm-workspace.yaml)) with exact versions and `linkWorkspacePackages: true`, so an app's `"@eloxiv/kernel": "^0.1.0"` (the range registry items name) links the workspace package where the published version would resolve. **Turborepo** builds and typechecks ([`turbo.json`](../turbo.json)).
37
+ - **TypeScript 7.0.2** (the native compiler) with the required strict flags plus `erasableSyntaxOnly` (Node's type stripping) in [`tsconfig.base.json`](../tsconfig.base.json).
38
+ - **Source condition:** workspace packages export `src/*.ts` under the custom condition `@eloxiv/source` and `dist` otherwise. Development, tests and benchmarks run TypeScript directly: `NODE_OPTIONS=--conditions=@eloxiv/source` is set by mise; Bun gets `--conditions=@eloxiv/source` explicitly; Vitest and Vite set `resolve.conditions`; `tsc` uses `customConditions`. Published packages resolve `dist`: their `publishConfig.exports` (what npm gets) drop the condition ([release.md](release.md)).
39
+ - **Property tests are deterministic.** Every fast-check property runs from one fixed seed (`test/property-seed.ts` in the kernel, contracts and testing projects, set before each test file), so every run, CI included, generates the same cases and a failure replays exactly. fast-check reports a failing case's seed and path; `ELOXIV_PROPERTY_SEED=<seed>` replays it or explores other cases (the sync property also takes `ELOXIV_SYNC_PROPERTY_SEED` and `ELOXIV_SYNC_PROPERTY_PATH`). Cases once found hard are fixed examples of their property, run first every time (the sync property's `fixtures/prop/planner-case.ts` and `or-case.ts`).
40
+ - **Oxlint** type-aware ([`.oxlintrc.json`](../.oxlintrc.json); `--disable-nested-config` because `repos/agent-native` has its own config), **oxfmt** ([`.oxfmtrc.json`](../.oxfmtrc.json); generated files are excluded), **Vitest 5** projects ([`vitest.config.ts`](../vitest.config.ts)), **Playwright** ([`playwright.config.ts`](../playwright.config.ts)).
41
+ - **fallow** ([`.fallowrc.json`](../.fallowrc.json)): zone boundaries between packages and app layers, and two rule packs: [`tools/fallow/portable-client.json`](../tools/fallow/portable-client.json) bans Node built-ins, Node-only packages, UI bindings (React, Foldkit, StyleX) and DOM/Node global calls in the client SDK (its React and Foldkit entries, `packages/client/src/React.ts` and `Foldkit.ts`, are zones of their own, which the root may not import), and [`tools/fallow/eloxiv-sync.json`](../tools/fallow/eloxiv-sync.json) bans `@rocicorp/zero` (with its subpaths, type-only imports and re-exports) in modules, the shells (React and Foldkit), the themes, the desktop host, app composition and the app server: they reach sync through `@eloxiv/client` (decision 9; proven by `tools/done/test/one-definition.test.ts`, which runs fallow on a violating fixture). Every file under an app's root is in a zone the rule covers (`app-other` for helpers and connectors). Fallow does not see dynamic `import()` or `require()`, so the criterion 19 gate also walks the import graph from every file of each app (`tools/done/src/syncImports.ts`, every load form; relative imports followed anywhere in the repository with TypeScript's `.js`/`.cjs`/`.mjs` substitution, dependency aliases resolved, and workspace packages entered through every condition of their `exports` and checked like the app's code) and fails if anything reaches `@rocicorp/zero` other than through the public entry points of the packages that own it, or loads a computed specifier. Above the graph, a package rule (`tools/done/src/syncPackages.ts`) allows only `@eloxiv/client`, `@eloxiv/kernel`, `@eloxiv/testing`, `@eloxiv/cli` and the workspace root to depend on `@rocicorp/zero`: every other workspace package's `package.json` (aliases resolved to their real names) and its closure in `pnpm-lock.yaml` (stopping at those packages) must not reach it, so no workspace package can forward the engine to an app. `mise run lint` runs `fallow architecture` (boundaries, cycles, policy). fallow's dead-code report is not gated yet.
42
+ - **Releases** ([release.md](release.md)): the eight public `@eloxiv/*` packages (the seven code packages and `@eloxiv/registry`, the registry's built items, which an installed CLI reads by default) are published to npm under MIT, at one version, by [`.github/workflows/release.yml`](../.github/workflows/release.yml) on a pushed `v*` tag with npm trusted publishing (provenance once the repository is public); [`tools/done/src/release.ts`](../tools/done/src/release.ts) sets the version (`mise run release:version`), checks the metadata, packs and verifies the tarballs. **Changesets** ([`.changeset/config.json`](../.changeset/config.json)) keeps them in one fixed group for versions and changelogs; it does not publish.
43
+ - **CI** ([`.github/workflows/ci.yml`](../.github/workflows/ci.yml); tiers and the plan job in [ci.md](ci.md)): on every push to a topic branch's pull request, lint, typecheck and the affected tests on Bun and on Node; on the merge tier, `mise run check` on a Bun and a Node matrix; `actions/checkout`, `jdx/mise-action` and `actions/upload-artifact` pinned by commit SHA. Beside it, the desktop lanes (Linux, macOS, Windows) and the React Native guard: see "Desktop and React Native in CI"; `live connector (google)`, the google connector's kits against real Google with the kernel on Bun and then on Node when the `ELOXIV_GOOGLE_TEST_*` secrets are present (skipped with a notice otherwise, as for a fork's pull request; one run at a time, concurrency group `live-connector-google`; docs/connectors/google.md). Two workflows of their own never run on pull requests, only by hand or on pushes to main and build/main that change what they exercise (slack live also nightly): `model live` ([`model-live.yml`](../.github/workflows/model-live.yml): the agent on a real model and one run of the skill evals, on Bun and on Node, with `ELOXIV_MODEL_OPENAI_API_KEY`; docs/connectors/openai.md) and `slack live` ([`slack-live.yml`](../.github/workflows/slack-live.yml); docs/connectors/slack.md).
44
+
45
+ ### Packages
46
+
47
+ | Package | What it is |
48
+ | --- | --- |
49
+ | [`@eloxiv/contracts`](../packages/contracts) | Effect Schema sources for language-neutral contracts: the standard error set, audit records, outbox events, actors, provenance and lockfile, daemon pairing; module, entity, action and event contracts; the RPC projection `toRpcGroup`. `@eloxiv/contracts/drizzle` is the TypeScript entity builder over Drizzle tables (`defineEntity`, decision 9: the table is the only declaration of a module's fields; the root stays Drizzle-free and the manifest publishes the language-neutral entity); `@eloxiv/contracts/devices` is the kernel-provided `devices` module's contract over its tables. `pnpm --filter @eloxiv/contracts emit` writes [`schema/*.json`](../packages/contracts/schema); a test keeps them current. `moduleToJson` emits a module manifest's declarative part |
50
+ | [`@eloxiv/kernel`](../packages/kernel) | The services, Effect 4 against platform abstractions (`effect` core, `@effect/platform-node`, `@effect/platform-bun`): registry, identity (Better Auth sessions, agent sessions, API tokens and OAuth access tokens), directory, policy (Cedar compiler), the approval stage (consent, then business approval), the inbox (work items, notifications and their channels, with system email over SMTP), invocation path, outbox dispatcher with dead letters, sharing (the `sharing` module: grants, links, access requests), durable work (workflows and the scheduler on Effect cluster), machine identity (an OAuth 2.1 authorisation server, API tokens, service principals), ingress (inbound webhooks), release (lease, one-transaction setup, snapshots) and readiness, Secrets (envelope encryption), Connections (consent, custody, refresh, 401 versus 403, the `connections` kernel module, the sync engine) and Metering's per-connection backpressure, the query surface, settings and flags, the platform services (Progress, Versioning's module versions, record history and agent edit groups (each agent run's record versions and document autosaves, reverted by message or back to the start of a chat), Telemetry with OTLP, Sentry and PostHog adapters, Privacy's consent and data-subject requests, ResultRendering), the agent (runtime, model providers, memory, delegation, context accounting, resources, budgets), the sandbox (QuickJS in WebAssembly) and MAKE (modules made at runtime: drafts, previews, approved installs, versions and rollbacks, run sandboxed), collaborative documents (the `collab` module: Yjs documents owned by records, their WebSocket transport, compaction), the surfaces, the Zero query endpoint, bootstrap and migrations; `runtime/node` and `runtime/bun` entries, and `runtime/resolve`, the resolve hook an app's `server/main.ts` installs on Node before it loads the kernel (its dependencies' relative imports resolved without Node's per-import package lookup) |
51
+ | [`@eloxiv/client`](../packages/client) | Headless SDK: typed action client (Effect RPC over fetch, with `orgId` and `clientVersion`), sign-in, `connectSync<S>` (Zero, typed by the app's generated schema: `SyncClient<AppSchema>`), and the sync API modules and UI use instead of Zero (decision 9): the query builder, named queries, schema builders and row types; React hooks and the provider in `@eloxiv/client/react`; the Foldkit bindings (the replica as a ManagedResource, live queries and connection state as Subscriptions, optimistic writes and action calls as Effects for Commands) in `@eloxiv/client/foldkit` (decision 10; [ClientSDK](contracts/client-sdk.md#ui-bindings)). `@eloxiv/client/sync` exports the kernel's sync tables, generated from the kernel modules' Drizzle tables (`KernelTables.gen.ts`): the share grants, the inbox tables (`inboxTables`, `inboxRelationships`, `inboxQueries`), the settings and flags tables (`platformTables`, `platformQueries`) the agent's conversations, messages, runs and queued messages (`agentTables`, `agentQueries`), app state entries and screen commands (`appStateTables`, `appStateQueries`), the spaces' grants and preferences (`spacesTables`, `spacesRelationships`, `spacesQueries`), and progress tasks and consent (`servicesTables`, `servicesQueries`). `@eloxiv/client/runtime` is the portable client core (`makeClientRuntime`, decision 14: session, organisation and generation, replica lifetime, live queries, optimistic writes, calls, teardown; [ClientSDK](contracts/client-sdk.md#the-client-core)), which the daemon serves as [LocalClient](contracts/local-client.md). `@eloxiv/client/storage` holds the replica's storage adapters ([StorageAdapter](contracts/storage-adapter.md): IndexedDB, SQLite over a synchronous binding, memory). The transport layer every HTTP request follows (`Transport.ts`, `Reader.ts`: a disabled-backend state, failure classes, a failure circuit, read batches over `POST /api/batch`, `send` with timeout, abort, keepalive and retries; [ClientSDK](contracts/client-sdk.md#transport)), polling, shared probes and tab identity (`Poll.ts`, `Tab.ts`), durable app state and the agent's screen commands (`AppState.ts`, over the kernel's `app_state` module; [ScreenContext](contracts/screen-context.md#durable-state-and-agent-commands)), WebMCP and client actions (`WebMcp.ts`), uploads (`Upload.ts`), preferences (`Preferences.ts`), skew recovery (`Skew.ts`), and the chat SDK's context staging, intents and labels (`Chat.ts`). It is the [ClientSDK](contracts/client-sdk.md) contract's implementation. Compiles with no DOM or Node types ([`web-globals.d.ts`](../packages/client/src/web-globals.d.ts)) |
52
+ | [`@eloxiv/shell-core`](../packages/shell-core) | The headless shell contracts, with no UI framework and no DOM: [View](contracts/view.md), [Slot](contracts/slot.md) and [Command](contracts/command.md) (`shellRegistry`: views by id and route, deep links, slot contributions in order, palette search), [Space](contracts/space.md) (`resolveSpaces`), [ScreenContext](contracts/screen-context.md) (`makeScreenContext`), [ThemeTokens](contracts/theme-tokens.md) (`themeCss`, `resolveTheme`, measured contrast), [Locale](contracts/locale.md) (`makeLocale` over a Paraglide JS catalog) the agent's screen commands (`screenCommandHandler`) and the [Host](contracts/host.md) interface; `@eloxiv/shell-core/web` is the web host (`webHost`) and the browser's side of the client SDK's tab identity, visibility and WebMCP (`webTabEnvironment`, `webVisibility`, `webModelContext`). The portable rule pack covers it as it covers the client |
53
+ | [`@eloxiv/testing`](../packages/testing) | `startKernel` (in-process kernel on a real database with overridable stages), `startSystem` (kernel and zero-cache as processes; `@eloxiv/testing/system` exports it and the other process helpers without loading the kernel), database helpers, the scripted model provider (multi-turn tool use decided from the prompt alone, with its own token count), the agent eval harness (`Evals.ts`), the decision-2 fixture tests, the conformance kits, and protocol fakes of Microsoft Graph, Google, Slack and a generic `acme` provider, an OTLP collector, Sentry's envelope endpoint and PostHog's capture endpoint, APNs (HTTP/2 over TLS with an in-memory test CA, `TestCa.ts`) and FCM HTTP v1 with its OAuth token endpoint (`@eloxiv/testing/fakes/*`) |
54
+ | [`@eloxiv/daemon`](../packages/daemon) | The device daemon ([Daemon](contracts/daemon.md), [DeviceControl](contracts/device-control.md)): pairing with the kernel (a code a signed-in person confirms), custody of the device credential (libsecret, Keychain, Credential Manager, or a 0600 file), persistent state, a loopback relay (`/relay/actions/<action>`, `/mcp`) with per-client authentication (host secret, local clients paired only with the host's approval and a 50-bit code under a global wrong-code lockout, per-turn harness tokens with an optional action scope; Host and Origin checks), Claude Code and Codex adapters and an ACP adapter (OpenCode, or a configured ACP agent; `Acp.ts`), only the Eloxiv tools unless a turn asks for workspace tools, the process group killed with the turn, and follow-up turns resuming a resumable turn's harness session; device commands (`Commands.ts`: `terminal.exec` and file operations confined to the workspace, browser and computer operations handed to a paired browser-extension or computer-use companion; each kind off unless `--allow-commands`), local terminals (`Terminals.ts`: a PTY on Bun, pipes on Node), capability reports and the host's push registration, the tools-only profile (`--tools-only`), a headless runner (`--headless`) that keeps a finished turn's result until the kernel takes it, and the commands `pair`, `status`, `unpair`, `approve-client`. `build:sidecar` compiles it with `bun build --compile` to `eloxiv-daemon-<target-triple>` (`--entry` and `--name` for an app's own sidecar); an app's sidecar composed with a `clientApp` serves [LocalClient](contracts/local-client.md) under `/client/v1` (decision 14; `Client.ts`: the person session from a desktop sign-in through its own callback, the replica in SQLite, the event stream) to the host and paired `desktop-app` clients; `@eloxiv/daemon/testing` has the fake harness; `@eloxiv/daemon/bin` (Bun) and `@eloxiv/daemon/bin-node` (Node) are its entry points, which the Daemon kit's runner starts as the package resolves them (the source in this repository, the compiled JavaScript when installed) |
55
+ | [`@eloxiv/cli`](../packages/cli) | `eloxiv` on Effect CLI ([docs/cli.md](cli.md)): `init`, `add`, `generate` (each module's sync tables from its Drizzle tables and entities, through drizzle-zero 0.21.0 behind Eloxiv's adapter `SyncGen.ts`, and the composition files), `diff`, `update` (three-way merge, `--continue`), `eject`, `restore`, `info`, `list`, `setup` (the app's server entry), `doctor`, `clean` (`Inspect.ts`, `Doctor.ts`); and against a running kernel, `login` (the OAuth device flow; tokens in the OS keychain, `Keychain.ts`), `logout`, `whoami`, `actions`, `call` (HTTP labelled `cli`), `agent` (one turn of the person's agent, followed over its event stream) and `mcp install|uninstall|status` (`Mcp.ts`: the kernel's `/mcp` in agent hosts' project files) |
56
+
57
+ The kernel's tables live in schema `eloxiv` ([`db/KernelSchema.ts`](../packages/kernel/src/db/KernelSchema.ts), migrations `0000` to `0044`): organisation, membership, the directory's roles, groups and permissions, sync_fact and sync_org (the live directory facts sync filters test), audit_log, idempotency_key, outbox, outbox_delivery, outbox_failure (failed and dead-lettered deliveries), approval, share_grant (grants to a user, group, organisation or link, with expiry), share_link (link token hashes) and share_redemption, agent_session, service_principal, api_token and the OAuth server's oauth_* tables, ingress_delivery, linked_identity and link_code, device, device_pairing and device_session (the Daemon contract; migration `0023_devices`), secret (envelope-encrypted secrets), connection, connection_flow, connection_cooldown, connection_usage and connection_sync (migration `0022_connections`), deployment_setting (settings' app- and module-level values a deployment administrator sets), file, file_part and storage_quota (the Files contract), record_source and search_document (Search's tracked tables and full-text index), search_embedding (hybrid search's vectors, migration `0111_search_embeddings`), privacy_visit (visitors' consent and attribution before sign-in, `0112_privacy_visits`), ingestion_item and ingestion_chunk (migration `0029_files_search_ingestion`), module_version and module_version_history (Versioning: installed versions and every change, written by setup), record_history (Versioning: append-only versions of history entities' records; migration `0030_platform_services`, which also makes the write log keep rows for those tables), privacy_step and privacy_pseudonym (Privacy's request bookkeeping), make_draft, make_version, make_installation, make_activity and make_call (MAKE's drafts, installed versions, the version each MAKE module runs, rate-limit activity and calls in flight; migration `0031_make`, with `eloxiv_ctx.transaction_writes()`), collab_document, collab_update, collab_version, collab_contribution and collab_rate, with the unlogged collab_presence and collab_change (CollabDocument: each record's merged snapshot and head, its append-only updates, checkpoints, who contributed, the rate window, live presence and wake-ups; migration `0035_collab`, which also makes `eloxiv.forget_record` delete a deleted record's document), invitation, org_domain and group metadata (Directory 1.2.0's invitations, claimed domains and `org_group.metadata`; migration `0085_directory_administration`), user_avatar (people's photos; migration `0086_user_avatars`), and the release bookkeeping created by setup itself ([`db/Bootstrap.ts`](../packages/kernel/src/db/Bootstrap.ts)): module_migration, release_lease, release_history, schema_snapshot, module_hardening (each module's hardening fingerprint and security state), and `eloxiv_setup.record_migration` (through which a module's owner session records its migrations); the kernel's own security state is in `eloxiv_release.kernel_state`, which only the setup role (a superuser, or on a managed host its administrative role) writes. Better Auth's tables live in schema `auth`. Durable work's records: workflow_execution (which, from `0070_run_outcomes`, records how each execution ended: `state`, a no-op's `outcome`, the failure's tag), workflow_step, schedule_state, schedule_run (every run, with its organisation from `0072_run_organisations`, who asked for one by hand, pseudonymised on their erasure in that organisation only, and when the scheduler settled it: failure streaks, owner alerts and auto-pause, [Scheduler](contracts/scheduler.md)) and scheduler_sweep (the sweeping kernel's heartbeat, for `scheduler.health`); members' event automations (runtime schedules on events that name their record, `scheduler/Automations.ts`, the kernel workflow `eloxiv.event-automation`) record their runs there too, keyed `schedule:<id>#event:<event id>`; `0071_retention` indexes what the kernel's `Retention` job prunes (settled outbox events, and audit records when `ELOXIV_AUDIT_RETENTION_DAYS` is set).
58
+
59
+ ### The invocation path
60
+
61
+ Every call, from every surface, goes through [`Invocation.invoke`](../packages/kernel/src/Invocation.ts):
62
+
63
+ 0. **Client version:** a write from a client that declares an older version (`x-eloxiv-client-version`, or on MCP an Eloxiv client's `initialize` `clientInfo.version`) than the app's minimum is refused with `ClientOutdated` on every surface, before anything else ([Release](contracts/release.md)).
64
+ 1. **Identity:** `Identity.authenticateCall(headers, surface)` resolves the credential in the `Authorization: Bearer` header (or the session cookie): a person's Better Auth session, an **agent session** the kernel issued for an agent acting for that person (`eloxiv_agent.<secret>`), an **API token**, or an **OAuth access token** whose audience is the surface's resource ([MachineIdentity](contracts/machine-identity.md)). Each resolves afresh to exactly one actor with the same fields (roles, groups, permissions), and the membership for the organisation (`x-eloxiv-org` picks one; an agent session or a machine credential acts only in its own). A machine credential's scope is checked next, then whether the surface offers the action at all (its `exposure`: the app's agent, MCP and the API each on its own, discovery rather than authorisation; [ActionRegistry](contracts/action-registry.md#exposure)). The path also decides the call's origin from the surface and credential alone, never a header: `agent` (agent tools, MCP, or an agent session on any surface), `person`, or `system` (an execution identity). Management operations (Directory, MachineIdentity, dead letters) and sync accept only a signed-in person (`Identity.authenticate`): API tokens, OAuth access tokens and agent sessions are refused there.
65
+ 2. **Policy:** the action's Cedar policy compiled for the actor; a constant `false`, or a policy the compiler cannot translate, denies before anything runs.
66
+ 3. **Consent, then business approval:** the `Approvals` stage. An agent-originated call to an action marked `consent` (by default the destructive ones) is held with `ConsentRequired` until the person approves it, bound to its exact input, optionally remembered for the agent session or always ([ActionConsent](contracts/action-consent.md)); then the app's and modules' approval rules hold matching calls with `ApprovalRequired` until an approver decides, and a kernel workflow runs the approved call once ([Approvals](contracts/approvals.md)). Both raise a work item and a notification for whoever must decide. `Approvals.requireFor([...])` remains for tests of the stage's position.
67
+ 4. **Idempotency:** keys are scoped by (organisation, user, action, key). The first call claims the key row and runs. A retry with the same input does **not** run again and does **not** return the original output: it returns a **receipt** of what the original call did (see "The action contract"), after the caller is authenticated as a member of the organisation and the action's policy is checked. A different input is `IdempotencyConflict`. The agent surface keys on the model's tool-call id.
68
+ 5. **Execute:** the kernel records the invocation context (actor, organisation, action) for the transaction, locks and authorises the action's declared targets, then runs the handler as the module's **runtime role** (`SET LOCAL ROLE`). The handler sees `ctx.origin`, and asks for work items and notifications through `ctx.workItems` and `ctx.notify` ([WorkItems](contracts/work-items.md), [Notifications](contracts/notifications.md)), applied after its writes are checked, in the same transaction. Postgres row-level security, generated from the compiled Cedar filters, checks the rows the handler reads or writes: the old row (`USING`) and the new row (`WITH CHECK`); a database refusal is `Forbidden`. The runtime role has plain DML on its own tables only (no `TRUNCATE`, DDL or triggers). Afterwards the kernel checks the write log against the action contract and refuses the call if the handler left a different role in place. With an idempotency key, it stores the call's receipt (see "The action contract"), never its output.
69
+ 6. **Audit:** a successful call's audit row commits with its transaction (with `affected`, `requested` and `completion` for targeted actions); every failure that reaches `invoke` (unknown action, invalid input, denial, consent or approval required, idempotency conflict, outdated client, handler failure, defects) is audited once after rollback. An output that does not match the action's schema fails the call inside its transaction, and every `ActionFailed` says what the call may have done (`effect`: `none`, or `unknown` after a direct provider change or a failure while committing; [Invocation](contracts/invocation.md#errors)). Every surface (RPC, HTTP, MCP, agent tools) passes raw input to `invoke`, which decodes it, so rejected input is audited on all four.
70
+ 7. **Outbox:** events emitted by the handler are written in the same transaction and `pg_notify` wakes the dispatcher. Delivery is **at-least-once**: each subscriber runs in its own savepoint as its module's role, together with its `outbox_delivery` row, so a subscriber's database effects commit exactly when its delivery is recorded and a subscriber that succeeded is not re-run; a failing subscriber (typed failure or defect) is rolled back to its savepoint and retried under its delivery policy (attempts, last error and next attempt persisted per subscriber in `eloxiv.outbox_failure`), without holding up other events or the event's other subscribers. When the policy is exhausted (by default after 20 attempts; never retried forever) the delivery is dead-lettered: kept with its last error, logged at error level, counted by Readiness, and listed for the organisation's administrators to retry or discard ([Outbox](contracts/outbox.md)). Event triggers are delivered and dead-lettered the same way, and so are the kernel's own reactions (`kernel:<id>`: starting and resuming approval workflows, delivering notifications through their channels). Subscribers get `ctx.workItems` and `ctx.notify` too, applied with their delivery. Effects outside the database can repeat: subscribers deduplicate on the event id. Deliveries are recorded per subscriber id, so subscriber ids are unique across the app (and never of the form `trigger:<id>`, which event triggers use), as are module names: the kernel refuses to start otherwise (nor may they take the form `kernel:<id>`).
71
+
72
+ ### The action contract
73
+
74
+ Every action has a `title`, what people see it called ("Send an email"): the kernel records it with each consent and approval request it holds (migrations `0003_title`), and the chat SDK, the Foldkit chat and approval screens, the Rune and Expo hosts and the kernel's notifications show it, never the action's id ([ModuleManifest](contracts/module-manifest.md) 1.6.0). Person-only actions are on no agent's tool list ([ActionRegistry](contracts/action-registry.md), "Person-only actions").
75
+
76
+ An action's manifest entry (`defineAction`) declares what it may change, and the kernel holds it to that:
77
+
78
+ - **`writes`**: the entity whose policy authorises the action. Rows the call inserts or updates must satisfy the action's compiled filter for their entity, old row and new row.
79
+ - **Declared entities only.** An action's policy reaches only the tables of the entities it declares (`writes`, `target`, and `actsOn` for secondary records such as a child it creates): on every other table its filter is FALSE, in row-level security and in the kernel's checks, so an action declaring no entity reads only what `read` allows. Startup refuses a policy that lets an action (or `read`) reach records not tied to the actor (by organisation, a user field, a sharing grant or one named user), unless the action is declared `organisationWide`, which confines it to the acting organisation.
80
+ - **`target: { entity, field }`**: the input field holding the record the action acts on, either one id or a list of ids (a target set). Targets are locked and authorised before the handler runs.
81
+ - **Exact (the default).** An action with a target must affect exactly what it declared: every declared target is inserted, updated or deleted, and no other row of the target entity is. Otherwise the call fails as `Forbidden` and rolls back, including when the handler reached another readable record through `UPDATE ... FROM`, a data-modifying CTE, or `INSERT ... ON CONFLICT DO UPDATE` (row-level security lets such an action's statements reach readable rows of its target entity precisely so the kernel sees them and refuses, instead of filtering them silently). Deleting is allowed only for declared targets. Inserting or updating a row that is not a declared target is refused at the statement by row-level security (`WITH CHECK ... eloxiv_ctx.is_target(...)`), before an `INSERT`'s conflict arbitration, so an undeclared `INSERT ... ON CONFLICT DO NOTHING` fails the same way whether or not some record already holds the key.
82
+ - **Identities are immutable.** Setup installs a key guard on every module table: an `UPDATE` that changes a primary key is refused (`Forbidden`) before referential checks run, except for the module's owner role in migrations. Setup refuses any other `BEFORE UPDATE` row trigger on module tables, so nothing can change a key after the guard. The write log and every check identify records by key, so a key change could otherwise move one record onto another's identity.
83
+ - **Best effort (`bestEffort: true`).** Declared explicitly, never inferred, and only with a target and an output containing `BestEffortFields`. Targets the caller may not act on are skipped silently (row-level security filters them). The kernel overwrites `affected`, `requested` and `completion` (`complete` or `partial`) in the output and writes them to the audit record. The guarantee covers only what the kernel generates: those completion fields and the replay receipt never say which targets were affected or skipped, although the counts reveal how many of the supplied ids the caller could act on. The rest of the output is the handler's, and the kernel does not inspect it, so a best-effort action's own output fields could still name the affected ids. Module authors must not put them there. Writing any undeclared row of the target entity still fails.
84
+ - **Rows outside the caller's sight, and constraints.** Rows the caller cannot read are filtered out of every statement's reads and writes. Postgres checks unique and foreign-key constraints across row-level security, so the kernel holds writes to one rule, failing closed: **a write's outcome may not depend on a record the caller cannot read**, but for the two stated limits below. Each channel is closed at the statement or at setup, for every action (exact, best effort or untargeted), its secondary entities and MAKE modules alike:
85
+ - *References.* Setup installs a reference guard (`eloxiv.guard_reference`, a `BEFORE INSERT OR UPDATE` row trigger) for every foreign key of a module table: a new or changed reference must name a record the writer can read under its row-level security. A missing record and an unreadable one are refused alike (`Forbidden`, the same message), before the referential check whose outcome would tell them apart. A foreign key must reference its parent's single-column primary key, which the key guard makes immutable; setup refuses one referencing any other key, whose change would fail only while a referencing record exists. The module's owner (migrations) is exempt; a reference with a null column is not checked, as the foreign key does not check it.
86
+ - *Other unique keys.* Setup refuses a unique key (constraint or index) other than a primary key, and an exclusion constraint, on an entity's table unless no action declares the entity (only migrations and subscribers write it, and no caller sees their outcome) or every row a writer can conflict on is one it can read: the key includes fields every declaring action confines new rows to the actor or the acting organisation, and the entity's read policy admits every record with those values (`uniqueKeyProblems` in [`Rls.ts`](../packages/kernel/src/policy/Rls.ts)). Only a key's own columns count (never its `INCLUDE` columns), and a column anchors it only where the index compares it as policies do (its type's default operator class, a deterministic collation). So `UNIQUE (org_id, user_id)` on a record every member reads is accepted; `UNIQUE (name)`, or `UNIQUE (org_id, name)` where members read only their own, is refused. The kernel's own modules (agent, devices, privacy) are exempt: kernel code whose handlers check the record a key names (a run's conversation) before writing.
87
+ - *Key changes* are refused before referential checks (above), and an exact action's undeclared inserts before conflict arbitration (above), so an exact action never meets a key it did not declare.
88
+
89
+ The stated limits (known gap 11):
90
+ - **A key the caller names.** An untargeted or best-effort action may insert a record under a key the caller chose (the normal create path, and a sync's provider-keyed upserts). Whether that key is free is then disclosed: a free key's insert succeeds, a held one cannot be made, whatever the error says, so no check inside the policy can hide it. What it discloses is only whether a record holds a key the caller names: with random keys, one it was given (a reference it can read, a record it could once read). Keys callers name across people should be derived with `recordKey` (organisation, user, entity and the caller's key, as optimistic inserts do), which meets only records the same caller derived; closing it in general needs keys namespaced per caller, a redesign of every create and of provider-keyed sync.
91
+ - **Deleting a record another record references** fails while the reference exists, whether or not the caller can read the referencing record (setup refuses referential actions that would rewrite or delete it, which would run outside row-level security). The failure is an `ActionFailed` that names neither the referencing record nor its table, so it discloses one fact: that some record refers to this one. Closing it needs deletes that cascade under the referencing records' own policies, or tombstones, a redesign.
92
+ - **Actions without a target** (creates, create-or-get) may insert and update rows that satisfy their filter; row-level security filters their updates (their receipt counts only the rows they wrote: known gap 11a), and they cannot delete.
93
+ - **Replays return receipts, never cached output.** With an idempotency key, the kernel stores only a receipt (format-versioned, `receipt_format`); the output is never cached. A replay (same actor, organisation, action, key and input) returns `{ kind: "replay", receipt }`. The receipt (`InvocationReceipt` in `@eloxiv/contracts`) holds only facts the caller already had, and the code enforces each one:
94
+ - `action`, the original `invocationId`, and `outcome: "succeeded"`;
95
+ - `targets`: the declared target ids **exactly as the caller supplied them** (deduplicated, in the caller's order). This applies whether the call updated or deleted them, and for best-effort actions it is the full requested list, never the affected subset;
96
+ - `created`: ids of records the call **inserted**, of the action's own (`writes`) entity, that **appeared in the original output**. All three conditions are checked: the record is in the write log as an insert, it still exists, and its id is a value in the encoded output. Updated records, secondary-entity records and inserts the output didn't name are never listed;
97
+ - `completion`: for best-effort actions only, the counts `affected`, `requested` and `complete` or `partial`. It is never a list of which targets were affected. For every other action it is `null`.
98
+ - `noop`: when the original output was a no-op outcome (`noOp(reason, evidence)`), that outcome, so work that runs again (a scheduled run's step after a crash) still records that the call did nothing on purpose;
99
+
100
+ It holds no entity field values, nothing the call read, no nested records and no record id the caller wasn't given. The kernel checks identity and policy again **after any wait on the first execution's idempotency claim and immediately before releasing the receipt**: it re-authenticates the same user in the same organisation and re-checks the action's policy. A member removed while their duplicate call waited gets `Forbidden`. A receipt stored under another format is refused with `IdempotencyConflict` (use a new key). Callers that need current data re-read it through the normal read path (sync or a read action), which applies the current policy.
101
+ - **The result is an envelope on every surface:** `{ kind: "output", output }` on first execution, or `{ kind: "replay", receipt }` (`actionResult(action)` in `@eloxiv/contracts`). The two are structurally exclusive whatever the action's output schema allows, because the output always sits inside `output`. An output that looks like a receipt, or a broad (any-JSON) output schema, is delivered intact and is never taken for a replay. The same envelope is the typed client's `call` return type, the RPC success schema, the HTTP API response and OpenAPI document, the MCP tool's output, the agent tool's `output`, and `result` in the JSON manifest. `isReplay` (exported by `@eloxiv/contracts` and `@eloxiv/client`) validates the whole envelope and receipt, not just the tag.
102
+
103
+ The surfaces are projections of one action registry: Effect RPC at `/rpc`, Effect HttpApi at `POST /api/actions/<action>` (OpenAPI at `/api/openapi.json`; calls carrying `x-eloxiv-surface: cli` are recorded as surface `cli`), Effect McpServer at `/mcp` (tools named `hello_greet`), and Vercel AI SDK tools from `AgentTools.toolsFor(headers)` (an effect; the kernel's agent runtime calls the same projection through `AgentTools.execute`, as the person through an agent session). Workflows, the scheduler and inbound webhooks invoke the same path as surfaces `workflow`, `scheduler` and `ingress`, with an execution identity.
104
+
105
+ - **Listings follow reach.** `Invocation.reach` answers what a caller can reach by the checks `invoke` makes before reading the input (identity, credential scope, agent tool group, a policy constant false for the actor). MCP `tools/list` (an Effect McpServer visibility), the OpenAPI document asked for with a credential (`eloxiv actions` sends one), `AgentTools.toolsFor` and the agent runtime's offered tools list only that; without a credential the OpenAPI document lists every action. A hidden action called directly still reaches `invoke`, which refuses and audits it.
106
+ - **Agent tool groups.** Every action is in its module's group and in any group its manifest declares (`toolGroups`). `KernelApp.agentTools.disabledGroups` disables groups for agents: an agent-originated call to their actions is `Forbidden` on every surface (an agent session over HTTP included), and they are hidden from every agent listing. Unlike agent-native, no route stays open to an agent when its group is off; people's calls are left to the policy.
107
+ - **One chokepoint for deferred authority: `Authority.assert`** ([`Authority.ts`](../packages/kernel/src/Authority.ts), [Invocation](contracts/invocation.md#authority)). Approval requests, schedules, agent runs (and their tool calls, consent retries and delegates), device turns and inbound webhooks carry an authority chain (the credential, agent session, device, linked identity and consent they were asked under; `AuthorityRecord` in `ctx.authority`, `authority` in `ExecutionIdentity`). Every call asserts it inside its own transaction before touching protected data, locking each link's row `FOR SHARE` in one global order and reading expiry by `clock_timestamp()`; so do an agent run's own reads and writes outside actions (`onBehalf`: context, compaction, skills, the query fallback, delegation). Revocations update the same rows in the same order: they wait for, or refuse, in-flight work, and never deadlock with it. The assertion returns a capability (`Asserted`) that every protected-data API requires (handler execution, query views and the query surface, the agent's resources, memory, skills and transcripts), bound to its transaction and person and carrying the scope, which covers non-action reads (`agent.send` for a run's own reads, `eloxiv.query` for view reads); the person's membership and a sync's connection are links too, and a one-time consent is used up as the call it approved commits. Nothing missing is unrestricted: work, sessions and journalled identities recorded before chains were fail closed (trusted code says `{ scope: null, chain: [] }`); `packages/kernel/test/authority-capability.test.ts` checks the capability cannot be forged, and the lint rule `eloxiv/no-asserted-cast` refuses casts to it. Reactions to committed facts (outbox subscribers, event-triggered workflows) act as the system by design. A request with no recorded provenance fails closed; consent a person withdrew refuses an approved agent call; requesters withdraw pending approvals (`approvals.withdraw`), and approvals expire after seven days by default. Event-trigger workflows keep their system identity (app-authorised reactions to committed facts). [`deferred-authority.test.ts`](../packages/testing/test/deferred-authority.test.ts), [`authority-chain.test.ts`](../packages/testing/test/authority-chain.test.ts).
108
+ - **Deferred work keeps its provenance.** A business approval records the held call's origin, agent session (or reference), credential scope and authority chain, and executes the call with them; a schedule records its creator's origin and authority (`ctx.authority`); `ExecutionIdentity` carries `agentSession`, `origin: "person"`, `scope` and `authority`. The checks run again at execution, every link of the chain included, so neither approval nor scheduling widens a call or outlives what it was asked under ([`provenance.test.ts`](../packages/testing/test/provenance.test.ts)).
109
+
110
+ - **`/mcp` requires a credential.** Without one (or with an invalid one) it answers `401` with an RFC 9728 `WWW-Authenticate` challenge pointing at `/.well-known/oauth-protected-resource/mcp`, so MCP clients discover the kernel's OAuth server. Each `tools/call` may carry its own idempotency key in `params._meta["io.eloxiv/idempotency-key"]` (over the `idempotency-key` header).
111
+ - **The OAuth 2.1 authorisation server** ([MachineIdentity](contracts/machine-identity.md)): `/.well-known/oauth-authorization-server`, `/.well-known/oauth-protected-resource/{mcp,api}`, and `/oauth/*` (dynamic client registration, authorisation code with PKCE, a consent page, the device flow, token and revocation). `KernelApp.oauthPages` replaces its sign-in, consent and device pages.
112
+ - **Inbound webhooks** ([Ingress](contracts/ingress.md)): `POST /ingress/<source>` verifies, accepts and stores a delivery, answers once it is committed, and processes it in the `eloxiv.ingress` workflow. `defineModule` and `KernelApp` take `ingress` sources.
113
+ - **Request limits** (`KernelConfig.http`, [MachineIdentity settings](contracts/machine-identity.md#settings)): every request body is counted as it arrives and refused (`413`) at the first byte past its limit (4 MiB overall; 16 KiB for OAuth, 64 KiB for management operations, the source's for ingress), never buffered first; a body the kernel reads itself must arrive within 30 s (`408`); and a connection silent for 120 s while the kernel owes it nothing is closed, on Bun and Node (idle between requests, or a response the client stopped reading; never under a handler still working on its answer). Better Auth and Zero are handed a body already read within these limits, and Better Auth's rate limiter, on in every environment with its counts in the database (`KernelConfig.authLimits`), keys on an address the kernel states (`x-eloxiv-client-address`), never on `x-forwarded-for` as a client sent it.
114
+ - **Kernel management over HTTP** (a signed-in person): `POST /kernel/machine-identity/<operation>` (service principals and API tokens) and `POST /kernel/ingress/<operation>` (link codes and linked platform identities).
115
+ - **Connections** ([Connections](contracts/connections.md)): `GET /connections/authorize?flow=` and `GET /connections/callback` (the OAuth client flow, PKCE S256, state bound to the session); the lifecycle is the kernel `connections` module's actions (`connections.connect`, `reconnect`, `disconnect`, `list`, `add` for endpoint Connections, `grant`, `revoke`, `grants` for shared ones, and the ToolSource and HttpApi actions `tools`, `callTool`, `openApp`, `appCall`, `closeApp` (MCP App sessions), `apiCatalog`, `apiDescribe`, `apiRead`, `apiWrite`) on every surface. `POST /kernel/secrets/{put,list,delete,inventory,preview-removal}` manages a person's own and (with `eloxiv.secrets.manage`) the organisation's secrets ([Secrets](contracts/secrets.md)).
116
+ - **Auth behind a seam** ([AuthProvider](contracts/auth-provider.md), [`auth/`](../packages/kernel/src/auth)): the kernel owns the identity store (schema `auth`) and judges every session; the provider people sign in with is Better Auth unless the app names another (`KernelApp.auth`; a trusted-proxy provider is in `@eloxiv/testing/auth`). Session tokens are stored as their digests (`auth/SessionTokens.ts`, migration `0246`). Enterprise sign-in and provisioning through WorkOS ([`enterprise/`](../packages/kernel/src/enterprise), migration `0245`, [Directory](contracts/directory.md#enterprise-sign-in-and-provisioning)): `POST /api/sso/start`, `GET /api/sso/callback`, `POST /api/workos/webhook`, off without `ELOXIV_WORKOS_*`.
117
+ - **Other routes:** `/auth/*` (the auth provider; Better Auth's configured by `KernelConfig.identity`: address verification, password reset, change of address, TOTP two-factor with backup codes and a challenge for bearer clients in `x-eloxiv-two-factor`, OAuth/OIDC sign-in providers with verified-only account linking; account mail through system email, [AccountMail.ts](../packages/kernel/src/AccountMail.ts); [Actor](contracts/actor.md#signing-in)), `/kernel/directory/<operation>` (every Directory operation, a person's own session), `/api/me/avatar` and `/api/users/<id>/avatar` (people's photos, [Avatars.ts](../packages/kernel/src/Avatars.ts)), `/health`, `/ready` (Readiness: also the agent's default model and each connector's settings), `/agent/readiness` (whether a person's agent can answer: configured, missing or unavailable), `/release`, `/api/me/organizations` (the organisation switcher), `/notifications/unsubscribe` (the signed one-click link every system email carries; `GET` and RFC 8058 `POST`), `/zero/query`, `/zero/mutate` (optimistic writes pushed from replicas, run through the invocation path as surface `sync`: [Sync](contracts/sync.md#mutate)).
118
+
119
+ ### The query surface, settings and flags
120
+
121
+ Three more kernel modules, installed like the inbox's: `queryModule` (actions `eloxiv.query` and `eloxiv.queryViews`: read-only SQL over the published query views, [QuerySurface](contracts/query-surface.md)), `settingsModule` (`settings.get`, `settings.set`, `settings.clear`: keyed, scoped values modules declare, [Settings](contracts/settings.md); setup checklists are such values, `defineChecklist`) and `flagsModule` (`flags.evaluate`, `flags.set`, `flags.remove`, `flags.rules`: feature flags targeted per organisation, [Flags](contracts/flags.md)). Their actions are served by kernel services (`QuerySurface`, `Settings`, `Flags`) through `KernelActionHandlers`; handlers read settings and flags with `ctx.settings.get` and `ctx.flags.isEnabled`. Setup creates the query surface (schema `eloxiv_surface`, one view per published query view owned by its module's runtime role, readable only by the role `eloxiv_query`), and the platform read functions (schema `eloxiv_platform`, `SECURITY DEFINER`, owned by the role `eloxiv_platform_read`, executable by module runtime roles only) through which `ctx.settings` and `ctx.flags` read deployment settings, stored values and flag rules for the caller without switching the handler's role. The surface bounds each query's result size, value size, `work_mem`, temporary files and time, and how many run at once in all and per person, refusing rather than queuing so a query never holds a kernel connection while it waits; it returns and encodes only built-in base types, so no module's cast runs ([QuerySurface](contracts/query-surface.md#limits)). Their sync tables are `platformTables` in `@eloxiv/client/sync`. The example apps do not install them yet; the platform conformance app ([`crm/app.ts`](../packages/testing/src/conformance/crm/app.ts)) does.
122
+
123
+ Under setup's steps ([Release](contracts/release.md), guarantee 2) the query module's schema is `eloxiv_query` (the kernel's modules use `eloxiv_<name>`). A module's query-surface views are dropped on setup's session just before its owner session migrates it (they read its tables as its runtime role, so its owner cannot drop them), and every view and platform read function is created again in step 2, after the hardening. `eloxiv_surface`, `eloxiv_platform`, and the roles `eloxiv_query` and `eloxiv_platform_read` (attributes and memberships) are the kernel's recorded security state (`kernelSecurityState`, format 2): changed outside setup, setup refuses them; what the platform read role may read of the `settings` and `flags` tables (USAGE, SELECT, its row-level security policy) is those modules' own recorded state, repaired like any module's. Module runtime roles' USAGE on `eloxiv_platform` and EXECUTE on its functions are what setup gives them, and nothing else there. Evidence: [`platform-state.test.ts`](../packages/testing/test/platform-state.test.ts).
124
+
125
+ ### The inbox
126
+
127
+ The kernel provides four modules, installed with `inboxModules` beside the app's own: `approvals` (business approval requests), `consent` (an agent's held calls and remembered permissions), `inbox` (work items: what someone must do, assigned to a person or a group, from any module's work-item source) and `notifications` (in-app notifications, delivery records and preferences). They are ordinary modules (their own schemas, policies and row-level security) whose actions the kernel registers like any other; their tables sync through `@eloxiv/client/sync`'s inbox tables. Notifications reach people in the app and through `NotificationChannel`s; the kernel's email channel sends system email over SMTP (`ELOXIV_SMTP_URL`, `ELOXIV_EMAIL_FROM`) from registered templates. The kernel's push channel (`notifications/Push.ts`, Notifications 1.2.0 and NotificationChannel 1.1.0) delivers to the app installations people register from their own session (`notifications.registerInstallation`, `eloxiv.push_installation`, removed when that session ends) through APNs over HTTP/2 and FCM HTTP v1 (`ELOXIV_APNS_*`, `ELOXIV_FCM_*`), with per-installation delivery state (`eloxiv.push_delivery`), the record's view link, and for approval and consent notifications to an APNs installation a single-use decision token (on Android the notification opens the request with the verdict preselected and the person confirms it in the app) redeemed at `POST /api/notifications/decide` (`notifications/Decide.ts`, `eloxiv.notification_decision`) through the existing actions as the person. Policies may test `principal in resource.<attribute>` on an entity-typed column (a group, a user or an organisation): row-level security calls `eloxiv_ctx.in_group(<column>)`, and sync evaluates it live against the replicated directory facts, so an item assigned to a group reaches its members' replicas and leaves one when the member leaves the group.
128
+
129
+ ### Platform services
130
+
131
+ Four more kernel-provided modules and two cross-cutting services ([Progress](contracts/progress.md), [Versioning](contracts/versioning.md), [Telemetry](contracts/telemetry.md), [Privacy](contracts/privacy.md), [ResultRendering](contracts/result-rendering.md)):
132
+
133
+ - `progressModule` (`progress.list`, `get`, `cancel`, `remove`): tasks of long work owned by the person whose work it is, synced to them; handlers and workflows report through `ctx.progress`; cancellation is cooperative.
134
+ - `versioningModule` (`versioning.modules`, `history`, `version`): setup refuses modules whose `kernel` range excludes the kernel and downgrades (a MAKE module goes back only through `make.rollback`), and records versions; entities with `history: true` keep an append-only history written by the invocation path, read through the record's own read policy; modules restore with `ctx.history.restore` in their own actions (through the platform read function `eloxiv_platform.record_version`).
135
+ - `privacyModule` (`privacy.getConsent`, `setConsent`, `requestExport`, `requestErasure`, `requests`, `download`): consent per person and organisation under regional rules (`KernelApp.privacy`); export and erasure as the kernel workflow `eloxiv.privacy-request` over every module's `dataSubjects` (enforced complete when the module is installed), `KernelOptions.privacySources` and every kernel store in the inventory (`privacy/Inventory.ts`, enforced against the catalog by `kernel-inventory.test.ts`), each source done once (`eloxiv.privacy_step`), reported through Progress and audited per source. Files and ingested items follow their record (a person's staged files are deleted, their id as uploader or submitter pseudonymised); the spaces module and MAKE's stores are in the inventory; MAKE modules declare their data subjects in their manifests (required with the privacy module installed), and requests export and erase their records as each module's runtime role. Needs `progressModule`.
136
+ - `auditModule` (`audit.records`, `audit.export`): the organisation's audit log, with each call's lineage and change summary (migration `0110_audit_lineage`), read and exported as CSV or OCSF by holders of `eloxiv.audit.read` ([Audit](contracts/audit.md)).
137
+ - Visitors before sign-in (`/privacy/visit`, `/privacy/visit/claim`, `privacy/Visits.ts`): consent choices and attribution on a visit cookie, carried to the person at sign-in ([Privacy](contracts/privacy.md#visitors-before-they-sign-in)); the client SDK's `consentController` and `errorReporter`.
138
+ - `telemetryModule` (`telemetry.track`, `telemetry.captureError`): clients' analytics events and unexpected errors (labels only). Telemetry itself (`TelemetryTracing`, `ErrorCapture`, `Analytics` in `Telemetry.ts`) is configured by `KernelConfig.telemetry` (OTLP, Sentry, PostHog), provided innermost in `KernelServices`; allowlist-only: span attributes are declared values (registered names, enums, route templates), captured errors are a tag, an invocation id and a fixed message, analytics events are declared with typed properties (ids pseudonymised) and leave only with consent.
139
+ - Renderers (`render` on actions and query views) are checked at startup and published in manifests; agent tool results carry compact text (`rendered`).
140
+
141
+ The conformance app is [`studio/app.ts`](../packages/testing/src/conformance/studio/app.ts).
142
+
143
+ ### Sharing
144
+
145
+ The kernel-provided `sharing` module (`sharingModule`, installed beside `inboxModules`, whose work items and notifications it needs) makes per-record sharing an action on every surface ([Sharing](contracts/sharing.md)): grants of an entity's declared sharing permissions to a member, a group, the organisation or a link (an unguessable, expiring, revocable token members redeem), revocation, listing, and access requests that reach the record's managers as work items and notifications. Who may share a record is the entity's own Cedar policy for the action `share`. A grant is always in its record's organisation and counts only for someone acting there. Grants compile into row-level security (`eloxiv_ctx.has_grant`, for the acting principal only, in the record's organisation), the query views and sync (live permission subqueries over the replicated grants and redemptions). The kernel deletes expired grants every second. Handlers share through `ctx.sharing`, authorised the same way.
146
+
147
+ ### The kernel boundary
148
+
149
+ Kernel code and module (registry and app) code are kept apart in-process ([`KernelModule.ts`](../packages/kernel/src/KernelModule.ts), [`durable/Trust.ts`](../packages/kernel/src/durable/Trust.ts)):
150
+
151
+ - **Module code runs without the kernel's services.** Handlers, subscribers, module and app workflow bodies and their step bodies, failure handlers, connector operations, and every module-declared schema the kernel decodes or encodes run through `asModuleCode`: a context holding only Effect's own references and the call's transaction connection (what `ctx.sql` uses), in a scope of their own, so `yield* Secrets` in module code is a missing service and a finalizer it adds never runs with the kernel's services.
152
+ - **Kernel workflows** are defined only in `durable/Trust.ts` (no package export reaches it; a fallow boundary refuses imports of it): `defineKernelWorkflow` records the body and failure handler it was given and whether its steps may execute approved business-approval requests (the approval workflows only), and freezes the definition; the engine runs the recorded functions with the kernel's services, and everything else as module code. A module's step may act only as the execution's identity (`untrustedRequest`). Trusted: `eloxiv.approval`, `eloxiv.approval-expiry`, `eloxiv.ingress`, `eloxiv.agent-run`, `eloxiv.connection-sync`, `eloxiv.connection-effect`, `eloxiv.device-turn`, `eloxiv.device-turn-deadline` and `eloxiv.privacy-request`. (`eloxiv.scheduled-action` is an ordinary workflow: it invokes as the schedule's owner, or as the person's agent for a schedule an agent set up.)
153
+ - **Kernel modules** are frozen, and an app whose module takes a kernel-provided name (inbox, scheduler, connections, sharing, query, settings, flags, agent, devices, spaces, progress, privacy, versioning, telemetry) without being the kernel's own object is refused at startup. `defineKernelModule` (connections) records its handlers, which run as the kernel's role; `KernelActionHandlers` serves the query surface's, settings' and flags' actions, found by module object.
154
+
155
+ ### The agent
156
+
157
+ The kernel-provided `agent` module (`agentModule`) and its services ([AgentRuntime](contracts/agent-runtime.md) and family): one agent per person per organisation over the whole registry, durable runs (`eloxiv.agent-run`) whose model and tool calls are journalled steps, consent holds, delegation, memory, resources, context accounting and budgets ([Metering](contracts/metering.md)). `agent.send` with `device` runs the turn on one of the person's paired devices instead ([Daemon](contracts/daemon.md#integrating-with-the-agent-runtime)). Since build/agent-runtime (AgentRuntime 1.4.0, Delegation 1.1.0): each run records its options when it is queued (`run.options`: `mode`, the organisation's tool policy, delegation depth and profile); the organisation's loop and tool policies are the agent module's settings `agent.loop` and `agent.tools`, capped at `KernelApp.agent.maxLimits`; plan mode (`agent.send` `mode: plan`); tool discovery by search (`ToolSearch.ts`: a tool index and `tool_search`, loaded tools offered from the next call); write receipts on agent tool results and the final-answer check (`Receipts.ts`, `run.verification`); app processors (`Processors.ts`, `KernelApp.agent.processors`); delegation depth and custom agent profiles (`maxDelegationDepth`, `profiles`); active runs with stall detection (`GET /agent/runs`); conversation marks, search and pages (`agent.updateConversation`, `GET /agent/conversations`); and queued messages (`agent.send` `queue`, `eloxiv_agent.submission`, promoted in the transaction that records a run's end; `agent.cancelQueued`). Agent module migrations `0095_run_options`, `0096_conversation_meta`, `0097_submission`. Since build/agent-runtime-2 (AgentRuntime 1.7.0): conversations shared to read or reply through Sharing grants (`agentRelationships` in the sync schema), threads on a record, checkpoints, turns recorded from elsewhere, attachments' text read into context (`files.readText` as the person's agent), and `agent.send` refused when the agent is not ready (an invocation precheck, `agent/Admission.ts`); agent module migration `0098_threads`.
158
+
159
+ Model providers run over the Vercel AI SDK, with no real provider in the kernel: registry connectors supply them ([`openai`](connectors/openai.md), proven against OpenAI's API). Model setup (2026-11-15): organisation and personal model keys as managed secrets, checked against the provider before they are saved, the organisation's policy (personal keys, allowed models) and each person's checked model choice, through `/agent/models` and the client SDK's `modelSetupOf` ([ModelProvider, "Model setup"](contracts/model-provider.md#model-setup)). Teams of parallel sub-agents with messages between them, the `team` tool (Delegation 1.2.0, build/agent-teams; `agent-teams.test.ts`). Compaction in three tiers: recent messages raw, dated observations and a reflection over them (Memory 1.1.0; the Memory kit, run by `agent-memory.test.ts`). Resource packs: `agent.exportResources` exports a scope and `agent.importResources` imports it elsewhere, all or nothing, conflicts refused, skipped or replaced ([AgentResources](contracts/agent-resources.md); the AgentResources kit, run by `agent-resources.test.ts`). Budget alerts: a member is notified once per period when their usage reaches their budget's alert threshold ([Metering](contracts/metering.md); `agent-usage-insights.test.ts`). The `/agent/*` HTTP routes and the client SDK's `agentClient` reach all of it; agent-tool failures return `{ ok: false, error }` to the model.
160
+
161
+ ### Connections and devices
162
+
163
+ - **Connections** ([Secrets](contracts/secrets.md), [Connections](contracts/connections.md), [Metering](contracts/metering.md)): envelope-encrypted secrets, OAuth connections to providers with custody, refresh and per-connection backpressure, the sync engine (`eloxiv.connection-sync`), the seven capability contracts, the `microsoft-graph` and `google` connectors, and the `slack` channel connector receiving through Ingress (proven against protocol fakes). Endpoint Connections (2026-11-11): a Connection may name its own endpoint and authenticate with a named secret or OAuth discovered from the endpoint, every destination someone chose passing the outbound destination policy (`connections/Destinations.ts`, `ELOXIV_OUTBOUND_ALLOW`); the registry's `mcp` (ToolSource: remote MCP servers) and `http-openapi` (HttpApi) connectors implement them. Shared (organisation) Connections are granted to members, groups and modules. Raw provider requests (Connections 1.3.0, `connections/ProviderApi.ts`): a capability's bounded escape hatch to its provider's own API over the person's Connection (CalendarProvider 1.4 `apiRead`, `apiWrite`), within the paths its connector opens and sent through the destination policy, pinned; a capability's sensitive scopes may be left to incremental consent (`incremental`: Gmail's settings scope). The client SDK's `connectionsOf`, `consentInPopup` and `authorizationResume` carry them headlessly.
164
+ - **Devices** ([Daemon](contracts/daemon.md), [DeviceControl](contracts/device-control.md)): paired devices with their own credential, the kernel-provided `devices` module (`devices.sendTurn` with follow-ups, `devices.cancelTurn`, `devices.sendCommand`, `devices.getCommand`, `devices.listDevices`; the organisation's switches `devices.commands` and `devices.workspaceTools`) and the durable turn queue (`eloxiv.device-turn`), driven by the daemon package's headless runner or desktop daemon; device commands run at most once before their deadline; a device's push subscription in `eloxiv.device_push` (kernel migration `0105_device_push`).
165
+
166
+ ### Collaborative documents
167
+
168
+ - **CollabDocument** ([CollabDocument](contracts/collab-document.md)): entities declare `collab` (limits, the text agents edit); the record's Cedar `read` policy governs reading and presence, its `collaborate` policy changes. The kernel-provided `collabModule` (`collab.open`, `pull`, `update`, `awareness`, `readText`, `editText`, `history`, `snapshot`, `restore`; edits and restores may name a `baseSeq` and are refused as a version conflict when the document moved past it) puts every read, update and presence message on the one invocation path, every statement on the document tables under the call's asserted authority (`Asserted`, provided to the kernel's own modules as `CallerAuthority`) and checked against the record's policy, changes under the record's lock; the WebSocket transport (`GET /collab/socket`, `collab/Socket.ts`) turns every frame and every delivery into one of those calls with the connection's credential, so revocation closes open connections. Updates are stored append-only under the document row's lock, compacted into a snapshot (and a checkpoint) without touching later ones; presence lives only while live in a kernel-only unlogged table, newest client clock winning; wake-ups are empty notifications, what changed a kernel-only change row. Clients: `@eloxiv/client/collab` (`connectCollab`, and `followPeer`, `localUndo`, `recentEdits` attributed by the kernel's stored authors), `@eloxiv/client/history` (`documentHistory`, `recordHistory`), and the Foldkit adapter's `collabDocument` Subscription. Sharing's headless controllers (`shareController` with the organisation-widening confirmation, `wideningTransition`, `accessGate` over `sharing.access`, `decideAccessRequest`) are `@eloxiv/client/sharing`. Example: `notes` 0.6.0's collaborative note (the registry `app` 0.4.1 installs `collabModule` and the inbox modules, so an agent's edit waits for its person's consent).
169
+
170
+ ### Files, Search and Ingestion
171
+
172
+ Three kernel modules defined with `defineKernelModule` (kernel-role handlers that authorise each record themselves), installed as `filesModule`, `searchModule` and `ingestionModule`; their state is the kernel's own tables (migration `0029_files_search_ingestion`). The kernel's `data` module (`dataModule`) adds read programs (Sandbox 2.1.0: `data.run`, `data.status`, sandboxed code that calls only granted read actions and Connections), staged datasets (Ingestion 1.2.0: `data.stage`, `data.query`, `data.datasets`, `data.drop`, and a module's `ctx.ingestion.datasets`) and corpus collections (`data.collect`, `data.collection`, `ctx.ingestion.collect`: the checkpointed workflow `eloxiv.corpus-collect` paging through `connections.apiRead`); its state is the kernel's tables `staged_dataset`, `staged_row`, `data_run` and `corpus_collection` (migration `0160_sandbox_data`).
173
+
174
+ - **Files** ([Files](contracts/files.md), [StorageBackend](contracts/storage-backend.md)): entities declare `files` (limits, types, `ingest`); the record's Cedar `attach` policy governs attaching and deleting, its `read` policy reading. Resumable multipart uploads through the kernel's signed part route (`PUT /files/upload`), quota reserved under the organisation's lock (Metering's storage part), the durable `eloxiv.file-finalize` workflow (size, SHA-256, type sniffed from the bytes, the `FileScanner` hook), downloads through short-lived signed URLs (`GET /files/download`, or the store's presigned URL), retention holds, a sweep purging deleted bytes, and `eloxiv.file` synced through each file's record's read filter (`fileTables` in `@eloxiv/client/sync`). Bytes in a local directory or an S3-compatible store (`ELOXIV_STORAGE`, `KernelOptions.storage`); Readiness reports `storage`. Handlers get `ctx.files`.
175
+ - **Search** ([Search](contracts/search.md)): entities declare `search` (fields, weights, language). Setup installs `eloxiv.track_record()` on tracked tables (recorded in the module's security state) and rebuilds an entity's documents when its declaration changes; `search.query` filters every candidate by its record's read policy at query time. With `KernelApp.search.embeddings`, documents are embedded in the background through ModelProvider and a hybrid query fuses full-text and semantic rankings.
176
+ - **Ingestion** ([Ingestion](contracts/ingestion.md)): `ctx.ingestion.submit` (files, text, email, DocumentSource documents over a Connection) and attached files of `ingest` entities run the durable `eloxiv.ingest` workflow (extract, chunk, index); `ingestion.status` reports progress.
177
+
178
+ ### MAKE
179
+
180
+ The kernel-provided `make` module (`makeModule`) and the Sandbox ([sandbox.md](contracts/sandbox.md)): a person or their agent drafts a module (the JSON manifest form, a Cedar policy, a capability profile, additive and rollback-safe SQL migrations, ES module code, an optional view), previews it in a preview database of its own, and asks to install it; an organisation administrator approves (a business approval showing the source hash and the capability profile), and the install runs setup with it, so it gets its own schema and two roles and is hardened exactly as a built-in module. Its handlers run in QuickJS (WebAssembly) in a pool of worker threads, off the kernel's event loop, with only the host functions its profile grants (`sql` through a guard over PostgreSQL's parse tree, its results capped in the database; `emit`; `call` of other modules' read-only actions, never the kernel's; `setting`); its statements run on a session logged in as its runtime role, and everything the call leaves (its rows, idempotency receipt, audit record and events) commits once, in that session's transaction, through kernel functions bound to the call's own ticket (no prepared transactions). Its actions are served at `POST /make/actions/<module>.<action>` and as the agent's tools; versions are additive, and a rollback runs the previous version's code over the same schema. Its views are code that runs in the sandbox (`make.renderView`) and returns a view tree, which the shell (shell-foldkit 0.4.0) draws in an iframe sandboxed without scripts under a CSP that loads nothing, its controls routed to the view through the frame's own fragment (threat SB-7). Not yet: subscribers, MCP, the typed RPC client.
181
+
182
+ ### Registry and distribution
183
+
184
+ - [`registry/`](../registry) is a shadcn registry. `registry.json` is generated by [`registry/scripts/index.ts`](../registry/scripts/index.ts) from the item sources (so new files such as migrations are always published) and built with `shadcn build` into `registry/public/r/*.json` (`pnpm --filter @eloxiv/registry-source build` runs index, build and compose). Items: `app` (server entry and seed; 0.2.0 seeds a second organisation, `globex`, for Alice; 0.3.0 drops `queryEntities`), `hello` and `notes` (**headless** modules: Drizzle tables, contract, server, generated sync tables and named queries, policy, migrations; 0.4.0 defines their entities over the Drizzle tables, decision 9; hello 0.6.0 declares `hello.greet`'s optimistic effect and refuses farewells; hello 0.7.0 counts waves, `hello.wave` predicted by hello's own code, 0.7.1 titles its actions, `optimistic.custom()`), `people`, `mail` and `calendar` 0.1.0 (headless business modules, below; each names the kernel-provided modules it needs in `meta.eloxiv.kernelModules`), `shell-foldkit` (the shell, below; 0.1.0 was decision 10's proof, 0.2.0 adds MAKE's views and slots, 0.5.0 its lifecycle: legacy paths, the kernel's readiness notice, WebMCP while signed in, the pre-paint boot and the high-contrast preset, profile editing, the classified error view and MAKE frames in the app's theme), the UI items `hello-ui-foldkit` (hello's screen; 0.2.0 shows hello's slot) and `notes-ui-foldkit` (notes' screen, also beside hello's greetings through notes' contribution to that slot), `chat-ui-foldkit` and `approvals-ui-foldkit` (reference screens for the agent and the inbox, decision 11), `ui-conformance` (the UI kit's conformance kit: Foldkit Scene probes against a contract major, `shell-foldkit/src/conformance/uiKit.ts`), `theme`, `desktop` (0.4.0 depends on no shell: it embeds `desktop/dist`, built from the app's own shell, `shell-foldkit` when the app has it), and the connectors `microsoft-graph` and `google` (kind `connector`: MailProvider, CalendarProvider, DirectoryProvider and DocumentSource over a kernel Connection) and `slack` (Messaging, with the `slackEvents` Ingress source; [docs/connectors](connectors)). A connector is installed like any item; the composition lists its export in `eloxiv.server.ts` (`connectors`) with the kernel's `connectionsModule`, and `app` 0.5.0's `server/main.ts` installs the modules, the kernel-provided modules they ask for (`kernelModules`) and the connectors. microsoft-graph 0.1.3 and google 0.1.4 implement CalendarProvider 1.2 (`respondToEvent`, `selfResponse`) and MailProvider 1.3 (`archive`, client ids, message versions); google 0.1.5 carries the client id in a custom header and reads it back from the sent messages (Gmail replaces a sender's `Message-ID`). Published item versions are immutable (`registry/public/r/<item>/<version>.json`): publishing refuses changed content without a version bump. Each item's `meta.eloxiv` carries its kind, version and, for modules, the contract, server and sync exports. **Retired items** are listed in `registry/public/r/deprecated.json` (written by `registry/scripts/index.ts`): the React shell `shell` (last 0.4.0: React 19, TanStack Router, shadcn/ui, Tailwind) and its hello route `hello-ui` (last 0.3.0) gave way to `shell-foldkit` and `hello-ui-foldkit` (decision 10); their published versions stay, `eloxiv add` refuses them, and `diff` and `update` report them to apps that installed them.
185
+ - Item sources live in [`registry/app/`](../registry/app) laid out exactly as they land in an app, so relative imports are identical. `registry/app` is a working app for the registry's own tests; its composition files are written by the CLI's generator.
186
+ - **`eloxiv add <items>`** resolves registry dependencies, copies files (refusing to overwrite a different file without `--overwrite`), merges npm dependencies into the app's `package.json`, records provenance in `eloxiv.lock.json` (registry location, registry version, sha256 content hash of the item as published, sha256 per file, item metadata), regenerates `eloxiv.modules.ts`, `eloxiv.server.ts`, `eloxiv.schema.ts` (the sync schema and named queries the server imports) and `eloxiv.sync.ts` (those with the mutators, for clients; module items ship their generated sync tables, `sync.gen.ts`, like their migrations; `eloxiv generate` rewrites them after a schema change; the registry's build generates its own first, `registry/scripts/generate.ts`), prints the item's next steps and runs `pnpm install` unless `--no-install`.
187
+ - **Developer tooling in the CLI** (build/dev-tooling, [cli.md](cli.md)): `eloxiv dev`, `build`, `start <kernel|zero|shell|setup>` and `typecheck` run the app with its own tools (`start zero` derives zero-cache's settings from the kernel's environment and always keeps CRUD writes off; `start shell` serves the built shell with its CSP and security headers); `deploy docker|fly|railway` writes a recipe (never deploys) and `deploy check` is the production preflight; `db host|check` are PostgreSQL host recipes and URL checks (`Postgres.ts`), `db schemas|tables|rows|sql` development-only administration (`DbAdmin.ts`); `doctor` adds portable architecture and security guards (`Guards.ts`) and imports of moved names; compatibility migrations in items' `meta.eloxiv.migrations`, applied by `update` and `migrate`, with `migrate --dossier` (`Migrate.ts`, `Dossier.ts`); `docs search`, `blueprint`, `info @eloxiv/<package>`, `changelog`; `eval` (through `@eloxiv/testing`'s `EvalMain.ts`) and `eval promote`; `agent-web generate|audit`; `brand extract`; `mcp serve` (stdio).
188
+ - **Examples, all three assembled only through the CLI** (`examples/hello-app`, the whole example app; `examples/headless-app`, criterion 9 with no UI; `examples/hello-only`, the hello app the hello budgets measure: app, hello and the shell) (`pnpm eloxiv init ...` then `pnpm eloxiv add ...`); a test checks every file against the lockfile's hashes and every lock entry against the current registry. They depend on `@eloxiv/*` packages as versions (linked in the workspace), never on registry source.
189
+ - [`examples/hello-app`](../examples/hello-app): `app hello hello-ui-foldkit notes notes-ui-foldkit desktop desktop-rune mobile` (bringing `shell-foldkit` and `theme`; the Tauri host, the Rune host and the Expo host side by side), plus the desktop item's next step (`pnpm exec tauri icon ...`). `mise run dev`, the Playwright suites and the benchmarks run against it.
190
+ - [`examples/headless-app`](../examples/headless-app): `app hello notes people mail calendar microsoft-graph google home openai`, no UI at all (`home`, of the registry kind `space`, brings the kernel's spaces, agent and inbox modules without a screen), driven only through the client SDK, the CLI's HTTP surface and MCP, with live replicas, against the connectors' protocol fakes: the directory imported, a member claiming their record, manager chains, sensitive fields only in HR's replica, each person's own mail and not a colleague's, a reply, a thread shared explicitly, an invitation in the invitee's unified inbox accepted over MCP, a colleague's free/busy, and the home space: spaces granted per role and pinned, follow-ups claimed, completed and dismissed, the global agent's consent through the SDK and `eloxiv agent`, member administration through the SDK ([`registry/test/headless.test.ts`](../registry/test/headless.test.ts); criterion 9).
191
+
192
+ ### The hello and notes modules
193
+
194
+ - **hello** ([`registry/app/modules/hello`](../registry/app/modules/hello)): entity `greeting` (defined over its Drizzle table, `schema.ts`, the only declaration of its fields), action `hello.greet` (with its optimistic effect: a replica shows the greeting at once, under the id the kernel derives from the caller's key), action `hello.wave` (one more wave at someone else's org-visible greeting, predicted by hello's own `predictions.ts`: the replica counts it at once, the server's count replaces it, a wave at one's own greeting is refused), event `hello.greeted` (a reference and the greeting's visibility, never its text); a drizzle-kit migration from the table; Cedar policy (greet in your own organisation as yourself, never with a farewell (`*goodbye*`); wave at your organisation's visible greetings, never your own; read your own greetings in the organisation you act in, org-visible ones, or ones explicitly shared with you); generated Zero table (`sync.gen.ts`) and a named query (`sync.ts`). Its shell route is the separate `hello-ui` item.
195
+ - **notes** ([`registry/app/modules/notes`](../registry/app/modules/notes)): entity `note`, no actions; subscribes to `hello.greeted` through the outbox (decision 4) and records an entity reference (`greeting_id`) to organisation-visible greetings only, never copying their text, so hello's read policy remains the only way to read a greeting. It exists to prove module isolation and cross-module events.
196
+ - Each module has two NOLOGIN roles created at bootstrap: an **owner** (`eloxiv_own_hello`) that owns the schema and tables and is used only by migrations, on a session of its own that logs in as it (setup gives it LOGIN and a one-time password only while it connects, under the cluster's role lock); and a **runtime** role (`eloxiv_mod_hello`) with `SELECT, INSERT, UPDATE, DELETE` on its own tables under row-level security. The kernel role can switch into runtime roles but inherits nothing from them and has no membership in owner roles. Every setup holds both roles to that state (no privileged attribute, password, LOGIN or other membership) and repairs drift. Setup refuses unsafe objects in a module schema (deferred triggers, `SECURITY DEFINER` functions, rules, unsafe views, foreign keys with `CASCADE`, `SET NULL` or `SET DEFAULT` referential actions, which would rewrite child rows as the table owner without checking either the old or the new child row, and `BEFORE UPDATE` row triggers other than the kernel's key guard; also casts to or from the module's types or through its functions, foreign tables, base types with their own I/O, and event triggers and default privileges touching the module), replaces any policies a migration created, and installs the generated ones.
197
+ - **Module migrations run as their owner; the kernel's migrations and the hardening are one transaction, under a lease** ([Release](contracts/release.md), guarantee 2). Setup holds a PostgreSQL advisory lock on the app's database for its whole run, recorded with its owner and an expiry in `eloxiv.release_lease`, and does all its own work on the session that holds it (a lost session ends its work with it, and the next setup ends any owner session the lost one left); a concurrent setup waits (`waitMs`, default 120 s), then fails with `ReleaseLeaseHeld` naming the holder, and a stuck holder is reported at once. Migrations are parsed with PostgreSQL's grammar before anything runs: transaction control and role changes are refused, and a migration that cannot run in a transaction (`CREATE INDEX CONCURRENTLY`) must start with `-- eloxiv:no-transaction` and runs alone between two rounds (undeclared ones are refused). Each module's pending migrations then run on its owner session in one transaction that records them, leaves the module **closed** (forced row-level security, no policy, no privilege) and commits only once its checks pass and the lease holds; then one transaction on setup's session applies Better Auth's, the kernel's and Effect cluster's migrations, checks and hardens every module (unsafe-object refusal, privileges, row-level security, write-log and key-guard triggers, the security state compared and recorded), publishes the query views, updates the sync publication and records each module's schema snapshot. A module migration that fails halfway, or that the checks refuse, leaves the database exactly as it was, Better Auth's and the kernel's tables included (`packages/testing/test/release-atomic.test.ts` reproduced backlog 11 against the earlier code); a failure in the hardening transaction leaves the migrated modules closed, never open, until a setup succeeds. Every setup checks each module's security state against what its last hardening recorded, repairs drift (or refuses what it cannot repair), and `GET /ready` is not ready while it drifted. Every setup is recorded in `eloxiv.release_history`. Run setup before starting the new kernel version: a kernel whose database is behind its build reports not ready at `GET /ready`.
198
+ - **Database hosts without a superuser** ([Release](contracts/release.md#database-hosts), [`db/Host.ts`](../packages/kernel/src/db/Host.ts)): setup runs as the admin URL's role, the setup role, which on a managed host (Neon's `neondb_owner`) is an ordinary role with `CREATEROLE`, `CREATEDB` and `BYPASSRLS`. Before anything changes it requires those and `pg_authid` (refusing otherwise), detects which protections the host allows (revoking catalogue functions from PUBLIC, event triggers, SCRAM verifiers as passwords, reading `pg_hba.conf`, schema-wide publications), applies each one it does and records them with the kernel's state (`host`), refusing a later setup on a host that allows less. The setup role is the kernel's trusted owner besides superusers: it owns setup's own functions and the recorded state, zero-cache's shard must be a trusted owner's, nothing setup creates may be a member of it, and the kernel role may not be it or a member of any privileged role. Without a superuser it holds the roles it creates (`INHERIT`, `SET`) to act as their owner. Where a protection is missing, its replacement: MAKE's guard for the catalogue functions, a live test of the owner's login window for `pg_hba.conf`, a table-by-table publication, plaintext one-time passwords whose login is gone before the lock is released, and zero-cache resets instead of setup's DDL announcements. Tested on a local emulation of Neon's privilege model (`tools/scripts/neon-emulate.sh`, `ELOXIV_TEST_ADMIN_URL`; CI `managed postgres (emulated, bun|node)`) and against a real Neon branch (`tools/scripts/neon-branch.ts`; CI `live postgres (neon, bun|node)`).
199
+
200
+ ### The People, Mail and Calendar modules
201
+
202
+ Headless registry modules (decision 10: their UI comes later on Foldkit), each over Drizzle tables with generated sync, Cedar policy, `dataSubjects`, published query views, a skill with eval cases, and a Connection sync declared in `defineModule({ connectionSyncs })` (named `<module>.<name>`). Handlers reach providers through `ctx.connections`: the caller's own Connections, only the operations each action declares, and an operation others see (sending, inviting, answering) only scheduled, recorded in the call's transaction and made after commit at most once by the kernel's `eloxiv.connection-effect` workflow ([Invocation, "External effects"](contracts/invocation.md#external-effects), [Connections](contracts/connections.md#from-a-modules-handler)).
203
+
204
+ - **people** ([`registry/app/modules/people`](../registry/app/modules/people)): person (linked to a member by `people.claim`, the record whose work email is their verified sign-in email, compared in one normalised form), company, department, position, reporting lines (every change to them, `people.terminate` and the directory import included, under one per-organisation advisory lock; `people.setManager` walks the whole line above the manager and refuses a cycle; `people.managerChain`), `people.terminate` (refused while active people report to them), and `sensitive` (personal email and phone, salary band, birth date) in its own entity readable and writable only with `people.hr`, so it never reaches another replica. Every member reads basic profiles; changes need `people.manage`. `people.directory` imports and delta-syncs a DirectoryProvider Connection whose owner has `people.manage` (others record `Forbidden` and import nothing), matching manual records by work email and creating departments by name. [`registry/test/people.test.ts`](../registry/test/people.test.ts).
205
+ - **mail** ([`registry/app/modules/mail`](../registry/app/modules/mail)): one mailbox per MailProvider Connection, its inbox synced (`mail.inbox`) for its owner alone; threads shareable through Sharing (`read`), their messages following by one hop (`resource.thread.sharedWith`); send and reply (consent for each message; the message is recorded in `outgoing` and delivered after commit, at most once, its state reported to `mail.delivered`), archive, move, mark read, fetch a body, and follow-up flags as the `mail.followUps` work-item source. Messages are searchable: their summary through the entity's `search` declaration, and each newly synced body (fetched through the owner's Connection) through `ctx.ingestion` as an `email` source under its message, so Search returns it exactly to those who may read the message (its owner, and whoever its thread is shared with, only while it is); a deleted (erased) message takes its search documents, chunks and ingested text with it. The composition installs the kernel's search and ingestion modules for it (`kernelModules: "search"`). Since 0.2.0: drafts kept in Eloxiv until sent (`draft`), a teammate's draft queued for its owner to review and send (`mail.queueDraft`, the `mail.draftQueue` work-item source; only the owner edits or sends it), sends scheduled for later (`sendAt`, an effect with `notBefore`) and cancelled until they go (`mail.cancelScheduled`, `ctx.connections.cancel`), snooze (archived now, an `updateMessage` effect moves it back at its time), triage rules acting on new inbox messages as the sync applies them (`rule`), bulk triage, and sending as an alias (MailProvider 1.5). Since 0.3.0: Gmail's own server-side filters (`mail.filters`, `mail.createFilter`, `mail.deleteFilter`; MailProvider 1.6), not mail's triage rules ([`mail-filters.test.ts`](../registry/test/mail-filters.test.ts)). [`registry/test/mail.test.ts`](../registry/test/mail.test.ts), [`mail-workflows.test.ts`](../registry/test/mail-workflows.test.ts).
206
+ - **calendar** ([`registry/app/modules/calendar`](../registry/app/modules/calendar)): one calendar per CalendarProvider Connection (`calendar.events`), its events for their owner alone, and a busy block per event (times only) readable by colleagues with `calendar.freeBusy`; create, update, cancel, respond (CalendarProvider 1.1; each needs consent from an agent, is recorded in `change` and made at the provider after commit, reported to `calendar.changed`), `calendar.freeBusy`, `calendar.findTime` (since 0.2.0: free slots within working hours in a time zone, from the caller's and colleagues' busy blocks and outside addresses' busy time through CalendarProvider 1.3 `freeBusy`), and invitations awaiting an answer as the `calendar.invitations` work-item source. Since 0.3.0: raw requests to the provider's calendar API through the caller's own calendar (`calendar.apiRead`; `calendar.apiWrite`, a change of kind `request` made after commit with the provider's answer as its `result`; CalendarProvider 1.4). [`registry/test/calendar.test.ts`](../registry/test/calendar.test.ts), [`calendar-find-time.test.ts`](../registry/test/calendar-find-time.test.ts), [`calendar-api.test.ts`](../registry/test/calendar-api.test.ts).
207
+
208
+ ### Spaces and the shell contracts
209
+
210
+ The kernel-provided `spaces` module (`spacesModule`, [Space](contracts/space.md)): the organisation's spaces, one `space_grant` row per space and audience (everyone or a role), readable where the audience is everyone or a role the member holds (`principal.roles.contains(resource.audience)`, which the policy compiler now compiles for a String column: `eloxiv_ctx.has_role(<column>)` in SQL, a live directory-fact subquery in sync), and each member's own preferences. `spaces.define` and `spaces.remove` need `eloxiv.spaces.manage` (kernel migration `0028_spaces_manage` gives it to existing administrators). `agent.send` takes a [ScreenContext](contracts/screen-context.md) snapshot as `screen` and shows its references to the model. The kernel-provided `app_state` module (`appStateModule`, schema `eloxiv_app_state`, ScreenContext 1.1.0) keeps each person's app state per tab with compare-and-set and the commands for their screen until a tab acknowledges them. The kernel also serves `POST /api/batch` (read batches, [Invocation](contracts/invocation.md)) and WebMCP's agent sessions and tool manifest (`/api/webmcp/*`, [ClientSDK](contracts/client-sdk.md#webmcp)); the `flags` module has labs (personal opt-in, Flags 1.1.0), the `settings` module declares each person's language, time zone and theme (Settings, "Preferences"), and the renderers include chart, metric, change and file kinds (ResultRendering 1.1.0). The other shell contracts are in `@eloxiv/shell-core` and `@eloxiv/client` (see [contracts/README.md](contracts/README.md#shell-contracts-published)); the kernel imports no UI (`tools/fallow/kernel-headless.json`, [`kernel-headless.test.ts`](../tools/done/test/kernel-headless.test.ts)).
211
+
212
+ ### Shell and desktop
213
+
214
+ - **The example app's reference screens** (criterion 11, decision 11; [example-app.md](example-app.md)): UI items over `@eloxiv/client`, `@eloxiv/client/chat` and the Directory's member routes: `home-ui-foldkit` (the launcher at `/`: the person's spaces and everything installed), `inbox-ui-foldkit` (the unified inbox at `/inbox`), `members-ui-foldkit` (member administration at `/admin/members`), `people-ui-foldkit`, `mail-ui-foldkit` and `calendar-ui-foldkit`, each 0.1.0, with Story and Scene tests (`registry/test/shell-foldkit-reference.test.ts`). The browser journeys are `e2e/example.spec.ts` (J1 to J8, the providers' protocol fakes and a scripted model from `e2e/example.ts` and `e2e/model.ts`); the desktop journey (desktop 0.5.4) runs J1 to J8 in the webview, Alice's then Bob's in one session each, with a paired headless runner (`e2e/runner.ts`).
215
+ - **Shell** ([`registry/app/shell-foldkit`](../registry/app/shell-foldkit), item `shell-foldkit` 0.8.2 (on the client core; code-split since 0.8.0: each screen a chunk loaded when a route first shows it, routed and linked meanwhile from its declaration's literal fields, which the build reads (`screenMeta.ts`), its Subscriptions hosted in one shell entry (`hostedSubscriptions`); the MAKE view host loaded by its mount; a chunk that cannot load shows an error with a reload), whose one screen marked `home: true` takes `/` (the example app's launcher); decision 10, proven in [spikes/foldkit-proof.md](spikes/foldkit-proof.md)): Foldkit 0.170.0 (The Elm Architecture over Effect: one Schema-typed Model, Messages, a pure update returning Commands, Subscriptions, ManagedResources), Foldkit UI's Dialog, StyleX 0.19.1 over the theme's `tokens.stylex.ts`, Vite 8 with `@foldkit/vite-plugin` and `@stylexjs/unplugin`; no React, router library, component kit or Tailwind. Sign-in, organisations (the switch discards the screen and marks the replica opening in one update, so no render pairs the new organisation with the old one's rows), routes from the installed views that have a screen (`src/screens/`, filled by UI items such as `hello-ui-foldkit`; `src/screen.ts` is their contract), **slots** (a screen names the slots it shows; the views other modules contribute to them are shown beside it as panels, their own screens created and discarded with it for the same replica, and contributed view commands as links: `notes-ui-foldkit` beside hello's greetings), **MAKE views** (`/make/<module>`, `src/make.ts` around the sandboxed host `src/makeView.ts`: the module's view and actions from `make.view`, mounted for the signed-in session in the selected organisation, opened afresh in another), sign-out with revocation kept and retried, an accessible appearance dialog (light, dark or the system's; left to right or right to left), the **locale** (`src/locale.ts`: the shell's text as a catalog in Paraglide's compiled shape, English and Arabic, negotiated from the browser's languages through `@eloxiv/shell-core`; `lang` and the direction follow the language chosen), the **error view** (a path nothing is installed at, organisations or a replica that cannot be reached), a minimal **settings frame** (`/settings`: profile, the organisation's members from `GET /api/org/members`, language, appearance), the **desktop sign-in approval** (`/desktop/sign-in`, shell-foldkit 0.6.0: what asks, where its code goes and the request's fingerprint, approved only by the person's click; signed in first when signed out) and a small **UI kit** (`src/ui.ts`: button, text field, select, alert, card, error view, radio group). Screens of the kernel's own views name their route (`chat-ui-foldkit` at `/agent/conversation`, `approvals-ui-foldkit` at `/approvals/request`, both over `@eloxiv/client/chat`; decision 11 keeps them deliberately basic); the shell refuses to start with one that collides with a manifest view's route, its own (`/`, `/settings`, `/make`, `/desktop`) or another screen's. A screen's and a panel's Subscriptions run for that instance of it, and every Message they send names it, so one sent before an organisation switch (a snapshot of the previous replica, still in flight) is dropped; a view contributed to slots twice is two panels, each with its own. Not built, by decision 11: a command palette, devtools, feedback and onboarding flows, broad settings pages, an admin control plane, rich kits; the React shell had none of them, so nothing was dropped. Runs on one in-process client core (`@eloxiv/client/runtime`, shell-foldkit 0.7.0: its session, durable sign-out, organisation and generation, replica, live queries, writes and teardown, the same core the daemon serves) and reads and writes through `@eloxiv/client/foldkit`'s bridge to it ([ClientSDK](contracts/client-sdk.md#ui-bindings)); bearer tokens stay in the core and the adapter's `Credentials`, outside the Elm state (the Model names a session by handle), and the password is never held. Test builds (`VITE_ELOXIV_TEST_HOOKS=1`) call a hook after every render (`src/testHooks.ts`). Marks route timings for the route-change benchmark and calls the desktop host's `eloxiv_interactive` command when it runs in Tauri.
216
+ - **Theme** ([`registry/app/themes/default`](../registry/app/themes/default), item `theme` 0.2.0, kind `theme`): the default [ThemeTokens](contracts/theme-tokens.md) and what `themeCss` and `themeStylex` write from them, `theme.css` and `tokens.stylex.ts` (`pnpm --filter @eloxiv/registry-source themes`). The shell imports `tokens.stylex.ts`.
217
+ - **Desktop** ([`registry/app/desktop`](../registry/app/desktop), item 0.4.1, which embeds the app's shell, built into `desktop/dist` (`scripts/shell.ts`: `ELOXIV_DESKTOP_SHELL`, else `shell-foldkit`, else the retired React `shell`), so updating it never changes the shell an app ships; 0.3.0 added the [Host](contracts/host.md) contract: `host.ts` over `src-tauri/src/host.rs`, the launch deep link and secure storage in the OS keychain, updates a documented stub): Tauri 2.12 host template that loads the shell and runs the daemon sidecar (started from Rust with `--port` and `--stdin-lifeline`, stopped on exit), reports launch to interactive, and builds on Linux, macOS and Windows. `pnpm exec tauri build` from the app root runs `scripts/prepare.ts` first (the sidecar for the target triple, through `@eloxiv/daemon/build-sidecar`, and the shell). Harness scripts: `measure-launch.ts`, `webdriver-e2e.ts` (WebKitWebDriver on Linux, msedgedriver on Windows) and `hooks-e2e.ts` (macOS, with the `e2e` cargo feature), one journey with two drivers: its checks, verdicts and page code are shared (`journey-checks.ts`, `journey-system.ts`), and `registry/test/desktop-journey.test.ts` holds both drivers to every check. See its README and "Desktop and React Native in CI".
218
+ - **Desktop on Rune** ([`registry/app/desktop-rune`](../registry/app/desktop-rune), item `desktop-rune` 0.6.7 (with the agent chat, installers, the Host contract's deep links with single instance, secure storage and signed updates with rollback, and the person's new notifications as OS notifications while it runs), decision 14; [its page](registry/desktop-rune.md); in `examples/hello-app` through `eloxiv add desktop-rune`): a native host in Rust on Rune (pinned at `eb5ae6c9`, with its five `[patch.crates-io]` entries, in a Cargo workspace of its own) over the app's own daemon through LocalClient v1: it starts the sidecar with a per-launch host secret and the stdin lifeline, waits for `/health`, and draws sign-in in the system browser, the organisation switcher, hello's live greetings with an optimistic and a refused write, a MAKE view drawn natively from the closed vocabulary ([Sandbox, "Native hosts"](contracts/sandbox.md#native-hosts)) and sign-out, light and dark, left to right or right to left, every control named for AccessKit. Requests run off the UI thread; nothing of an older generation is shown. Its protocol types are generated with typify from the contracts' JSON Schemas (`crates/eloxiv-local-client`, a freshness test regenerates and compares). The item ships the app's daemon entry (`sidecar/daemon.ts`, `daemon-node.ts`: the daemon with the app's `clientApp`) and `scripts/build-sidecar.ts`, which compiles it into `target/sidecar/eloxiv-daemon`; the host finds it beside itself (a package: then on a free port, with the app's own state directory and the servers `app.json` names), in its workspace's `target/sidecar` (`cargo run`), or runs the entry from source with Bun. `scripts/package.ts` makes installers with cargo-packager (`.app` and `.dmg`, NSIS, `.deb` and AppImage) from `app.json` (the app's identity and host settings, also compiled into the host and read by the release signer `eloxiv-update`), signed only with credentials, and `scripts/measure-launch.ts` measures launch to interactive from the host's probe line; CI's `desktop-rune-package` job builds, installs and launches them on the three systems and measures the 1.5 s budget ([ci.md](ci.md#the-packaged-rune-host-desktop-rune-package)). The person approves its sign-in on the web shell's `/desktop/sign-in` (shell-foldkit 0.6.0), the daemon's default sign-in page (`ELOXIV_SHELL_URL`). `cargo test` drives it in Rune's headless Runtime against a fake `/client/v1`; `tests/journey.rs` drives it against a real daemon, kernel and zero-cache, started by [`registry/test/desktop-rune-journey.test.ts`](../registry/test/desktop-rune-journey.test.ts) on Bun and on Node (`ELOXIV_RUNE_JOURNEY=1`). CI's `rust` job (`mise run rust:check`) runs on Linux, macOS and Windows when a Rust input changed ([ci.md](ci.md#the-rust-crates-rust)), and its `rune-journey` job the live journey on Linux (each optimistic write made with zero-cache's push held at a barrier, so its prediction is seen before the server answers) ([ci.md](ci.md#the-rune-journey-rune-journey)).
219
+ - **Mobile on Expo** ([`registry/app/mobile`](../registry/app/mobile), item `mobile` 0.3.10, decision 14; [its page](registry/mobile.md); in `examples/hello-app` through `eloxiv add mobile`): Expo 58 and React Native 0.88 (pinned as the React Native guard), its own npm project beside the app, Metro bundling the app's contracts and sync schema. One in-process client core (`@eloxiv/client/runtime`) with an expo-sqlite replica and the session in `expo-secure-store` (failures as `HostFailure`, durable sign-outs, nothing resurrected after a reinstall, the auth cookie React Native keeps cleared, the person and organisation last open remembered with the session, so an offline cold start shows their last synced rows at once, marked offline: the client core's offline start); screens for sign-in with two-factor, organisations, a live list with optimistic and refused writes, the agent's chat with consent and approval cards, notifications; deep links and notification responses through one View-contract parser and a gate that waits for the person and the organisation's generation; push through `notifications.registerInstallation` with the native token, decision buttons redeemed at `POST /api/notifications/decide` on iOS and, on Android, the request opened with the verdict preselected for the person to confirm; the Host contract with 1.1.0's `pushToken` and `onNotificationResponse`. Tests: `registry/test/mobile-host.test.ts`; CI's `mobile` lane drives it on an Android emulator ([ci.md](ci.md#the-mobile-lanes)), and `mobile-ios` attempts an iOS simulator build.
220
+ ## Proofs in the full check
221
+
222
+ The shell contracts' kits and the kernel-headless check are listed in [contracts/README.md](contracts/README.md#shell-contracts-published) and [`kernel-headless.test.ts`](../tools/done/test/kernel-headless.test.ts).
223
+
224
+ | Proof | Test |
225
+ | --- | --- |
226
+ | Files, Search, Ingestion and StorageBackend kits (local directory and S3 protocol fake; rclone's `serve s3` where installed); search hits equal what the read policy admits (differential); finalize and ingest finish after a restart without indexing twice; DocumentSource documents ingested over a Connection | [`files.test.ts`](../packages/testing/test/files.test.ts), [`search.test.ts`](../packages/testing/test/search.test.ts), [`ingestion.test.ts`](../packages/testing/test/ingestion.test.ts), [`storage-backend.test.ts`](../packages/testing/test/storage-backend.test.ts), [`search-index.test.ts`](../packages/testing/test/search-index.test.ts), [`ingestion-restart.test.ts`](../packages/testing/test/ingestion-restart.test.ts), [`ingestion-documents.test.ts`](../registry/test/ingestion-documents.test.ts) |
227
+ | Each surface yields the same audit record and outbox event for the same call; the dispatcher delivers to the other module's subscriber | [`registry/test/surfaces.test.ts`](../registry/test/surfaces.test.ts) |
228
+ | Criterion 2, as a property: generated actors, records, actions, inputs and keys through all eight surfaces (typed client, HTTP, MCP, agent tool, CLI, scheduled job, workflow step, inbound webhook) give the same identity, policy result, approval and consent, idempotency, audit record and outbox event, by one model with each surface's documented differences; every listing (OpenAPI, `eloxiv actions`, MCP `tools/list`, agent tools) shows exactly what the caller can reach; an action the policy hides, or an agent tool group the app disabled, is unreachable on every surface | [`packages/testing/test/surfaces-property.test.ts`](../packages/testing/test/surfaces-property.test.ts) |
229
+ | Unauthenticated calls denied and audited on every surface; idempotent replay (the same receipt on all four surfaces; outputs and receipts enveloped and never confused, see `envelope.test.ts`) and conflict on every surface (agent keyed by tool-call id); invalid input rejected on every surface | same file |
230
+ | The approval stage blocks on every surface and nothing is written | [`registry/test/approval.test.ts`](../registry/test/approval.test.ts) |
231
+ | Record authorisation before the handler and over every affected row; replays return only receipts (revoked grant, new forbid, create-or-get, nested, map, count and joined-entity outputs, deletes, best effort), refused to removed members and for old receipt formats; idempotency scoped by organisation, including concurrent calls; early failures and uncompilable policies audited | [`packages/testing/test/invocation.test.ts`](../packages/testing/test/invocation.test.ts) |
232
+ | A module role cannot read or write another module's schema, the kernel's tables, the auth tables, or create objects elsewhere | [`registry/test/isolation.test.ts`](../registry/test/isolation.test.ts) |
233
+ | No readable projection (every synced query of the app, every entity's policy-filtered SQL view) exposes a private greeting's text | [`registry/test/sync.test.ts`](../registry/test/sync.test.ts) |
234
+ | Sync follows the organisation the client acts in, with a replica per user and organisation | same file |
235
+ | Queries reaching related tables are refused by the sync endpoint | [`packages/testing/test/sync-scope.test.ts`](../packages/testing/test/sync-scope.test.ts) |
236
+ | The client SDK imports nothing DOM- or Node-only: fallow rule pack (static), the client's `tsc` without DOM or Node types, and a neutral-platform bundle run in a VM context with only web-standard globals that signs in, calls an action and syncs | [`tools/fallow/portable-client.json`](../tools/fallow/portable-client.json), [`registry/test/sync.test.ts`](../registry/test/sync.test.ts) |
237
+ | The client SDK on React Native (Hermes, release APK on an Android emulator; CI run 41814919666): sign-in, an action, another client's row synced into an `expo-sqlite` replica and read back offline by a new process (CI job `react native`, not `mise run check`) | [`tools/scripts/react-native-harness.ts`](../tools/scripts/react-native-harness.ts), [`journey.ts`](../tools/react-native/journey.ts) |
238
+ | The example's desktop host on Linux, macOS and Windows: release build with its sidecar, the journey inside the webview, launch to interactive within budget (CI jobs `desktop`, not `mise run check`) | [`tools/scripts/desktop-lane.ts`](../tools/scripts/desktop-lane.ts), [`webdriver-e2e.ts`](../registry/app/desktop/scripts/webdriver-e2e.ts), [`hooks-e2e.ts`](../registry/app/desktop/scripts/hooks-e2e.ts), [`measure-launch.ts`](../registry/app/desktop/scripts/measure-launch.ts) |
239
+ | Action to second client, headless and policy-filtered, including a sharing grant | [`registry/test/sync.test.ts`](../registry/test/sync.test.ts) |
240
+ | Action to second client in two browsers; private greetings withheld; sign-out revokes the session and closes the replica | [`e2e/second-client.spec.ts`](../e2e/second-client.spec.ts), [`e2e/sign-out.spec.ts`](../e2e/sign-out.spec.ts) |
241
+ | Cedar compiles to SQL and ZQL with Cedar's type semantics; differential against Cedar in memory (1,500 generated cases) and in Postgres (300); every real module's policy set, and MAKE's installed and upgraded ones, against Cedar over generated rows through the invocation path's SQL, row-level security as installed, the query surface and sync (the oracle in `packages/kernel/test/policy-oracle.ts`); ill-typed policies stop startup | [`packages/kernel/test/policy-compiler.test.ts`](../packages/kernel/test/policy-compiler.test.ts), [`packages/testing/test/policy-sql.test.ts`](../packages/testing/test/policy-sql.test.ts), [`registry/test/policy-differential.test.ts`](../registry/test/policy-differential.test.ts), [`packages/testing/test/make-policy-differential.test.ts`](../packages/testing/test/make-policy-differential.test.ts), [`packages/kernel/test/policy-schema.test.ts`](../packages/kernel/test/policy-schema.test.ts), [`packages/testing/test/policy.test.ts`](../packages/testing/test/policy.test.ts) |
242
+ | Outbox: a poison event (defect) is retried with backoff without stalling others; recovery without re-running succeeded subscribers | [`packages/testing/test/outbox.test.ts`](../packages/testing/test/outbox.test.ts) |
243
+ | `eloxiv add` provenance; headless assembly (no UI files or dependencies); both examples match their lockfiles and the registry | [`packages/cli/test/cli.test.ts`](../packages/cli/test/cli.test.ts) |
244
+ | A CLI-assembled headless app works through the SDK and MCP alone | [`registry/test/headless.test.ts`](../registry/test/headless.test.ts) |
245
+ | Account security through the client SDK with a real SMTP server and an OAuth provider fake: no session for an unverified address when required, password reset through the mailed link ending every session, a change of address confirmed from the current one, two-factor (a challenge and no credential for the password alone; a code or a backup code once; a challenge's few wrong codes), OAuth sign-in joining an account only when both sides verified the address, untrusted callback origins refused | [`account-security.test.ts`](../packages/testing/test/account-security.test.ts) |
246
+ | Directory administration over HTTP and the client SDK: invitations admitting only their own verified address once, DNS-verified domains for one organisation with self-service joining of verified addresses, permission explanations, atomic group edits with metadata, administration refused without `eloxiv.directory.manage` | [`directory-admin.test.ts`](../packages/testing/test/directory-admin.test.ts) |
247
+ | Avatars seen only by their person and people sharing an organisation, only accepted image types and sizes, one shared lookup and change notifications; the session controller's one verified read, forgetting a refused session, keeping an unchecked one, sign-out stopping reads first; safe return paths | [`profile-session.test.ts`](../packages/testing/test/profile-session.test.ts) |
248
+ | `setup` on a fresh database logs no Better Auth schema mismatch | [`packages/testing/test/setup.test.ts`](../packages/testing/test/setup.test.ts) |
249
+ | JSON Schema emission is current | [`packages/contracts/test/json-schema.test.ts`](../packages/contracts/test/json-schema.test.ts) |
250
+ | One definition per module (decision 9): every generated sync file is current; for generated Drizzle tables of any shape the emitted file passes the kernel's startup check (the generator cannot produce a mismatch), and so does every generated file of the repository; each kind of tampering with a generated file is named, and the kernel refuses to start with one | [`sync-generated.test.ts`](../packages/testing/test/sync-generated.test.ts) |
251
+ | Setup refuses a database that disagrees with a module's Drizzle tables (a missing column, another kind of value, NULL where the table says `notNull`) | [`entity-columns.test.ts`](../packages/testing/test/entity-columns.test.ts) |
252
+ | Criterion 19: registry and example modules declare fields only in their Drizzle tables; the sync boundary rule is configured over every guarded path and fallow, run on a violating fixture, refuses every direct import of `@rocicorp/zero` there and none in the client; the import graph and the package graph reach the engine only through the packages that own it | [`one-definition.test.ts`](../tools/done/test/one-definition.test.ts) |
253
+ | Daemon alone: loopback, Host and Origin checks, per-client tokens, local pairing (wrong, expired, reused codes), secret stores, harness stream parsers on recorded real runs, the fake harness, cancellation and time limits, the compiled sidecar and its commands | [`packages/daemon/test/`](../packages/daemon/test) |
254
+ | Daemon and DeviceControl kits: pairing (wrong, expired, reused codes; a credential issued once), custody, revocation cutting a running daemon off, the relay as the person and as the person's agent (both stream formats), consent holding a destructive relayed call, a headless runner serving a browser SDK call and a scheduled job, SIGKILL mid-turn then restart settling the turn once, follow-up turns, ACP agents (tools-only and fail-closed); devices and sessions, device commands (workspace confinement, consent, revocation, companions), terminals, capability reports, push, the tools-only profile and the organisation's switches | [`daemon.test.ts`](../packages/testing/test/daemon.test.ts) |
255
+ | Real Claude Code and Codex turns through the adapters and the relay (gated: `ELOXIV_DAEMON_REAL_HARNESS=1`) | [`daemon-real.test.ts`](../packages/testing/test/daemon-real.test.ts) |
256
+ | The suite runs on the runtime CI selected | [`packages/testing/test/runtime.test.ts`](../packages/testing/test/runtime.test.ts) |
257
+ | Row-level security: side-effect updates, deferred triggers and `TRUNCATE` cannot touch forbidden rows; the compiled filter and RLS select the same rows; subscribers stay in the event's organisation | [`packages/testing/test/invocation.test.ts`](../packages/testing/test/invocation.test.ts), [`packages/testing/test/policy.test.ts`](../packages/testing/test/policy.test.ts), [`packages/testing/test/outbox.test.ts`](../packages/testing/test/outbox.test.ts) |
258
+ | The action contract: exact targets (upserts, joined updates, CTEs, untouched or extra targets fail as `Forbidden`), best-effort completion in result and audit, replay receipts; setup refuses rewriting foreign keys and hardens tables added by later migrations; the sync schema's column mappings are checked at startup | [`packages/testing/test/invocation.test.ts`](../packages/testing/test/invocation.test.ts), [`packages/testing/test/setup.test.ts`](../packages/testing/test/setup.test.ts), [`packages/testing/test/sync-scope.test.ts`](../packages/testing/test/sync-scope.test.ts) |
259
+ | Roles: the kernel role has no access to module tables; runtime roles have no `TRUNCATE`, DDL or policy control; setup refuses deferred triggers and `SECURITY DEFINER` functions | [`registry/test/isolation.test.ts`](../registry/test/isolation.test.ts), [`packages/testing/test/setup.test.ts`](../packages/testing/test/setup.test.ts) |
260
+ | Sync applies the policy of the table the query really reads | [`packages/testing/test/sync-scope.test.ts`](../packages/testing/test/sync-scope.test.ts) |
261
+ | The policy cache distinguishes principal attributes | [`packages/kernel/test/policy-cache.test.ts`](../packages/kernel/test/policy-cache.test.ts) |
262
+ | Shell-only and module-without-UI assemblies build, typecheck and link only to installed routes; replacing a UI item's screen (`hello-ui-foldkit`) touches nothing else; retired items (`shell`, `hello-ui`) are refused by `eloxiv add` and reported, not broken, by `diff` and `update` | [`packages/cli/test/cli.test.ts`](../packages/cli/test/cli.test.ts), [`packages/cli/test/shell-assemblies.test.ts`](../packages/cli/test/shell-assemblies.test.ts) |
263
+ | The shell (Foldkit): the session, organisation switch, optimistic write and rollback, the dialog's keyboard, slots and the MAKE screen as Foldkit Story and Scene tests; credentials kept out of the Elm state and revocations kept until confirmed; the adapter's resource, Subscriptions and Effects against a real kernel and zero-cache; in the browser, StyleX's compiled CSS in light, dark and right to left, the dialog's focus, routing, IndexedDB per organisation, one replica connection at a time; notes' contributed view beside hello's greetings, live, and gone with them on a switch | [`registry/test/shell-foldkit.test.ts`](../registry/test/shell-foldkit.test.ts), [`registry/test/shell-foldkit-slots.test.ts`](../registry/test/shell-foldkit-slots.test.ts), [`registry/test/shell-foldkit-review.test.ts`](../registry/test/shell-foldkit-review.test.ts), [`registry/test/foldkit-adapter.test.ts`](../registry/test/foldkit-adapter.test.ts), [`e2e/shell.spec.ts`](../e2e/shell.spec.ts), [`e2e/slots.spec.ts`](../e2e/slots.spec.ts) |
264
+ | The shell's reference layer (decision 11): settings (members of the organisation selected, never another's), the locale (lookup negotiation, `lang` and direction), the error view; the chat and approval screens (a send under a key a Command makes, as the session's handle, the transcript and run, a consent prompt decided by the person, approvals decided); the headless chat SDK's guarantees as pure transitions, against a stub server and against the agent conformance kernel on its wire format (one send per key, a lost answer retried under its key, a send's identity outside the screen and settled only by a definitive outcome for its key, looked up by its key in the receipt store, decisions under their own keys, answers counted only for their request and conversation, streamed text by run and model step, `run-finished` ending a run the replica lags on, the stream reconnecting after a drop and closing when interrupted, consent decided through the SDK, refusals typed); screen and panel Messages per instance (a late snapshot of the previous organisation dropped), screen routes checked for collisions, MAKE views opened without running an action; the members route for sessions only, read under the membership's lock; a React app's update keeping its shell; the reference screens assembled through the CLI build and typecheck | [`registry/test/shell-foldkit-settings.test.ts`](../registry/test/shell-foldkit-settings.test.ts), [`registry/test/shell-foldkit-chat.test.ts`](../registry/test/shell-foldkit-chat.test.ts), [`registry/test/chat-sdk.test.ts`](../registry/test/chat-sdk.test.ts), [`registry/test/chat-sdk-review.test.ts`](../registry/test/chat-sdk-review.test.ts), [`registry/test/shell-foldkit-isolation.test.ts`](../registry/test/shell-foldkit-isolation.test.ts), [`registry/test/chat-sends.test.ts`](../registry/test/chat-sends.test.ts), [`packages/testing/test/members-route.test.ts`](../packages/testing/test/members-route.test.ts), [`packages/cli/test/cli.test.ts`](../packages/cli/test/cli.test.ts), [`packages/cli/test/shell-assemblies.test.ts`](../packages/cli/test/shell-assemblies.test.ts), [`e2e/shell.spec.ts`](../e2e/shell.spec.ts) |
265
+ | A failed server sign-out is reported and retried until revoked | [`e2e/sign-out.spec.ts`](../e2e/sign-out.spec.ts) |
266
+ | Outbox dead letters: a poison subscriber dead-letters after its policy without blocking others, is listed, retried and discarded by an organisation administrator (authorised, audited); trigger dead letters and the operator log | [`packages/testing/test/outbox.test.ts`](../packages/testing/test/outbox.test.ts), [`packages/testing/test/dead-letters.test.ts`](../packages/testing/test/dead-letters.test.ts) |
267
+ | Release: a failed migration or check leaves the database exactly as before; a failed hardening after committed module migrations leaves the module closed until a setup succeeds; concurrent setups serialise; held and stuck leases; declared non-transactional migrations; fresh equals upgraded snapshots; committed kernel and module snapshots; a stale client's write is refused (`ClientOutdated`) while its read works | [`packages/testing/test/release.test.ts`](../packages/testing/test/release.test.ts), [`packages/testing/test/release-atomic.test.ts`](../packages/testing/test/release-atomic.test.ts), [`registry/test/schema-snapshots.test.ts`](../registry/test/schema-snapshots.test.ts) |
268
+ | Readiness: not ready while migrations are pending, degraded while dead letters accumulate, or while the agent's default model or a connector's settings are missing | [`packages/testing/test/readiness.test.ts`](../packages/testing/test/readiness.test.ts) |
269
+ | The agent's readiness (configured, missing, unavailable; `unknown` only a client's) and the chat SDK holding sends, not drafts, until it is set up | [`packages/testing/test/agent-readiness.test.ts`](../packages/testing/test/agent-readiness.test.ts) |
270
+ | The app's own typed configuration (`defineAppConfig`, `KernelApp.config`): environment aliases, defaults, problems that stop the start | [`packages/kernel/test/app-config.test.ts`](../packages/kernel/test/app-config.test.ts) |
271
+ | Setup checklists as declared settings: per person on every device, shared per organisation, written by the person or their agent | [`packages/testing/test/checklists.test.ts`](../packages/testing/test/checklists.test.ts) |
272
+ | The shell's organisation switcher: the second organisation's data appears only after switching, writes go to it, the choice survives a reload; from a switch's intent on, no render (the test build's render hook) and no DOM mutation holds the previous organisation's rows, and the check catches an injected flash | [`e2e/org-switch.spec.ts`](../e2e/org-switch.spec.ts) |
273
+ | Contracts: every registered kernel contract has its schema, documentation and conformance kit; parity rows cite tests that exist | [`contracts.test.ts`](../tools/done/test/contracts.test.ts), [`parity.test.ts`](../tools/done/test/parity.test.ts) |
274
+ | Criterion 16's map: every threat in [security/threat-model.md](security/threat-model.md) (identity, policy, approval, MCP and OAuth, webhooks, the sandbox, the daemon, secrets) cites a test that exists (a kit's, only if some test file runs the kit) or states its limit, and every area has its section | [`threat-model.test.ts`](../tools/done/test/threat-model.test.ts) |
275
+ | Threat-model tests added with the map: an eligible approver's agent cannot approve a business approval (on the agent surfaces; the approver's own decision counts); the OAuth sign-in, consent and device pages refuse framing; a body past its limit is refused while it is still being sent on every route that takes one from anyone (OAuth, Better Auth, actions, RPC, MCP) | [`Approvals.ts`](../packages/testing/src/conformance/Approvals.ts) (kit), [`machine-identity.test.ts`](../packages/testing/test/machine-identity.test.ts), [`request-limits.test.ts`](../packages/testing/test/request-limits.test.ts) |
276
+ | The manifest, directory and policy scope: groups, roles and permissions in policies and row-level security; an action's policy confined to its declared entities; query views checked against Postgres's parse tree; failed directory writes audited | [`directory-policy.test.ts`](../packages/testing/test/directory-policy.test.ts), [`action-scope.test.ts`](../packages/testing/test/action-scope.test.ts), [`query-view-escape.test.ts`](../packages/testing/test/query-view-escape.test.ts), [`query-views.test.ts`](../packages/testing/test/query-views.test.ts), [`directory-audit.test.ts`](../packages/testing/test/directory-audit.test.ts), [`conformance-manifest.test.ts`](../packages/testing/test/conformance-manifest.test.ts), [`conformance-directory.test.ts`](../packages/testing/test/conformance-directory.test.ts) |
277
+ | Directory changes reach connected replicas live (group, role, permission, membership and sharing revocations, re-grants, signed-out sessions) | [`sync-revocation.test.ts`](../packages/testing/test/sync-revocation.test.ts) |
278
+ | Workflows, jobs and event triggers survive SIGKILL without losing or repeating side effects: one committed effect, the first outcome `succeeded` and any later one `replayed` (the kill is placed deterministically after the effect and before the journal records it) | [`durable-restart.test.ts`](../packages/testing/test/durable-restart.test.ts), [`workflow.test.ts`](../packages/testing/test/workflow.test.ts), [`scheduler.test.ts`](../packages/testing/test/scheduler.test.ts) |
279
+ | `eloxiv diff`, `update` (three-way merge, `--continue`), `eject`, immutable item versions, hardening against symlinks, binary files and npm pins | [`diff.test.ts`](../packages/cli/test/diff.test.ts), [`update.test.ts`](../packages/cli/test/update.test.ts), [`update-hardening.test.ts`](../packages/cli/test/update-hardening.test.ts) |
280
+ | Criterion 10 over every item of the real registry, through the executable: provenance, merge into local edits, conflicts and `--continue`, eject; every UI item replaced with the kernel untouched; an app of every server-side item typechecks | [`registry-items.test.ts`](../packages/cli/test/registry-items.test.ts) |
281
+ | `info`, `list`, `restore`, `doctor`, `clean`, `init --preset`, `mcp`, the runtime check; `agent` and `whoami` against a kernel | [`tools.test.ts`](../packages/cli/test/tools.test.ts), [`cli-agent.test.ts`](../packages/testing/test/cli-agent.test.ts), [`cli-surface.test.ts`](../registry/test/cli-surface.test.ts) |
282
+ | Business approval: rules hold calls on every surface, approvers decide, the approved call runs exactly once (also across a SIGKILL and with two kernel processes), only kernel workflows may execute an approved request | [`approvals.test.ts`](../packages/testing/test/approvals.test.ts), [`approvals-kernel.test.ts`](../packages/testing/test/approvals-kernel.test.ts), [`approvals-restart.test.ts`](../packages/testing/test/approvals-restart.test.ts) |
283
+ | Consent: an agent's call (agent tools, MCP, or an agent session on any surface) is held until the person decides, never by a header; remembered per session or always, revocable | [`action-consent.test.ts`](../packages/testing/test/action-consent.test.ts) |
284
+ | Work items and notifications: assigned to people or groups, synced only to them (a group's item leaves a member's replica live when they leave the group), system email over SMTP with one-click unsubscribe, channel retries | [`work-items.test.ts`](../packages/testing/test/work-items.test.ts), [`notifications.test.ts`](../packages/testing/test/notifications.test.ts), [`notification-channel.test.ts`](../packages/testing/test/notification-channel.test.ts), [`inbox-sync.test.ts`](../packages/testing/test/inbox-sync.test.ts); push installations, APNs and FCM delivery and every class of provider answer against protocol fakes ([`push.test.ts`](../packages/testing/test/push.test.ts)), decisions from a notification ([`decision-tokens.test.ts`](../packages/testing/test/decision-tokens.test.ts)) |
285
+ | Credentials: a person's session and their agent session resolve to the same actor; agent sessions, API tokens and OAuth access tokens are refused for management operations and sync | [`credentials.test.ts`](../packages/testing/test/credentials.test.ts) |
286
+ | MachineIdentity: the OAuth 2.1 server (registration, PKCE with or without `redirect_uri` at the token endpoint, repeated parameters refused, consent, device flow, refresh rotation, revocation, audience binding), API tokens and scopes, service principals; `/mcp` answers 401 with an RFC 9728 challenge | [`machine-identity.test.ts`](../packages/testing/test/machine-identity.test.ts) |
287
+ | Password sign-in through the OAuth pages is rate limited like Better Auth's own endpoint, in one bucket per address that `x-forwarded-for` cannot choose (Better Auth's production limiter on) | [`sign-in-limit.test.ts`](../packages/testing/test/sign-in-limit.test.ts) |
288
+ | Ingress: verified deliveries accepted once and processed exactly once, also when the kernel dies after acceptance or after the handler acted; replay protection on the signed payload (a GitHub body under another delivery id joins the first); chunked bodies refused past the limit before they end, slow ones answered 408 | [`ingress.test.ts`](../packages/testing/test/ingress.test.ts), [`ingress-restart.test.ts`](../packages/testing/test/ingress-restart.test.ts) |
289
+ | The CLI against a running kernel: `login`, `actions`, `call` (surface `cli`), parallel calls refreshing an expired sign-in once under a lock, `logout` (kept credentials when revocation fails) | [`cli-surface.test.ts`](../registry/test/cli-surface.test.ts) |
290
+ | A stale client's write is refused with `ClientOutdated` on every surface and with every credential, and on MCP from an Eloxiv client's `clientInfo.version` | [`client-version.test.ts`](../packages/testing/test/client-version.test.ts) |
291
+ | The query surface (decision 6): one read-only SELECT over published views, parsed by Postgres's grammar and checked against its analysed tree, read as a role that can read only the surface's views, each row filtered by policy exactly as sync filters it; typed columns, row limit, statement timeout, audit, every surface; 115 adversarial queries refused | [`query-surface.test.ts`](../packages/testing/test/query-surface.test.ts) |
292
+ | The query surface's limits (result and value size measured in Postgres, temporary files, queries per person and in all, no stall of other invocations under sixteen slow queries) and its encoding (no module's cast to `json` or `text` ever runs: output columns and encoding-function arguments of built-in base types only) | [`query-surface-limits.test.ts`](../packages/testing/test/query-surface-limits.test.ts), [`query-surface-casts.test.ts`](../packages/testing/test/query-surface-casts.test.ts) |
293
+ | Settings: keyed reads through the scope order, authorisation per level, schema validation, sync of each person's own and organisation's values only, audit, `ctx.settings`, sensitive schemas refused; the client skipping values that no longer decode | [`settings.test.ts`](../packages/testing/test/settings.test.ts), [`platform.test.ts`](../packages/contracts/test/platform.test.ts), [`platform-sync.test.ts`](../packages/testing/test/platform-sync.test.ts) |
294
+ | Flags: targeting precedence, deterministic rollout, administrator-only changes, audit, each person's replica holding all of their applicable rules (unbounded) and evaluating them, rollouts included, as the kernel does, `ctx.flags` | [`flags.test.ts`](../packages/testing/test/flags.test.ts), [`platform.test.ts`](../packages/contracts/test/platform.test.ts), [`platform-sync.test.ts`](../packages/testing/test/platform-sync.test.ts) |
295
+ | A handler's role never changes under its concurrent SQL while `ctx.settings`, `ctx.flags` and `ctx.queryView` read; the platform read functions' owner, grants and answers; nor while a helper that switches the connection's role runs (`ctx.files`, `ctx.ingestion`, `ctx.sharing`, `ctx.history`, `ctx.workItems`: the handler's statements wait, `db/HandlerGate.ts`) | [`handler-role.test.ts`](../packages/testing/test/handler-role.test.ts), [`handler-gate.test.ts`](../packages/testing/test/handler-gate.test.ts) |
296
+ | Entity references: a module reads another module's record only through `ctx.references.read`, under the owner's read policy and row-level security, in one statement (the handler's concurrent SQL never runs as the owner's role); its own SQL on the owner's table is refused. No module loads a connector's code: capabilities only through `ctx.connections` | [`entity-references.test.ts`](../packages/testing/test/entity-references.test.ts), [`tools/done/test/module-imports.test.ts`](../tools/done/test/module-imports.test.ts) |
297
+ | The query surface and the platform reads under setup's steps: their views, functions and roles are the kernel's recorded state (a change refused), the platform role's access to `settings` is that module's (repaired), a second setup repairs nothing, and a module migration can retype a column its query-surface view reads | [`platform-state.test.ts`](../packages/testing/test/platform-state.test.ts) |
298
+ | An agent run on a paired device: the turn runs once the person consents, from the typed client or the agent client's `send` with `device`; a run cancelled mid-turn cancels its turn, the runner stops the harness, and nothing it asks for afterwards runs | [`agent-device.test.ts`](../packages/testing/test/agent-device.test.ts) |
299
+ | The agent: a multi-turn run calls two actions and a query, agent-originated in the audit; consent holds a destructive call mid-run and the run resumes on approval; limits, cancellation; conversations sync only to their owner; the HTTP event stream | [`agent-runtime.test.ts`](../packages/testing/test/agent-runtime.test.ts) (the AgentRuntime kit), [`agent-sync.test.ts`](../packages/testing/test/agent-sync.test.ts) (client SDK and zero-cache replicas) |
300
+ | Durable agent runs: SIGKILL between a tool's commit and its step's record resumes with the effect exactly once; a stored model call is never repeated; two kernels never advance one run | [`agent-restart.test.ts`](../packages/testing/test/agent-restart.test.ts) |
301
+ | Memory scoped per person and compaction within budget keeping facts; sub-agents within their tools and the person's permissions; the context x-ray adds up to what the model received; resources with precedence; budgets stop a run before the model call | [`agent-memory`](../packages/testing/test/agent-memory.test.ts), [`agent-delegation`](../packages/testing/test/agent-delegation.test.ts), [`agent-context`](../packages/testing/test/agent-context.test.ts), [`agent-resources`](../packages/testing/test/agent-resources.test.ts), [`agent-metering`](../packages/testing/test/agent-metering.test.ts), [`model-provider`](../packages/testing/test/model-provider.test.ts) |
302
+ | Every example module skill has eval cases that meet their thresholds through the agent runtime (scripted model in CI; `mise run evals` with a real one) | [`registry/test/evals.test.ts`](../registry/test/evals.test.ts), [`evals.test.ts`](../packages/testing/test/evals.test.ts) |
303
+ | The agent on a real model (the registry's `openai` connector): the ModelProvider kit; tool calls through the invocation path, streamed text, each call's context x-ray and metered real usage; consent approved and declined; business approval; cancellation mid-run; memory and delegation by the model's own choice (skipped without `ELOXIV_MODEL_OPENAI_API_KEY`; in CI, the `model live` workflow on pushes to main and build/**, never pull requests, which also runs `mise run evals` once on it, on Bun and on Node). Without a key, the connector against an OpenAI-compatible fake | [`agent-real-model.test.ts`](../registry/test/agent-real-model.test.ts), [`model-openai.test.ts`](../registry/test/model-openai.test.ts) |
304
+ | An external agent over MCP with OAuth, end to end: the MCP SDK's client against the example app's kernel process registers, authorises with S256 PKCE through the pages, lists exactly the person's reach, calls through the invocation path (audited on `mcp`, outbox event), and is stopped by revoking its grant; against the desk fixture, policy hides an action from the listing and a narrower scope lists and calls only itself | [`mcp-oauth.test.ts`](../registry/test/mcp-oauth.test.ts) |
305
+ | Secrets: ciphertext only, scope-bound ciphertext, audit without values, no module-role access, rotation and retired keys, HTTP management | [`secrets.test.ts`](../packages/testing/test/secrets.test.ts) |
306
+ | Connections: PKCE and a session-bound single-use state, one Connection per account with merged scopes, ciphertext-only custody, proactive, cross-process single-flight and rotation-safe refresh, 401 versus 403, membership on every use, every surface, disconnect, the custody seam | [`connections.test.ts`](../packages/testing/test/connections.test.ts) |
307
+ | Endpoint and shared Connections: remote MCP servers (none, named secret, OAuth discovered with dynamic registration, PKCE and the resource) and HTTP APIs (OpenAPI catalogue, bounded reads, same-origin pagination, writes held for consent), the destination policy, tool exposure, member, group and module grants; the client SDK's servers controller, consent popup and resume (against protocol fakes) | [`connector-mcp.test.ts`](../registry/test/connector-mcp.test.ts), [`connector-http-openapi.test.ts`](../registry/test/connector-http-openapi.test.ts), [`destinations.test.ts`](../packages/kernel/test/destinations.test.ts), [`client-connections.test.ts`](../registry/test/client-connections.test.ts) |
308
+ | Metering per connection: serialisation, bounded concurrency, Retry-After, shared cooldowns and quotas across processes | [`metering.test.ts`](../packages/testing/test/metering.test.ts) |
309
+ | The microsoft-graph and google connectors pass the MailProvider, CalendarProvider, DirectoryProvider and DocumentSource kits (against protocol fakes; google also **against real Google**, locally and in CI, directory read-only: docs/connectors/google.md "Proven connections") | [`connector-microsoft-graph.test.ts`](../registry/test/connector-microsoft-graph.test.ts), [`connector-google.test.ts`](../registry/test/connector-google.test.ts), real accounts: [`connector-live.test.ts`](../registry/test/connector-live.test.ts) (skipped until configured; Google's in CI job `live connector (google)`) |
310
+ | The Connection sync engine commits each page with its cursor and resumes after a crash or a process's death | [`connection-sync.test.ts`](../registry/test/connection-sync.test.ts) |
311
+ | Messaging through Ingress with linked identities: the slack connector over the Slack protocol fake (OAuth v2 install, Events API with url_verification and retries, 429 Retry-After, `{ ok: false }` errors, token rotation), and the reference connector (**against protocol fakes, and the real Slack test workspace**) | [`connector-slack.test.ts`](../registry/test/connector-slack.test.ts), [`messaging.test.ts`](../packages/testing/test/messaging.test.ts) (real Slack: [`connector-slack-live.test.ts`](../registry/test/connector-slack-live.test.ts) through a cloudflared quick tunnel, the `slack live` workflow, [`.github/workflows/slack-live.yml`](../.github/workflows/slack-live.yml), skipped without the variables) |
312
+ | Release review fixes: a lost lease stops its setup's work; migrations cannot end the transaction; security drift is repaired and reported; organisation switches never render another organisation's rows; aged deliveries never run | [`release-lease-loss.test.ts`](../packages/testing/test/release-lease-loss.test.ts), [`release.test.ts`](../packages/testing/test/release.test.ts), [`migration-check.test.ts`](../packages/kernel/test/migration-check.test.ts), [`readiness.test.ts`](../packages/testing/test/readiness.test.ts), [`e2e/org-switch.spec.ts`](../e2e/org-switch.spec.ts), [`dead-letters.test.ts`](../packages/testing/test/dead-letters.test.ts) |
313
+ | Optimistic writes reconcile with the server (criterion 6): inserts, updates and deletes confirmed; a module's own (custom) prediction shown before the server answers, replaced by the server's different result, rolled back with its typed error, refused with nothing kept or sent when it writes an undeclared table or throws, and `hello.wave`'s through zero-cache and the client core; every rejection kind (Forbidden, InvalidInput, ApprovalRequired, ConsentRequired, a conflict, a handler failure) rolled back on the client that made it with its typed error; a forbidden insert no other client ever saw; offline writes confirmed or refused on reconnect; a retried push replayed from its receipt; concurrent conflicting writes converging; the push endpoint's refusals; the greeting shown at once and a refused one gone, in the browser | [`optimistic.test.ts`](../packages/testing/test/optimistic.test.ts), [`predictions.test.ts`](../packages/testing/test/predictions.test.ts), [`registry/test/sync.test.ts`](../registry/test/sync.test.ts), [`registry/test/client-runtime.test.ts`](../registry/test/client-runtime.test.ts), [`e2e/optimistic.spec.ts`](../e2e/optimistic.spec.ts), [`packages/contracts/test/optimistic.test.ts`](../packages/contracts/test/optimistic.test.ts) |
314
+ | The Sandbox kit: no ambient authority (network, timers, modules, process, host globals), JSON-only boundary, each limit, a caught refusal still fails the run, nothing shared between runs | [`sandbox.test.ts`](../packages/testing/test/sandbox.test.ts) |
315
+ | MAKE: a hostile module's escapes (role changes, `set_config`, other modules', kernel and auth tables, the invocation context, functions, DDL, events and actions outside its profile, governance actions) refused; the kernel answers throughout hostile runs; its runtime role logged in directly has nothing more privileged to return to; the agent drafts, previews and asks to install, an administrator approves, a version bump and a rollback over the same schema; one commit per call without prepared transactions; the source checks and SQL guard; a view's step in the sandbox and the tree it may return; the shell's view host in Chromium (a hostile tree carrying an action's result reaching no server, controls routed to the view, listed actions only) | [`make-sandbox.test.ts`](../packages/testing/test/make-sandbox.test.ts), [`make-lifecycle.test.ts`](../packages/testing/test/make-lifecycle.test.ts), [`make-manifest.test.ts`](../packages/testing/test/make-manifest.test.ts), [`make-view-step.test.ts`](../packages/testing/test/make-view-step.test.ts), [`e2e/make-view.spec.ts`](../e2e/make-view.spec.ts) |
316
+ | No test run leaves temporary files or databases behind | [`tools/vitest/global-setup.ts`](../tools/vitest/global-setup.ts) (fails the run) |
317
+
318
+ ### Desktop and React Native in CI
319
+
320
+ Separate jobs beside the Bun and Node check, in [`ci.yml`](../.github/workflows/ci.yml) (backlog 9 and 10; criteria 11, 14 and 15). They run on the merge tier (pushes to main, pull requests into it: build/main's), when what they exercise changed since their last green run ([ci.md](ci.md)).
321
+
322
+ **`desktop (linux | macos | windows)`**, the kernel on Bun, and **`desktop (linux, node kernel)`**, the same Linux lane with the harness's kernel on Node (the host's daemon sidecar is Bun-compiled on every lane, decision 7; docs/ci.md) (Blacksmith `ubuntu-24.04` and `macos-15` on Apple M4, GitHub-hosted `windows-2025` (Blacksmith's Windows runner runs jobs in session 0, without an interactive desktop: the host's window is never shown and does not close on a close request; docs/progress.md, "build/criteria-12-14"); macOS runs on Blacksmith for the reason the check job does, the budgets need roughly developer-machine speed: on GitHub's `macos-15` VM, WKWebView took 1.6 s just to start loading the page and launch to interactive measured p95 2.2 s): PostgreSQL from the same mise prebuilt binaries on all three (on Windows `pg.sh` runs in the runner's MSYS bash, without a Unix socket directory, and mise sets `PGHOST=localhost`); Rust from mise, cached with `Swatinem/rust-cache`.
323
+
324
+ 1. [`tools/scripts/desktop-lane.ts`](../tools/scripts/desktop-lane.ts) `build`: `pnpm exec tauri build --no-bundle` of [`examples/hello-app/desktop`](../examples/hello-app/desktop) in release mode. Its `beforeBuildCommand` ([`desktop/scripts/prepare.ts`](../registry/app/desktop/scripts/prepare.ts), desktop item 0.2.0) compiles the daemon sidecar for the runner's target triple with `bun build --compile` (through the package export `@eloxiv/daemon/build-sidecar`, so an app assembled by the CLI builds it from its own dependencies) and builds the shell for the end-to-end system's ports.
325
+ 2. `e2e`: the example's kernel (Bun) and zero-cache on a fresh database, then the journey inside the real webview: sign-in against the kernel, the greetings list from the Zero replica, `hello.greet` written optimistically through the replica and confirmed through zero-cache, the sidecar answering `/health`, the `eloxiv_daemon` command and a fetch from the webview origin, and the sidecar stopping when the app quits.
326
+ - **Linux:** `webdriver-e2e.ts` through `WebKitWebDriver` (`webkit2gtk-driver`) under Xvfb, with a temporary `XDG_DATA_HOME` (a profile another checkout left in `~/.local/share/dev.eloxiv.app` once kept the shell from rendering).
327
+ - **Windows:** `webdriver-e2e.ts` through `msedgedriver` of the runner's WebView2 runtime version, attached (`debuggerAddress`) to the host started with WebView2's DevTools port open (`WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS`). Wry's own browser arguments override that variable, so the host template makes its main window in `setup` (`"create": false` in `tauri.conf.json`) and appends the variable's value to WebView2's defaults; without it neither msedgedriver's own launch nor an attach found the DevTools port (`DevToolsActivePort file doesn't exist`). The journey ends with sign-out and a window close request (`taskkill` without `/F`); the host kills its sidecar and waits for it to end.
328
+ - **macOS:** WKWebView has no WebDriver (`safaridriver` drives Safari only). `hooks-e2e.ts` runs the same journey, check for check, as a script the host injects into its main frame, from a build with the `e2e` cargo feature (only that build reads `ELOXIV_E2E_SCRIPT`; the measured release build is built separately without it; `ELOXIV_DESKTOP_JOURNEY=hooks` builds and runs it on Linux too). **Proven on macOS:** the real WKWebView host with its sidecar, the shell's sign-in, sync and optimistic writes from the `tauri://localhost` origin, a greeting confirmed by the server (a second client receives it), a refused one shown first and rolled back with its typed error, organisation isolation from the switch's intent on, the appearance dialog's focus and its keyboard handlers, sign-out, the daemon's CORS, and SIGTERM stopping the sidecar. **Not proven on macOS:** input through operating-system events or a WebDriver (the journey sets values, calls `click()` and dispatches keys to the shell's handlers in the page, so the browser's own Enter on a button and Tab moves do not run: the dialog's trap is checked by its handler and by focusing what lies outside it), and the exact release binary (the journey runs on the `e2e` build of the same source).
329
+ 3. `mise run bench` with `ELOXIV_BENCH_DESKTOP=1 ELOXIV_BENCH_ONLY=desktop`: `desktop-lane.ts launch` starts the system again and `measure-launch.ts` launches the release build 20 times (plus one killed outright, whose daemon must exit through its stdin lifeline), each from spawn to the host's interactive line on the harness clock; p95 against 1.5 s. With `ELOXIV_BENCH_DESKTOP=1` a missing measurement fails instead of reporting `PENDING`, and the job asserts `bench/results/latest.bun.local.json` holds a measured `desktop-launch` within budget. The check job does not build the host, so there `mise run bench` still reports desktop launch as pending, naming these lanes.
330
+
331
+ **`react native (hermes, android, bun | node)`** (a lane per runtime of the example's kernel; Blacksmith `ubuntu-24.04`: its Firecracker microVMs expose `/dev/kvm` with the CPU's virtualisation flags, which the emulator needs; the job opens the device to the runner): [`tools/react-native`](../tools/react-native) is a minimal Expo (SDK 58, React Native 0.88.1) app, outside the pnpm workspace (npm, its own lockfile). Metro bundles the client SDK and the example's module contracts and sync schema from this repository's TypeScript source (`@eloxiv/source`), and the release build compiles the bundle to Hermes bytecode (`expo prebuild`, `gradlew assembleRelease`, x86_64). [`tools/scripts/react-native-harness.ts`](../tools/scripts/react-native-harness.ts) starts the example's kernel and zero-cache, installs the APK on an Android 15 (API 35) emulator (`reactivecircus/android-emulator-runner`), reaches it over `adb reverse`, and launches the app twice:
332
+
333
+ 1. online: sign in, `hello.greet` through the typed client (Effect RPC over React Native's `fetch`), its own write arriving in the replica through zero-cache (React Native's `WebSocket`), then a greeting the harness writes as a second user from the host (another client) arriving too; then the rest of the client SDK an app on React Native uses:
334
+ - **optimistic writes** through the replica's generated mutators (`write`): a greeting in the replica while the harness holds the server's write back (a lock on the table: the server has not answered and the database does not hold the row), then confirmed once released; a farewell (refused by hello's policy) shown, then dropped, the server's answer its typed error (`Forbidden`);
335
+ - **a collaborative document** (`@eloxiv/client/collab`, Yjs over the kernel's WebSocket): the app edits the note hello's greeting left, the harness reads the edit back on the server as another member (`collab.readText`) and edits too (`collab.editText`), and that edit must arrive in the app;
336
+ - **the headless chat SDK** (`@eloxiv/client/chat`) against an agent kernel the harness runs in process ([`NotebookAgent.ts`](../packages/testing/src/conformance/NotebookAgent.ts): the notebook fixture, the agent and inbox modules, a scripted model): a send, the run's event stream reduced into `ChatState` to its end (React Native's `fetch` has no streaming body: the client reads each connection whole), and a destructive tool call held for consent (checked pending, nothing run), approved from the app, run exactly once (one successful audit record);
337
+ 2. offline, after `am force-stop`: a new app process opens the same replica with no server to reach and must read that greeting back.
338
+
339
+ The Foldkit adapter (`@eloxiv/client/foldkit`) is not part of it: Foldkit targets the browser, and a React Native app has its own UI model (decision 10). The guard found three things the client needed on Hermes, now fixed: the chat SDK sorted with `toSorted` (ES2023, which Hermes lacks); the collab client used `btoa`/`atob` and a WebSocket typing React Native's definitions do not have; and Yjs's random source on React Native (lib0 asks for `isomorphic-webcrypto`, and Hermes has no `crypto`), which an app provides: the guard resolves it to Expo's (`tools/react-native/webcrypto.ts`, `expo-crypto`), as [ClientSDK](contracts/client-sdk.md#react-native) describes.
340
+
341
+ The replica is SQLite through `expo-sqlite` (decision 7), via `storage: expoSQLiteStoreProvider()` from `@eloxiv/client/expo-sqlite`; the offline phase proves the rows are on disk, since a memory store would not survive the process. The harness checks the APK's bundle starts with Hermes bytecode's magic number and the app reports `HermesInternal`'s runtime properties (Static Hermes, bytecode version 99, release build). **Why this counts:** it is React Native's own runtime and networking (the native `fetch`, `WebSocket` and timers, plus Expo's standard polyfills such as `TextDecoder` and `structuredClone`), with the Hermes engine executing Metro's bytecode, not a VM shim; only the device is an emulator. **Not covered:** iOS (no iOS lane for the guard; the mobile host's `mobile-ios` attempt builds for the simulator on macOS, see [ci.md](ci.md#the-mobile-lanes); Hermes is the same engine), and a debug build loaded from Metro's server. The bare-VM proof in `registry/test/sync.test.ts` stays as the fast portability check.
342
+
343
+ The guard's own `tsconfig.json` is typechecked by its job with the repository's TypeScript; Expo's `tsconfigPaths` is off so that file does not change Metro's resolution.
344
+
345
+ ## Spike outcomes
346
+
347
+ - **Decision 5 (Effect RPC and Zero): kept.** All four checks pass; zero-cache itself runs on Node only (its native SQLite binding cannot load in Bun). Details: [spikes/sync-and-rpc.md](spikes/sync-and-rpc.md).
348
+ - **Decision 2 (Cedar compiled into SQL filters): kept.** Partial evaluation plus a fail-closed translator compiles owner, organisation, per-record sharing and forbid rules into one predicate used for the write-check, read filtering and sync. Details: [spikes/cedar-policy-to-sql.md](spikes/cedar-policy-to-sql.md).
349
+
350
+ ## Measured baselines
351
+
352
+ `mise run bench` on this machine (16 cores, 27 GiB, Arch Linux, otherwise idle) and in CI's `mise run check` (Blacksmith, 4 vCPUs, after the tests), on 2026-11-04 after the benchmark-regression fixes (see "CI: benchmark regression"):
353
+
354
+ | Budget | Bun | Node | CI Bun | CI Node | Budget |
355
+ | --- | --- | --- | --- | --- | --- |
356
+ | Shell route change from the local replica (p95) | 2.4 ms | 2.5 ms | 3.8 ms | 4.4 ms | ≤ 50 ms |
357
+ | Invocation overhead, excluding the handler (p50) | 1.2 ms | 1.5 ms | 1.4 ms | 1.5 ms | ≤ 5 ms |
358
+ | A write reaching another client (p95) | 11.7 ms | 12.0 ms | 22.2 ms | 17.3 ms | ≤ 250 ms |
359
+ | Example app in development, memory (PSS of everything `mise run dev` starts plus PostgreSQL, after sign-in, an action and its sync) | 1389 MiB | 1459 MiB | 1320 MiB | 1369 MiB | ≤ 2048 MiB |
360
+ | Example app in development, cold start (see below) | 3.0 s | 3.3 s | 3.6 s | 4.2 s | ≤ 5 s |
361
+ | Desktop launch to interactive (p95 of 20 launches, release build, signed out, kernel and zero-cache up) | 913 ms (Xvfb, busy machine) | (runtime-independent) | Linux 808 ms, macOS 1172 ms, Windows 948 ms (run 41814919666; the run before, 41811044496: 771, 1381 and 1225 ms) | | ≤ 1.5 s |
362
+
363
+ - **A write reaching another client** is measured both ways a client writes, and the budget holds for each (the reported value is the slower p95): optimistically through the writer's replica (`write`, pushed through zero-cache to `/zero/mutate`) and through the typed client. On 2026-11-05 on this machine: optimistic p95 17.2 ms on Bun and 19.3 ms on Node (p50 14.1 and 15.9 ms), the typed client 13.3 and 16.6 ms; the **local echo** (the writer's own replica showing the write) p50 0.47 and 0.39 ms, p95 0.60 and 0.55 ms.
364
+ - Invocation overhead is measured on a no-op action, in process, through the whole path (Better Auth session lookup, policy, approval, transaction with the invocation context, row-level security, target and write-log checks, audit): 9 SQL statements.
365
+ - **Cold start** is timed from spawning the `mise run dev` orchestrator (PostgreSQL start, the kernel with `setup` and `seed` in its own process, zero-cache from a fresh replica, Vite) through its "running" line until a signed-in browser shows `/hello` with a fixture greeting that only sync can deliver. The database itself already exists, as for any `mise run dev` after the first. The budget's figure is the **median of five independent cold starts**, each from scratch: a freshly prepared database, a fresh replica, a new orchestrator and a new browser context. The bench reports every sample, and the median start's steps say when each step finished. Before 2026-11-09 the figure was a single start, which CI runners vary by more than the budget's headroom. zero-cache's start-up is the critical path: it starts five Node processes one after another (about 2.3 s locally, 2.8 to 3.1 s on CI). The kernel's runtimes import only the platform modules they use; the platform package's index also loaded the unused `redis` client, 678 of the kernel's 2667 modules at start, about 0.3 s on Node.
366
+ - **CI runners vary.** The same commit on the same runner has measured a Node cold start between 4.0 and 7.1 s, and invocation overhead between 1.2 and 5.4 ms, within 15 minutes; slow rounds are slow on every measure at once. A local run competing with other test suites is just as unrepresentative (a run under a load average of 16 measured a 9 s cold start). The environment snapshot printed before CI's benchmarks shows the runner's load.
367
+ - Memory is dominated by zero-cache (~500 MiB) and Vite (~450 MiB once it has served the shell). zero-cache runs one sync worker in development (`ZERO_NUM_SYNC_WORKERS=1`).
368
+ - **Desktop launch** is timed from spawning the host to its interactive line (first content in `#root`, after the next frame), on the harness's clock, in CI's desktop lanes. Each run also reports when the webview started and finished loading the page: on macOS (Blacksmith, M4) the webview starts loading only about 830 ms after launch and the shell is interactive about 250 ms later, so its p95 has the least headroom (1172 and 1381 ms in two runs); Windows' daemon takes about 1 s to answer (a 108 MiB Bun executable), which the launch does not wait for. The launch is signed out (the journeys sign out at the end): a signed-in launch also waits for the membership list and the replica before showing anything.
369
+ - The route-change benchmark is the browser's view of `/` → `/hello` until the replica's confirmed rows are on screen; it is independent of the server runtime.
370
+
371
+ **In CI's budget jobs (2026-11-14, build/budgets, run 43640209551; Blacksmith 4 vCPUs, `budgets (bun)` and `budgets (node)`, each on a runner of its own; runner speed ratio 0.82 and 0.84, outcome pass on both).** The whole example app's figures are PR #17's app (`examples/hello-app` grown into it), measured by the same benchmark on the same runner type (probe run 43640253277, a temporary branch of #17 with this benchmark; #17 itself predates the calibration):
372
+
373
+ | Budget | CI Bun | CI Node | Budget |
374
+ | --- | --- | --- | --- |
375
+ | Shell route change from the local replica (median of 3 rounds' p95) | 16.2 ms | 16.1 ms | ≤ 50 ms |
376
+ | Invocation overhead (median of 3 rounds' p50) | 1.4 ms | 1.2 ms | ≤ 5 ms |
377
+ | A write reaching another client (median of 3 rounds' p95) | 19.5 ms | 20.0 ms | ≤ 250 ms |
378
+ | Kernel start on a set-up database, hello app (median of 3) | 930 ms | 1231 ms | ≤ 2 s |
379
+ | Kernel start on a set-up database, whole example app (median of 3) | 1229 ms | 1428 ms | ≤ 2 s |
380
+ | Hello app in development, memory (largest of 5) | 1351 MiB | 1489 MiB | ≤ 2048 MiB |
381
+ | Hello app in development, cold start (median of 5) | 3.11 s | 2.96 s | ≤ 5 s |
382
+ | Whole example app in development, memory (largest of 5) | 1519 MiB | 1563 MiB | ≤ 2048 MiB |
383
+ | Whole example app in development, cold start (median of 5) | 3.71 s | 3.20 s | ≤ 8 s (tripwire) |
384
+ | Desktop launch to interactive (median of 3 rounds' p95; desktop job) | Linux 785 ms, macOS 1369 ms, Windows 697 ms | | ≤ 1.5 s |
385
+
386
+ **Each app measured on its own (2026-11-15, build/budgets-2, merge-tier run 43687050132; runner speed ratio 0.64 and 0.83, outcome pass on both).** The hello rows measure `examples/hello-only`, the whole-example rows `examples/hello-app`:
387
+
388
+ | Budget | CI Bun | CI Node | Budget |
389
+ | --- | --- | --- | --- |
390
+ | Shell route change (median of 3 rounds' p95) | 16.3 ms | 16.0 ms | ≤ 50 ms |
391
+ | Invocation overhead (median of 3 rounds' p50) | 1.0 ms | 1.2 ms | ≤ 5 ms |
392
+ | A write reaching another client (median of 3 rounds' p95) | 20.2 ms | 23.2 ms | ≤ 250 ms |
393
+ | Kernel start, hello-only / whole example app (median of 3; the larger is asserted) | 731 / 1224 ms | 1228 / 1736 ms | ≤ 2 s |
394
+ | Hello app (hello-only) in development, memory / cold start | 1367 MiB / 2.70 s | 1481 MiB / 3.06 s | ≤ 2048 MiB / 5 s |
395
+ | Whole example app in development, memory / cold start | 1567 MiB / 3.58 s | 1590 MiB / 3.61 s | ≤ 2048 MiB / 8 s (tripwire) |
396
+ | Desktop launch to interactive (desktop jobs) | Linux 773 ms, macOS 1355 ms, Windows 685 ms | | ≤ 1.5 s |
397
+
398
+ Memory by role in the whole example app's largest sample (Bun): zero-cache's four workers 518 MiB, Vite 439, the kernel 293, zero-cache's own two processes 134, PostgreSQL 114, the orchestrator 20. The hello app's: workers 413, Vite 433, kernel 250, zero-cache 133, PostgreSQL 102. The whole app's extra modules cost about 170 MiB (workers and kernel) and 0.3 to 0.6 s of cold start (the kernel's start and zero-cache's initial sync).
399
+
400
+ Budgets live in [`bench/src/budgets.ts`](../bench/src/budgets.ts). None were tightened. How each is measured, and how a slow machine is told from slow code (a calibration workload, and one re-measurement of what missed on a slow machine, never of the assertion), is in [performance.md](performance.md).
401
+
402
+ ## Minimal or stubbed (by design)
403
+
404
+ - **CLI:** `add` refuses to update an installed item whose registry content changed (it points at `update`); `--overwrite` replaces files wholesale. `login` keeps its tokens in the OS keychain (`@napi-rs/keyring`: the macOS Keychain, Windows Credential Manager, the Secret Service), the rest of a sign-in in `<config dir>/credentials.json`, and the tokens there too (mode 0600) where no keychain answers (`ELOXIV_CREDENTIAL_STORE`, [cli.md](cli.md#calling-a-kernel)); proven against an injected keychain in CI (`packages/cli/test/credentials.test.ts`) and against KWallet's Secret Service on this machine by hand; macOS and Windows untested.
405
+ - **Daemon:** pairing, custody, the relay, the Claude Code and Codex adapters and the headless runner are built ([Daemon](contracts/daemon.md)). The Tauri template does not yet pass a host secret or show local pairing requests and codes (Rune starts its sidecar with a per-launch host secret: [desktop-rune](registry/desktop-rune.md)); the daemon's Keychain and Credential Manager backends have no round-trip test here (`packages/daemon/test/secrets.test.ts` covers the file store and, where present, libsecret); browser and computer commands run through companions, whose packaged products (a browser extension, a computer-use helper) are not built ([DeviceControl](contracts/device-control.md)); the kernel's pairing page only explains where to confirm a code (the confirmation screen is not built).
406
+ - **Approvals and consent:** decisions are actions (`approvals.approve`, `consent.approve`, ...), and the person's own: an agent may decide neither consent nor a business approval, though it may reject a business approval (which runs nothing). The consent decisions and `approvals.approve` are on no agent's tool list, `approvals.reject` is ([ActionRegistry](contracts/action-registry.md), "Person-only actions"). The inbox (`inbox-ui-foldkit`, `/inbox`), the approvals screen and consent in the chat are built (`e2e/example.spec.ts`, J6 and J7). People cannot list or end their agent sessions through a surface ([ActionConsent](contracts/action-consent.md)).
407
+ - **Agent resources:** workspace-wide resources (a scope above one organisation) and custom agents owned and edited as resources at runtime are not built, deferred by the owner (2026-11-16): Eloxiv has no workspace or owner model for them ([AgentResources](contracts/agent-resources.md)). Custom agents an app declares (`KernelApp.agent.profiles`) and resource packs between organisations are built (see "The agent").
408
+ - **Directory:** organisations, memberships, groups, roles and permissions, managed in process (`Directory.as(headers)`) and over HTTP as the person (`POST /kernel/directory/<operation>`, the client SDK's `directoryClient`; [Directory](contracts/directory.md)), and seeded by `server/seed.ts`. `members-ui-foldkit` (`/admin/members`) lists members, adds an existing user by email, gives and takes roles and removes members (`packages/testing/test/member-admin-routes.test.ts`; `e2e/example.spec.ts`, J2); no shell screen manages groups, role permissions, invitations or domain claims.
409
+ - **Sharing:** the Sharing contract is complete headlessly ([sharing.md](contracts/sharing.md)): the kernel-provided `sharing` module's actions (grant to a user, group, organisation or link; revoke; list; redeem a link; request, approve and deny access), `ctx.sharing`, and the client SDK's share and access-request controllers (`shareController`, `accessGate`, `decideAccessRequest`). No shell screen for sharing or access requests, and no anonymous links or sharing across organisations (by design).
410
+ - **Seeds and secrets:** a development `ELOXIV_AUTH_SECRET` default and demo users; the local development cluster uses `trust` authentication and `fsync=off`.
411
+
412
+ ## Known gaps
413
+
414
+ The numbers are stable references (other documents cite them). Resolved gaps are removed and their numbers are not reused: 9 (the module manifest now declares permissions, settings, skills, views, slots, contributions, commands, work-item sources, entity resolvers, query views and approval rules ([ModuleManifest](contracts/module-manifest.md)), and `defineModule` workflows, event triggers and ingress sources), 12 (MCP calls carry a per-call idempotency key in `_meta`, backlog 7: [Invocation](contracts/invocation.md)) and 17 (CI runs on the draft pull request, on Bun and Node; the harness entry that later reused 17 is 18), and 4 (the app-wide Zero handle was `Zero<any>`; the sync schema is now generated with literal types and `connectSync` returns `SyncClient<AppSchema>`, decision 9), and 1 (optimistic writes: actions declare the change a replica predicts, `eloxiv generate` writes their mutators, and `/zero/mutate` runs each pushed write through the invocation path; [Sync](contracts/sync.md#optimistic-writes)), and 2 (policy compiler coverage, backlog 4: the compiler translates typed equality, order comparisons on Longs, `like`, `has`, `if-then-else`, literal sets with `contains`/`containsAll`/`containsAny`, the principal's groups, roles, permissions and email, `principal in resource.<attribute>` and `<named entity> in resource.<attribute>` (a named user only while that user acts), the record's state (`context.row`), sharing sets for the acting principal, and one hop through a declared reference within a module, and everything else fails closed ([the spike](spikes/cedar-policy-to-sql.md#limits-and-follow-ups) lists what stays refused); `eloxiv_ctx.has_grant` answers only for the acting principal and `principal.email` is answered in the database; compiled filters are keyed on the policy set's version, so a policy set that changes at runtime is never served stale, while row-level security still needs setup to run again after a policy change; `packages/kernel/test/policy-compiler.test.ts`, `policy-cache.test.ts`, `packages/testing/test/policy-sql.test.ts` and the policy differential suites), 3 (related queries, backlog 5: each `related()`/`whereExists()` subquery carries its own entity's read filter, and one reaching a table no entity governs is refused; [Sync](contracts/sync.md), guarantee 4, the Sync kit and `sharing-live.test.ts`) and 7 (the [Host](contracts/host.md) contract, 1.1.0, implemented by the web, Tauri, Rune and Expo hosts, and [StorageAdapter](contracts/storage-adapter.md) 1.0.0, by the memory, IndexedDB, SQLite and `expo-sqlite` stores, each held to its conformance kit).
415
+
416
+ 5. **zero-cache needs Node.** Even in a Bun deployment, zero-cache runs on Node (`zeroCacheEnv` in [`System.ts`](../packages/testing/src/System.ts) and the CLI's [`Run.ts`](../packages/cli/src/Run.ts) find it). Dev settings that matter (`zeroCacheEnv`; the worker count, lag reporting, revalidation and the planner are defaults the environment overrides): `ZERO_NUM_SYNC_WORKERS=1`, `ZERO_REPLICATION_LAG_REPORT_INTERVAL_MS=0` (no lag-report readiness gating: even at 500 ms zero-cache jitters each report by up to ±1 s, which made cold start vary between 3.8 and 5.2 s), `ZERO_QUERY_ALLOWED_CLIENT_HEADERS=x-eloxiv-org`, `ZERO_MUTATE_ALLOWED_CLIENT_HEADERS=x-eloxiv-org,x-eloxiv-client-version`, `ZERO_ENABLE_CRUD_MUTATIONS=false` (writes reach the database only through actions), the kernel's `ELOXIV_ZERO_APP_ID` equal to zero-cache's `ZERO_APP_ID` (the shard sync's push writes its bookkeeping in), the publication `eloxiv_sync` (`ZERO_APP_PUBLICATIONS`), the query and mutate API keys the kernel checks (`ZERO_QUERY_API_KEY`, `ZERO_MUTATE_API_KEY`), `ZERO_AUTH_REVALIDATE_INTERVAL_SECONDS=10` (how long an expired session's replica can stay connected; Zero's default is 300 s), `ZERO_ENABLE_QUERY_PLANNER=false` (zero-cache's cost-based planner took 13 s to plan one generated permission filter of 59 correlated subqueries over six rows, seed `-1082452254` of `sync-property.test.ts`; deployments should turn it off too, or measure their own queries with it), and `synchronous_commit` left on. Production deployments with several replicas should keep lag reporting on and keep the revalidation interval at 10 s or less ([Sync](contracts/sync.md)). Sign-out, directory changes and sharing grants do not depend on either interval: zero-cache evaluates them live ([Sync](contracts/sync.md), guarantees 7 and 8; `sync-revocation.test.ts`, `sharing-live.test.ts`).
417
+ 6. **Desktop and React Native** are enforced in CI (see "Desktop and React Native in CI" and [ci.md](ci.md)): the Tauri host on Linux, macOS and Windows, the Rune host's journey on Linux, the client SDK on Hermes and the Expo mobile host on Android. What remains: on macOS the Tauri journey runs as an injected script, not through WebDriver or operating-system input; the Tauri webview's replica is IndexedDB ([StorageAdapter](contracts/storage-adapter.md); Rune's is SQLite through its daemon, React Native's SQLite through `expo-sqlite`); nothing is proven on iOS (the mobile host's iOS simulator lane is an attempt that never fails a run). The client core can open the remembered replica at a start that cannot reach the kernel when the session store remembers the context with its token (`SessionStore.recall`, [ClientSDK](contracts/client-sdk.md) 1.4.0); the mobile host's store does, the web shell's and the daemon's (Rune) do not yet, so they wait for the kernel to list the person's organisations, and the web shell meanwhile shows them unavailable, with why, recovering when the core lists them again (`registry/test/shell-foldkit-review.test.ts`).
418
+ 8. **Connector coverage.** The Microsoft Graph connector is proven against its protocol fake only (a live run is not required, owner decision 2026-11-17: [microsoft-graph.md](connectors/microsoft-graph.md)); Google and Slack also against real accounts; there is no Teams connector. CollabDocument, once listed here as a kernel contract not started, is built (CollabDocument 1.1.0: its kit, run by `collab-document.test.ts`, and `registry/test/notes-collab.test.ts`); the published contracts are listed in [contracts/README.md](contracts/README.md).
419
+ 10. **In-process trust limit.** Registry and app modules are the app's own, trusted code, and run in the kernel's process on its connection. Row-level security, role privileges and setup's checks stop mistakes and SQL-level escapes; running module code (handlers, subscribers, module workflows and their steps, connectors, module schemas) without the kernel's services, in scopes of its own, stops a module reaching kernel services by accident; kernel privilege is bound to the kernel's own recorded handler functions, not to module objects. None of this is a boundary against deliberately hostile in-process code: such code can `RESET ROLE` on the kernel's connection, import and read what it likes, or open its own connections. Untrusted (agent-made, MAKE) modules run in the sandbox instead (backlog 3, resolved for them; [sandbox.md](contracts/sandbox.md)): their code runs in QuickJS with no ambient authority and their statements on a session logged in as their runtime role, so there is no kernel connection or more privileged role within their reach (`make-sandbox.test.ts`: "is its own role, with nothing more privileged to return to"; "reaches no other module's, kernel's or Better Auth's tables, and cannot forge the invocation context").
420
+ 11. **Constraint side channels** (backlog 1, resolved as an accepted limit). Postgres checks unique and foreign-key constraints across row-level security; the kernel's rule that a write's outcome may not depend on an unreadable record is enforced per channel (see "The action contract": references are guarded, unique keys a writer could meet unreadable records on are refused at setup, key changes and exact actions' undeclared inserts are refused). The tests, one per channel: the Invocation kit ([`Invocation.ts`](../packages/testing/src/conformance/Invocation.ts), "identities and constraint outcomes") and [`setup.test.ts`](../packages/testing/test/setup.test.ts) ("refuses a unique key whose conflicts would disclose records a writer cannot read ..."). Two residual channels are accepted limits (owner decision, 2026-11-16):
421
+ - **a key the caller names** in an untargeted or best-effort insert: whether a record holds it is disclosed (a free key's insert succeeds, a held one cannot be made). Refusing caller-chosen keys outright refused the normal create path and provider-keyed sync. Optimistic inserts take their keys from `recordKey`, scoped to the acting organisation, user and entity ([Invocation](contracts/invocation.md)); other inserts under a raw key, provider-keyed upserts among them, keep the limit;
422
+ - **deleting a referenced record** fails while any record references it, readable or not; the failure names nothing but the fact (`ActionFailed`, the same fixed message in-process and in MAKE's `sql`), and closing it needs cascades under the referencing records' policies or tombstones (Invocation kit: "refuses deleting a referenced record the same way whether or not the caller can read the reference").
423
+
424
+ Two caveats of trusted module code (known gap 10) remain besides, outside the owner's decision:
425
+ - **a module's own `BEFORE INSERT` trigger** that changes a row after the reference guard has checked it is not caught: setup refuses other `BEFORE UPDATE` triggers, not `BEFORE INSERT` ones;
426
+ - **a subscriber's later visible effect** can act as an asynchronous oracle for an entity no action declares (its unique keys are not checked, since no caller sees a subscriber's outcome directly).
427
+ 11a. **Filtering of untargeted writes.** Exact targeted actions fail when they touch an undeclared readable row (see "The action contract"), but actions without a target are filtered by row-level security. Their receipts say how many records of their declared entities they inserted and updated (`written`), and an action declaring `reportsWritten` gets the same counts in its output; rows the caller cannot read are neither counted nor named (backlog 2, resolved; `untargeted-writes.test.ts`, [Invocation](contracts/invocation.md)). A one-hop reference in row-level security reads the referenced record under its own row-level security, so an unreadable referenced record counts as missing (stricter than Cedar).
428
+ 13. **Outbox:** dead letters and per-subscriber delivery policies exist (backlog 6, [Outbox](contracts/outbox.md); `dead-letters.test.ts`); the administrator operations on dead letters are in-process (`Outbox.as(headers)`), with no HTTP route or shell screen yet. Retention deletes settled events older than `outboxDays` (`ELOXIV_OUTBOX_RETENTION_DAYS`, default 30; 0 keeps them) with their deliveries and closed dead letters, keeping events that may still be retried or that unfinished work reads (`Retention.ts`; `retention.test.ts`). Subscribers act as a system actor limited to the event's organisation; finer subscriber authorisation is not modelled. The write log (`eloxiv.invocation_write`) is cleaned by the dispatcher; without a dispatcher, rows from non-invocation writes accumulate.
429
+ 13a. **Pre-review skeleton databases.** A database set up before the second review (2026-11-02) holds the earlier notes migrations, squashed before anything was deployed and without a backfill (`registry/test/migrations.test.ts`): reset it (`mise run db:reset`, or drop the `eloxiv` database). Databases set up since follow the [Release](contracts/release.md) migration path.
430
+ 14. **Organisation switching** (backlog 8, resolved) is in the shell and the client core: the switcher changes the acting organisation for actions and sync and is remembered per user (`e2e/org-switch.spec.ts`). The SDK's `orgId` may be a function read on every call. A web address naming an organisation (`?org=`) opens the session there when the person belongs to it, else the one selected or chosen last, else the first (`registry/test/shell-foldkit.test.ts`); Rune switches organisation for its deep links too (`app/tests/links.rs`, `a_link_opens_its_screen_in_its_organisation`). Not yet: the Tauri template's deep links reaching the shell (they are launch-only, [Host](contracts/host.md)), and an organisation picker on the sign-in screen.
431
+ 15. **Packaging.** Packages build to `dist`; the eight public `@eloxiv/*` packages are published to npm by the release workflow on a pushed `v*` tag, the first release (0.1.0) by hand by the owner, after which trusted publishing takes over ([release.md](release.md)). In this repository `@eloxiv/cli`'s `bin` points at `dist/bin.js` (pnpm warns until built). The shell is code-split (since shell-foldkit 0.8.0): the sign-in page loads 1048 KiB of JavaScript in the hello app and 1147 KiB in the whole example app (326 and 358 KiB gzip; one chunk of 1251 and 1387 KiB before), each screen 2 to 36 KiB more when its route is first shown. What remains is the client core, which the sign-in runs on, with Zero (about 300 KiB): the core opens the replica synchronously, so loading Zero after sign-in needs an asynchronous replica open in `@eloxiv/client/runtime`.
432
+ 16. **Generated files** are excluded from formatting ([`.oxfmtrc.json`](../.oxfmtrc.json)): the generated sync tables (`*.gen.ts`), the composition outputs (`eloxiv.modules.ts`, `eloxiv.server.ts`, `eloxiv.schema.ts`, `eloxiv.sync.ts`), `eloxiv.lock.json`, `registry/registry.json` and the built items, the contracts' JSON Schemas, migration metadata, snapshots and Tauri's generated files. The Foldkit shell has no generated route tree.
433
+ 18. **A cancelled device turn's harness** stops when the runner learns of the cancellation: before any call it relays, when it flushes the turn's events (every 300 ms while there are any), or at its heartbeat (a third of the lease, 20 s by default). The kernel refuses the turn's calls as soon as the cancellation commits, before that heartbeat (`agent-device.test.ts`, "refuses the turn's calls once the run is cancelled, before the runner's next heartbeat"). Until the runner learns of it, a harness that calls nothing can go on working locally (with workspace tools, on files).
434
+
435
+ ## Review fixes (2026-11-02)
436
+
437
+ An independent review found six blocking and nine should-fix issues. Each fix below came with a test written first and seen failing before the fix, except item 14 (the benchmark changed what it measures; the old measurement passed) and the Better Auth log, whose test was written first and failed:
438
+
439
+ | # | Issue | Fix | Test |
440
+ | --- | --- | --- | --- |
441
+ | 1 | notes copied private greeting text into org-readable notes | events carry references, notes keep references to org-visible greetings only | `registry/test/sync.test.ts` (every readable projection) |
442
+ | 2 | the compiler discarded types, widening access | typed policy attributes, Cedar's equality semantics, strict schema validation at startup | compiler, schema and SQL differential tests |
443
+ | 3 | records were authorised only after the handler, by returned id | targets locked and authorised before; then (round 2) row-level security, see below | `packages/testing/test/invocation.test.ts` |
444
+ | 4 | replays skipped record authorisation | replays re-check target and written rows | same |
445
+ | 5 | idempotency keys crossed organisations | organisation in the key, constraint and every lookup | same (including concurrent calls) |
446
+ | 6 | sync accepted `related()` without authorising children | such queries are refused | `packages/testing/test/sync-scope.test.ts` |
447
+ | 7 | the agent surface dropped idempotency keys | tool-call id is the key | `registry/test/surfaces.test.ts` (every surface) |
448
+ | 8 | outbox defects bypassed backoff and stalled the batch | every non-interrupt cause handled per subscriber savepoint; at-least-once documented | `packages/testing/test/outbox.test.ts` |
449
+ | 9 | sync could not select the organisation | `orgId` → `x-eloxiv-org` query header, per-org replica storage; hello's owner rule now org-scoped | `registry/test/sync.test.ts` |
450
+ | 10 | sign-out left the session and replica alive | server-side revocation, replica lifecycle in an effect | `e2e/sign-out.spec.ts` |
451
+ | 11 | early failures escaped auditing | one audit at the outer boundary for every failure | `packages/testing/test/invocation.test.ts` |
452
+ | 12 | installing a module forced UI | headless modules plus `-ui` items; `examples/headless-app` | `packages/cli/test/cli.test.ts`, `registry/test/headless.test.ts` |
453
+ | 14 | dev benchmarks measured readiness, not usability | cold start to a signed-in, synced route; memory after activity | `bench/browser/dev.spec.ts` |
454
+ | — | Better Auth logged a schema mismatch during setup | setup migrates through an instance with its startup check off | `packages/testing/test/setup.test.ts` |
455
+
456
+ Items 13 (a desktop CI lane) and 15 (a React Native runtime proof) were deferred to the next goal; both now run in CI (see "Desktop and React Native in CI").
457
+
458
+ ### Round 2 (same day)
459
+
460
+ The second review confirmed round-1 items 2, 4–9 and 12 and found four remaining holes, all reproduced first:
461
+
462
+ | # | Issue | Fix | Test |
463
+ | --- | --- | --- | --- |
464
+ | 1 | a side-effect update rewrote another record into a shape that passed the final check | Postgres row-level security generated from the compiled filters checks the old and the new row of every statement | `invocation.test.ts` "does not let a side-effect update..." |
465
+ | 2 | deferred triggers ran at commit with kernel privileges | runtime roles cannot create triggers or functions; the kernel inherits no module privileges; setup refuses deferred triggers, `SECURITY DEFINER` functions, rules and unsafe views | `invocation.test.ts`, `setup.test.ts`, `isolation.test.ts` |
466
+ | 3 | `TRUNCATE` bypassed the write log | runtime roles have no `TRUNCATE` (owner role is migration-only) | `invocation.test.ts`, `isolation.test.ts` |
467
+ | 4 | sync trusted a query's declared entity | the query's table is resolved through the Zero schema and must match the entity | `sync-scope.test.ts` |
468
+ | 5 | notes migration 0001 could leave copied text | notes migrations squashed into one clean migration (nothing deployed; no backfill) | `registry/test/migrations.test.ts` |
469
+ | 6 | subscribers had no authorisation boundary | subscribers act as a system actor scoped to the event's organisation, enforced by the same row-level security | `outbox.test.ts` "runs subscribers as a system actor..." |
470
+ | 7 | the policy cache ignored principal attributes | cache keyed on all bound principal data | `kernel/test/policy-cache.test.ts` |
471
+ | 8 | MCP (and RPC, HTTP) validated before the invocation path, so rejections went unaudited | every surface passes raw input (documented with the action's JSON Schema) to the invocation path | `surfaces.test.ts` "rejects invalid input on every surface and audits..." |
472
+ | 9 | the shell linked to `/hello` without hello-ui | navigation comes from installed routes (`staticData.nav`); empty composition files typecheck | `cli/test/shell-assemblies.test.ts` |
473
+ | 10 | sign-out swallowed revocation failures | failed revocations are tracked, retried and shown as pending until confirmed | `e2e/sign-out.spec.ts` (second test) |
474
+ | 11 | differential tests could pass vacuously | generated policies must compile; unsupported syntax tested separately (verified: both tests fail with a compiler that always refuses) | `policy-compiler.test.ts`, `policy-sql.test.ts` |
475
+ | 12 | dev benchmark skipped setup/seed and counted a query error as ready | benchmark times the real `mise run dev` path to synced fixture data; the shell is ready only on a confirmed result | `bench/browser/dev.spec.ts` (benchmark, no failing-first test) |
476
+
477
+ Also found and fixed on the way: the compiler did not short-circuit `&&`/`||` like Cedar (rules for one entity type failed to compile for another); hello's owner read rule ignored the organisation; `eloxiv add --overwrite` left files a newer item version no longer ships; concurrent setups raced on cluster-wide role changes.
478
+
479
+ ### Round 3 (same day)
480
+
481
+ The third review found two blocking holes and five should-fix items. Reproducers were written first and seen failing (the statement-shape coverage tests for `ON CONFLICT DO UPDATE`, `giveAway` and `rekey` failed first only on the missing audit columns; the no-op target test, the extra sync-validation unit tests and the upgrade regression were added after their fix and pass):
482
+
483
+ | # | Issue | Fix | Test |
484
+ | --- | --- | --- | --- |
485
+ | 1 | `CASCADE`/`SET NULL`/`SET DEFAULT` foreign keys rewrote other users' child rows as the table owner | setup refuses mutating referential actions on module tables (until enforcement checks old and new child rows) | `setup.test.ts` (three variants refused, `RESTRICT` accepted); `invocation.test.ts` key change against a child row fails and rolls back |
486
+ | 2 | a no-write upsert replayed private data after the grant was revoked | stored results carry their dependencies (rows written, rows returned, deletion receipts); replays re-check them; results without established dependencies are not replayed | `invocation.test.ts` "re-checks rows a create-or-get returned..." |
487
+ | 3 | sync trusted the Zero schema's column mappings | at startup every policy-relevant field (column attributes and the primary key) of every Zero table over an entity table must read the entity's column; the `shares` relationship must join the primary key to `eloxiv.share_grant.resourceId` with correctly mapped grant columns; mismatches stop the kernel | `sync-scope.test.ts` (kernel refuses a wrong `.from()`; unit tests for wrong join fields, wrong grant columns, wrong destination table) |
488
+ | 4 | targeted actions were filtered silently | exact versus declared best-effort semantics (above); kernel-computed completion in the result and the audit | `invocation.test.ts` round-3 block (`renameAll`, `hijack`, CTE, `UPDATE ... FROM`, upsert all `Forbidden`; `renameMany` partial/complete; untouched target `Forbidden`) |
489
+ | 5 | an authorised delete could not be replayed | deletion receipts (target id, actor, organisation, outcome) | `invocation.test.ts` "replays a successful delete from its receipt" |
490
+ | 6 | missing coverage | invocation tests for upserts, joined updates, CTEs, delete replay and an authorised row moved into a forbidden state (outcome and audit asserted); compiled SQL compared with row-level security independently; upgrade regression | `invocation.test.ts`, `policy.test.ts`, `setup.test.ts` |
491
+ | 7 | spike document drift | `has_grant` example, Bob's rename stopped by the target check, cache key includes principal attributes | `docs/spikes/cedar-policy-to-sql.md` |
492
+
493
+ Kernel migration `0004_completion_and_dependencies` adds the audit columns and replaces `idempotency_key.writes` with `dependencies`, discarding stored results (they cannot be re-authorised completely).
494
+
495
+ ### Round 4 (same day)
496
+
497
+ The fourth review confirmed round-3 items 1, 3 and 5 and found two blocking holes and two should-fix items. Every reproducer below was written first, seen failing for the reported reason, and kept as a regression test. The `WITH CHECK` test passes against the fixed code, so it was checked by disabling `WITH CHECK`: the test then fails.
498
+
499
+ | # | Issue | Fix | Test |
500
+ | --- | --- | --- | --- |
501
+ | 1 | an exact action could delete its target and move another readable record onto the target's key (the write log saw only the new key) | primary keys immutable outside migrations: kernel key guard before and after every module-table update (`insufficient_privilege` → `Forbidden`) | `invocation.test.ts` "does not let an action move another record onto its target's key" (Forbidden, both rows unchanged, exactly one denial audit row) |
502
+ | 2 | a replay recorded only the top-level id, so nested records in the output escaped re-checks | `returns` declarations; outputs must be fully covered by declared records or are never replayed; every recorded record re-checked (superseded in round 6: replays return receipts) | `invocation.test.ts` round-4 replay block (undeclared nested records not replayed; declared nested and second-entity records denied after revocation) |
503
+ | 3 | constraint outcomes revealed unreadable records (undeclared `ON CONFLICT DO NOTHING`, key change against an unreadable child) | exact actions may insert or update only declared targets, checked by row-level security before conflict arbitration; keys immutable, so key changes fail before referential checks; the remaining channels are documented | `invocation.test.ts` "refuses an undeclared insert the same way..." and the key-change test (same `Forbidden` with and without an unreadable child) |
504
+ | 4 | the give-away test would pass without `WITH CHECK` | a handler that makes a forbidden change and then restores the row: refused at the first statement (row-level security message), rolled back, audited once | `invocation.test.ts` "rejects a forbidden intermediate state at the statement..." |
505
+
506
+ Kernel migration `0005_identities` adds the key guard function, the per-transaction target table and `eloxiv_ctx.is_target`. The hardening fingerprint now includes the kernel's migrations, so existing databases are re-hardened.
507
+
508
+
509
+ ### Round 5 (same day)
510
+
511
+ The fifth review confirmed round-4 items 1 and 4 and withheld sign-off for two blocking and four should-fix items. Every reproducer was written first, seen failing for the reported reason, and kept. Two exceptions: the manifest assertion failed on the missing fields, and the kernel-only upgrade test first errored on re-applying a non-idempotent migration. It failed for the intended reason (guard trigger missing) once `0006` existed.
512
+
513
+ | # | Issue | Fix | Test |
514
+ | --- | --- | --- | --- |
515
+ | 1 | outputs with undeclared map keys or lists of empty objects passed the walker, so record ids and counts replayed without re-checks | replayable outputs must match an allowlist shape derived from `returns` (declared records and their ancestors only); anything else is never replayed (superseded in round 6: replays return receipts) | `invocation.test.ts` "does not replay docs.mapped (record ids as map keys)" and "docs.counted (...a count)" |
516
+ | 2 | results cached before the fix kept the bypass | migration `0006_dependency_format` discards cached results; dependencies carry a format version, and other formats are never replayed (superseded in round 6: replays return receipts) | `invocation.test.ts` "refuses to replay a cached result whose dependency format is not the current one", "discards cached results when the kernel upgrade that changed the format runs" |
517
+ | 3 | a migration-defined `BEFORE UPDATE` trigger could change a key after the guard; FK checks could precede the final guard | setup refuses every `BEFORE UPDATE` row trigger on module tables except the kernel's guard, which is now the only (terminal) guard | `setup.test.ts` key-changing trigger, alone and on a referenced table |
518
+ | 4 | constraint guarantee overstated | narrowed to undeclared inserts and direct key changes; open channels listed (known gap 11), closed by backlog 1 but for the stated delete limit | docs |
519
+ | 5 | JSON manifests dropped `target`, `bestEffort`, `returns` | emitted | `contracts/test/json-schema.test.ts` "projects the authorisation contract..." |
520
+ | 6 | the fingerprint test would pass without the kernel-migration input | the fingerprint now uses the kernel migrations applied in the database; new kernel-only upgrade test with an unchanged module | `setup.test.ts` "re-hardens an unchanged module after a kernel-only upgrade" |
521
+
522
+ Accepted limits are listed as backlog items in [`docs/backlog.md`](backlog.md).
523
+
524
+ ### Round 6 (same day)
525
+
526
+ The sixth review confirmed round-5 items 2–6. It found two more gaps in reconstructing which records a cached output reveals: overlapping `returns` declarations replaced one record with another, and structural list entries replayed an unchecked count. Six rounds had each found a new edge case of this kind. The coordinator changed the design so the class of bug cannot exist: **a replay returns a receipt of the call's own effects, never cached output**. The reproducers were written first and failed against the old design. The exception is the removed-member test, which passed from the start because identity already refused the caller; it is kept as a regression test.
527
+
528
+ | # | Change | Test |
529
+ | --- | --- | --- |
530
+ | 1, 2 | The output is no longer cached. Replays return `{ replayed: true, receipt }` (action, invocation id, outcome, records written or deleted, completion). Removed: `returns` declarations, the output allowlist, the dependency records and per-record replay re-checks, and `returns` in manifests | `invocation.test.ts` round-6 block: revoked grant, new forbid, create-or-get, delete, nested (`docs.bundle`), map keys (`docs.mapped`), count (`docs.counted`), joined entity (`docs.withAttachment`), best effort; each asserts the replay holds only the receipt and none of the original output |
531
+ | — | Replays are refused to a caller removed from the organisation | `invocation.test.ts` "refuses a receipt to a caller who is no longer a member..." |
532
+ | — | Receipts are format-versioned; a receipt in another format is refused with `IdempotencyConflict` | `invocation.test.ts` "refuses a receipt stored under another receipt format" |
533
+ | — | Migration `0007_replay_receipts` discards cached outputs and dependency records (safe to apply again) | `invocation.test.ts` "discards outputs cached before the upgrade to receipts, and runs the call afresh": `ok`, `replayed: false`, and the fresh, currently filtered output (should-fix 3) |
534
+ | — | The result type is explicit on every surface (`ReplayResult \| output`) and in the JSON manifest (`result`); `InvocationReceipt` and `ReplayResult` are published JSON Schemas (round 7: replaced by the `kind` envelope) | `registry/test/surfaces.test.ts`: the same receipt on RPC, HTTP, MCP and the agent tool, without the message; `contracts/test/json-schema.test.ts` |
535
+
536
+ Round 7 replaced the round-6 receipt fields (`written`, `deleted`) with `targets` and `created`, and the `{ replayed: true, receipt }` result with an envelope; see below.
537
+
538
+ ### Round 7 (same day)
539
+
540
+ The seventh review confirmed that receipts close the cached-output class. It found one blocking and two should-fix items. Every reproducer was written first, seen failing for the reported reason, and kept.
541
+
542
+ | # | Issue | Fix | Test |
543
+ | --- | --- | --- | --- |
544
+ | 1 | receipts listed every surviving written row (updated rows, secondary entities) and the best-effort affected subset | receipts hold exactly: action, invocation id, outcome; the caller-supplied target ids; ids of records the call inserted, of its own entity, that its output named (checked in code); best-effort counts only. Receipt format 2 refuses round-6 receipts | `invocation.test.ts` "does not reveal the ids of records an untargeted call updated", "reports only best-effort counts...", "returns a create's own created id on replay", "lists a created record only if the original output named it", plus every round-6 replay case |
545
+ | 2 | the result union was not disjoint and `isReplay` checked only two keys | `{ kind: "output", output }` / `{ kind: "replay", receipt }` envelope on all four surfaces; `isReplay` validates the whole receipt with the schema | `registry/test/envelope.test.ts`: receipt-shaped and broad (any-JSON) outputs on RPC, HTTP, MCP and the agent tool are delivered intact, and replays are the real receipt; guard rejects partial and malformed receipts |
546
+ | 3 | membership could go stale while a duplicate waited on the first call's claim | after the wait and immediately before release: re-authenticate the same user and organisation, re-check the action's policy | `invocation.test.ts` "re-checks membership after waiting on the first call's claim": an advisory-lock barrier holds the first call, the duplicate is seen waiting on the claim, the membership is removed, and the duplicate is refused |
547
+
548
+ ### Round 8 (same day)
549
+
550
+ The reviewer signed off the skeleton as a sound foundation. The four follow-ups were coverage and documentation gaps; no bypasses were found. Each new test was also run against the kernel with its guard removed, and it failed.
551
+
552
+ | # | Gap | Test (and the regression it catches) |
553
+ | --- | --- | --- |
554
+ | 1 | the format test seeded format 0, but the vulnerable receipts were format 1 | `invocation.test.ts` "refuses a real format-1 receipt...": seeds a round-6 format-1 receipt with identity lists, and asserts `IdempotencyConflict`, no receipt or identity disclosed, and no re-execution. Fails with `RECEIPT_FORMAT` set back to 1 |
555
+ | 2 | no secondary-entity insert was ever a `created` candidate | "never lists a secondary entity's inserted record as created...": `docs.withChild` inserts a document and an attachment and returns both ids; only the document is in `created`. Fails without the own-entity filter |
556
+ | 3 | the contention test failed at re-authentication, so the policy re-check was unprotected | "re-checks the action's policy after waiting, when re-authentication still succeeds": the duplicate waits on the claim, the user's email (the policy's only condition) changes, and re-authentication succeeds but the policy denies, so the result is `Forbidden`. Fails without the re-check |
557
+ | 4 | the best-effort guarantee was overstated; the execute step still described dependency recording | narrowed to kernel-generated completion fields and receipts; the execute step now describes receipts | docs |
558
+
559
+ ### Release review (2026-11-04)
560
+
561
+ An independent review of the Release work found two blocking issues, three should-fix and one note. Each reproducer was written first and seen failing against the code before its fix, then kept as a regression test.
562
+
563
+ | # | Finding | Fix | Test |
564
+ | --- | --- | --- | --- |
565
+ | 1 | losing the lease's session did not stop the migrations, which ran on other connections: terminating the recorded backend let a second setup in while the first one's migration transaction was still running | every statement of setup after the lock runs on the lock's own session, which never reconnects (Better Auth's migrations included, now applied in the transaction); each transaction and non-transactional migration first checks that its session holds the lock and is the recorded holder; renewal runs from a second connection only while that session is alive and recorded | `release-lease-loss.test.ts` (failed: the first setup's migration backend was still alive when the second took the lease); `release-atomic.test.ts` Better Auth rollback |
566
+ | 2 | the preflight accepted `COMMIT`, so `CREATE TABLE; COMMIT;` and a failing statement left a committed table without row-level security | migrations are parsed with libpg-query (PostgreSQL 17's grammar); transaction control, role and session changes and SQL that does not parse are refused, and what cannot run in a transaction is decided from the parse tree; after each migration setup checks `txid_current()` and the role are unchanged | Release kit "refuses a migration that would end the setup's transaction" (failed first), `kernel/test/migration-check.test.ts` |
567
+ | 3 | a no-op setup skipped hardening on its cached fingerprint and overwrote the snapshot, so disabled row-level security read as clean | hardening records each module's security state (`module_hardening.security`, migration `0017_hardening_state`, renumbered `0019_hardening_state`, now `0026_hardening_state`); every setup compares the live state, re-hardens on drift (revoking other grantees, re-enabling its triggers) and reports `repaired`, or refuses what it cannot restore; `status.insecure`; Readiness not ready | Release kit "security drift" (six weakenings, all failed first), Readiness kit |
568
+ | 4 | switching organisation changed the selection a render before the replica, so commits showed Acme's rows with Globex selected | the shell keeps the replica with the session and organisation it was opened for and renders rows only from the one matching the selection (shell 0.2.2; `examples/hello-app` updated with `eloxiv update`) | `e2e/org-switch.spec.ts` "never renders one organisation's rows while another is selected, in any commit" (React's commit hook records every commit; failed first) |
569
+ | 5 | a delivery's maximum age was checked only after a failure, so a retry due after its budget ran and could be recorded as delivered | the age is checked before every attempt; an aged delivery is closed per its policy without running | `dead-letters.test.ts` "maximum age" (failed first: the subscriber ran a second time) |
570
+ | re-review | drift detection missed function bodies and settings, module role attributes and memberships, event triggers and default privileges; the run's cleanup could drop a parallel run's databases | the security state records them (format 2); module roles are held to fixed attributes and one kernel membership on every setup, repaired in the transaction (this also undoes a migration that became the superuser in a `DO` block); module event triggers and default privileges are refused; each Vitest run tags the databases it creates (`ELOXIV_DATABASE_COMMENT`, `COMMENT ON DATABASE`) and drops only its own | Release kit role drift (six cases), refusals (four) and escalation (all failed first, the event-trigger case once isolated from the function-list check); `test-run-cleanup.test.ts` (failed first: the other run's database was dropped) |
571
+ | 6 | MCP ignored `clientInfo.version` | an MCP client named `eloxiv:<...>` in `initialize` has its `clientInfo.version` used as its client version when a call sends no header (the header wins); other clients' versions are ignored, and documented as ungated without the header | `client-version.test.ts` "MCP clientInfo.version" (the stale Eloxiv client failed first) |
572
+
573
+ ### Tests leave nothing behind (2026-11-04)
574
+
575
+ `/tmp` (a tmpfs) ran out of inodes: test suites had left about 10,000 directories there, and `fallow audit` base-snapshot caches about 35,000 inodes each; the local cluster held 142 leftover databases and 13 inactive replication slots.
576
+
577
+ - **Sources:** the CLI tests' fixture registries and apps (`eloxiv-registry-*`, `eloxiv-app-*`) and symlink targets (`eloxiv-outside-*`) were never removed; the CLI-surface test's config directory (`eloxiv-cli-*`); the shell-assembly apps in `.eloxiv/tmp`; zero-cache's worker directories (`sync-worker-*`, `mutagen-*`), left by every killed zero-cache; and most test files dropped their database before they ran, not after, as did the browser suite.
578
+ - **Prevention:** temporary directories are made through a helper that removes them when the test finishes, passed or failed (`tempDir` in `packages/cli/test/fixtures.ts`, `onTestFinished`), or in `afterAll`; zero-cache's `TMPDIR` is its replica directory, which goes with the database. A Vitest global setup ([`tools/vitest/global-setup.ts`](../tools/vitest/global-setup.ts)) gives each run a temporary directory of its own (`TMPDIR`, inherited by every worker and every process a test starts), fails the run naming anything left in it, removes it, and drops the test databases (with their replication slots and replicas) the run created: setup tags each database it creates with the run's id (`ELOXIV_DATABASE_COMMENT`), so a parallel run's databases are left alone. The browser suite's teardown drops its database.
579
+ - **fallow audit** (run by reviewers, not by `mise run check`) checks the base revision out into the temporary directory and keeps it as a cache per checkout root, so every agent worktree left one, and its garbage collection waited 30 days. `.fallowrc.json` sets `audit.cacheMaxAgeDays` to 1, so each audit sweeps abandoned caches of other worktrees after a day, and `mise run audit` runs it with `TMPDIR` in the checkout's ignored `.eloxiv/tmp`, so the cache goes with the checkout.
580
+
581
+ ### Process lifetime (2026-11-14)
582
+
583
+ A zero-cache started by `inbox-sync.test.ts` outlived its test by more than two hours and reached 4.2 GB during a Node verification run on a loaded machine (investigation of 2026-11-11). zero-cache forks every worker with `detached: true`, so each leads a process group of its own and the harness's signal to the launcher's group never reached them; startup had no owner until it returned a handle, so a startup a hook timeout abandoned was never stopped; and nothing stopped a dead test worker's processes.
584
+
585
+ - **Launches** ([`packages/testing/src/Launch.ts`](../packages/testing/src/Launch.ts)). Every zero-cache and kernel the harness starts (`startSystem`, `startZeroCache`, so dev, the browser suite, desktop and React Native lanes and benchmarks too) is a launch, owned from the moment it is spawned. Its environment carries a random marker (`ELOXIV_LAUNCH`) every descendant inherits: on Linux its processes are the ones whose `/proc/<pid>/environ` holds the marker, wherever they were reparented, with their descendants; elsewhere on Unix the launcher's group and its live descendants; on Windows the launcher's tree (`taskkill /T`; zero-cache does not detach there). Limit: on macOS a detached worker whose launcher already died is not found.
586
+ - **Stop** sends SIGTERM to every process of the launch and their groups, SIGKILL to what is left after 5 s, and settles on its own deadline (about 7 s), not on an `exit` event (a launcher already dead by a signal no longer hangs it). It is idempotent and fails naming any process that survived SIGKILL.
587
+ - **Abandoned startups.** Launches start under a scope; the Vitest setup file [`tools/vitest/launches.ts`](../tools/vitest/launches.ts) (testing and registry projects) ends it after every test file, stopping whatever that file launched and did not stop, and refusing a launch a startup still pending tries afterwards. `startSystem`, `startZeroCache` and `run` also take an `AbortSignal`; `startSystem` stops what it started on any failure before it collects PostgreSQL diagnostics. `ServicesReference` releases its fakes and kernel when zero-cache fails to start, and zero-cache too when the grants after it fail.
588
+ - **Parent death.** The first launch of a process starts a watchdog (a small Node or Bun process of its own group) that reads the launches over a pipe; when the parent dies, however it dies, the pipe closes and the watchdog stops them. **Run registry:** the Vitest global setup sets `ELOXIV_LAUNCHES_DIR`; each launch is recorded there until it is stopped, and the global teardown stops whatever is still running of it before it drops the run's databases, and then fails the run naming it (a process that outlived its test is a leak, like a temporary file; build/flakes, 2026-11-15).
589
+ - **Heap.** zero-cache runs with a V8 heap limit of its own (`NODE_OPTIONS=--max-old-space-size`, inherited by every worker it forks): `ELOXIV_ZERO_HEAP_MB`, default 512, 0 for none. A test zero-cache's processes peaked at about 180 MB of RSS each (`inbox-sync.test.ts` alone, Node and Bun). It does not bound native memory or the whole tree; `heavy.sh`'s cgroup does.
590
+ - **Output and evidence.** A launch's output is drained always and kept bounded in bytes (startSystem 64 KiB and 200 lines per process, `startZeroCache` 1 MiB, `run()` 8 MiB). Each launch notes in its captured output (never the console) its pid, database, app id, heap limit and replica at start, its processes by role once zero-cache is ready, and what it stopped.
591
+ - **Dev.** `mise run dev` installs its SIGINT and SIGTERM handlers before anything starts; a signal during startup abandons it and stops what started.
592
+ - **Tests.** [`launch-lifetime.test.ts`](../packages/testing/test/launch-lifetime.test.ts), with inert process trees shaped like zero-cache's: stop reaches a detached grandchild; stop settles and reaches the rest when the launcher died by SIGKILL; an abandoned startup is stopped and a later launch refused; a parent killed with SIGKILL takes its launches with it; the run registry's teardown stops what nobody stopped; output is bounded in bytes and drained; the heap limit reaches a forked worker.
593
+ - **`eloxiv dev`'s test** (`packages/cli/test/deploy.test.ts`) starts the CLI as a launch, on free ports, and stops it in `onTestFinished`; the cli project registers the per-file setup too. Before, its `finally` killed only the CLI, so a failed or timed-out run left the stand-in kernel, zero-cache and Vite (`eloxiv-deploy-*/server/main.ts prepare-and-serve`, `vite-stub.cjs --port 4993`, zero's `cli.js`) running for hours.
594
+ - **Upstream.** Draft issue for Rocicorp Zero (worker detachment, parent-disconnect handling installed only after startup's first await): not filed.
595
+
596
+ ### CI: intermittent Node startup hang (2026-11-03)
597
+
598
+ On the Node job, system startup in CI sometimes hung. Examples: the `sync.test.ts` setup hit Vitest's 120 s hook timeout with no output, and the benchmark setup took about five minutes before "Timed out ... waiting for kernel /health". It reproduced locally on two CPUs: three runs in a row failed.
599
+
600
+ - **Root cause.** The Node kernel started listening before its services and routes were built: the platform server was the outermost layer, so it was built first. Node accepts connections as soon as a server listens, and a request that arrives before any `request` listener exists is never answered. A readiness probe that landed in that window waited for `fetch`'s own five-minute headers timeout. Startup is slower under load (CI), so the window was longer. Bun's server didn't show the hang.
601
+ - **Fix.** `KernelHttp` takes the platform server layer and provides it innermost, so the port opens only after the pool and every kernel service are built. On Node the server also answers `503` with `retry-after` until Effect attaches its handler (the short window while routes are built).
602
+ - **Fail fast.** `run()` has a timeout (default 120 s) and kills the command's process group, reporting everything it printed. Readiness probes give up after 2 s each, and `waitFor` can't be held past its deadline by a check that never settles. `startSystem` has an 80 s budget, kept under Vitest's 120 s hook timeout. On failure it prints its step trace, each process's recent output, and PostgreSQL's sessions, waits and replication slots. `dropDatabase` and the publication check are bounded too.
603
+ - **Tests.** `packages/testing/test/startup.test.ts`:
604
+ - a kernel with a deliberately slow service, and a server with slow routes, are probed during startup; every probe is refused or answered, none hangs. Both tests recorded hung probes against the previous code;
605
+ - `run()` stops a hung command and reports its output;
606
+ - `waitFor` gives up on a check that never settles.
607
+
608
+ The full Node suite then passed 8 times in a row on two CPUs.
609
+
610
+ ### CI: benchmark regression (2026-11-04)
611
+
612
+ The walking skeleton's CI run (41590010647) measured invocation overhead at 0.6 ms (p50) and a cold start of 3.0 s on Bun. The first Phase A run (41698617945) measured 10.6 ms and 6.8 s, which broke two budgets. Limiting a local run to four cores didn't reproduce it. A diagnostic pull request measured the runners directly.
613
+
614
+ - **No code regression.** The commit before Phase A (c5ed28d4) and the Phase A tip ran interleaved on the same runner, three rounds each (run 41722049015). On Bun, before and after Phase A measured a 4.4 s and 4.2 s cold start and 0.87 ms and 1.13 ms invocation overhead (medians). On Node they measured 5.0 s and 5.2 s, and 2.0 ms and 1.6 ms. A no-op invocation sends 9 statements before and after Phase A (pg_stat_statements). Phase A's identity reads the actor, roles, groups and permissions in one query.
615
+ - **Runner variance.** The same commit on the same runner, within 15 minutes, measured a Node cold start of 4.0 to 7.1 s and invocation overhead of 1.2 to 5.4 ms (run 41724409657). The slow rounds were slow on every measure at once. The 10.6 ms run was one of these episodes: the next `build/main` run measured 1.2 ms.
616
+ - **Not leftovers from the tests.** After the tests no kernel, zero-cache or Vite process was left, no PostgreSQL session was open and no autovacuum was running. The machine was 30 to 70 % idle during the benchmarks. Benchmarks run straight after the tests were no slower than on a fresh runner (run 41720144709).
617
+ - **The cause.** Before Phase A, the cold start already used 3.6 to 5.6 s of its 5 s budget on these runners. The bench's step timings show the critical path:
618
+ - zero-cache starts five Node processes one after another;
619
+ - the orchestrator imported the whole kernel before it started anything;
620
+ - on Node the kernel loaded twice, once for `prepare` and once to serve;
621
+ - Vite transformed the shell only on the first page load (0.9 to 1.6 s);
622
+ - setup sent no-op DDL, and each statement ran zero-cache's event-trigger schema introspection (20 to 50 ms each, 0.44 s per prepare locally). Policy residuals in hash-map order made every setup of the docs fixture re-harden.
623
+ - **Fixes:**
624
+ - setup sends DDL only when something changes;
625
+ - residuals are compiled in a fixed order;
626
+ - the orchestrator imports only `@eloxiv/testing/system`;
627
+ - `server/main.ts prepare-and-serve` (app 0.2.1) sets up, seeds and serves in one process (`startSystem({ prepareInKernel })`, used by `mise run dev` and the e2e system);
628
+ - the shell warms up its modules (`server.warmup`, shell 0.2.1);
629
+ - `NODE_COMPILE_CACHE` keeps Node's compiled code in `.eloxiv/node-compile-cache`.
630
+
631
+ The bench now reports each startup step, every phase's duration and, on CI, an environment snapshot. The benchmarks that start their own system use the e2e ports and drop their databases afterwards. The e2e teardown stops the system even when the shell has already exited. zero-cache's internal change-streamer gets a free port of its own (`ZERO_CHANGE_STREAMER_PORT`): it used `port + 1`, which another process sometimes held under parallel tests, so `inbox-sync.test.ts` timed out with `EADDRINUSE`.
632
+
633
+ ### CI: build/main health (2026-11-09)
634
+
635
+ `check (node)` failed twice on `build/main` after B′: run 41908328825 (zero-upgrade) and run 41931121774 (cold start 5811 ms against its 5 s budget).
636
+
637
+ - **Cold start: runner variance, not a regression.** `d9ef07d6` (run 41931121774, 5811 ms on Node) and `14746d51` (run 42559884168, 2573 ms on Node, 2410 ms on Bun) differ only in two documents. In the slow run even the bench's fixed steps were slow: checking the publication (one `psql`) took 27 ms where it takes 3 to 8 ms, and the kernel's spawn took 45 ms instead of 5 to 9 ms. The pre-B′ commit `46c03563` failed the same way at 6268 ms (run 41736154633). One pre-B′ commit measured 3.2 to 7.1 s within a single job (run 41724409657). Locally (16 cores, interleaved, rounds at load 7 to 30), the medians were 3.27 s on Node and 3.05 s on Bun before B′ (`21a3cde4`), and 3.46 s and 3.15 s after it (`81010bd2`). The critical path is unchanged: zero-cache starting from a fresh replica, ready at about 2.5 s. B′ adds `drizzle-orm` (102 modules, about 250 ms to import on Node) to the kernel's start, so on Node the kernel is ready about 0.3 s later (1.12 to 1.42 s). That is still about a second before zero-cache is ready. No budget changed.
638
+ - **zero-upgrade: a port two tests shared.** `freePort` releases its port before the caller's server listens, which takes seconds for a child process. The operating system hands the same ports out again soon after (300 calls returned 3 to 8 repeats), so another test's server could take the port first. zero-cache then could not listen, and `startZeroCache`'s readiness check (any status below 500) took the other server's answer for zero-cache's. The client's sync connection then failed until its timeout ("WebSocket connection closed abruptly", 30 s). Fixes:
639
+ - `freePort` reserves each port it hands out for every process on the machine for at least three minutes (`ELOXIV_PORTS_DIR`, set by the Vitest global setup). A reservation is a file `<port>@<window>`, created exclusively. A process looks at the neighbouring windows only after creating its own, and withdraws if it finds one. No process ever removes another's reservation: taking over a lapsed one by removing it and creating a fresh one let two of 16 racing processes win the same port (review).
640
+ - zero-cache is ready only when it answers its own `200 OK`.
641
+ - A child that exits before it is ready fails its start, with its output (`test-ports.test.ts`).
642
+ The same race could hand a kernel child's port to another server in every test that starts processes (durable-restart, approvals-restart, agent-restart, inbox-sync, the registry's sync test).
643
+ - **durable-restart: a sweep's runs were recorded after they started.** A kernel killed after a sweep handed a run to the engine, and before it recorded the run and moved the cursor, left an execution that ran without a `schedule_run` row. Under catch-up `once` or `skip`, the recovery sweep passed over that due time, so the run was never recorded, and the cron catch-up test waited for a ledger it could never match. Now one transaction records the runs (each with the start request it still owes, kernel migration 0044) and moves the cursor, the runs start after it commits, and every sweep first starts the runs a crash left pending. A run's record is never removed: when the engine refuses a retried start (the redeployed app no longer has the workflow or accepts its input), the record stays linked to its execution, or is marked `refused` with the reason when the engine never had it (`scheduler.test.ts`, review). Deterministic kill points on both sides of the record are in `durable-restart.test.ts` ("records every scheduled run that ran, and runs every one it recorded, when killed …").
644
+ - **durable-restart's kills were timed on statements that merely ran.** `held()` counted any active statement of a held kind, so a kill could land on one still running rather than at the gate. Two cases: a sweep's uncommitted record, so nothing was owed (CI run 42642812874); or a step's other update, so no run was cut off after its effect, which is what the cron catch-up case expects. A statement now counts as held only while it waits in the hold's `pg_sleep`, which has a deterministic test.
645
+ - **`dropDatabase` could fail on a slot still active** ("used by an active logical replication slot", kernel-inventory on CI run 42639278477). A terminated walsender releases its slot only as it exits, and a stopping zero-cache's workers can reconnect. It now refuses new connections to the database and terminates until none of its slots is active, then drops them and the database.
646
+ - **Cold start regressed with the Collab merge, and is fixed.** The example app now installs the collab and inbox modules too, so setup on a database already set up checks three times as many modules. On CI the kernel's start in development went from 0.8 s (Bun) and 1.3 s (Node) to 3.0 and 5.5 s, and both `check` jobs missed the cold start (run 42679308250). A CPU profile of a repeat `prepare` put 1.2 s of it in Cedar: setup compiled each entity's policies into row-level security filters three times, for the registry's scope check, setup's own and the policies themselves. The compilations are now memoised on everything they depend on. The column-type check also resolved each declared type with its own query, one per field; it now runs one query per module. A repeat `prepare` locally took 2.2 to 2.4 s on Bun and 3.0 to 3.3 s on Node; it now takes 1.5 and 2.1 s (0.9 and 1.5 s before Collab, with fewer modules).
647
+ - **The second `mise run dev` failed setup.** zero-cache names its schemas after its app id (`<app id>` and `<app id>_<n>`), and the harness used the database's name as the app id. On the development database, `eloxiv`, zero-cache therefore created its `permissions` table, function and trigger in the kernel's own schema. Every start after the first then failed setup: "the kernel's schemas were changed outside setup (relation eloxiv.permissions added …)". Child kernels were never told the app id either, so setup's check of zero-cache's schemas used the default `zero`. Fixes:
648
+ - The app id is now `zero_<database>` (`zeroAppIdFor`), for zero-cache, for child kernels (`ELOXIV_ZERO_APP_ID`) and for in-process kernels alike.
649
+ - Setup refuses an app id any of whose schemas (`<app id>`, `<app id>_0` and its `/cdc` and `/cvr` stores) is the kernel's, `auth`, `public` or PostgreSQL's (`zeroSchemaProblems`; `pg` makes `pg_0`).
650
+ - Before each start, the harness looks for what a zero-cache left under an old app id (the database's name, and `eloxiv`): its shard schemas, its `permissions` table, its publications and replication slots. It never removes them. Three rounds of proving what zero-cache made (the owner, the tables' kinds, nothing outside depending on it) still let something go that was not zero-cache's: a module's schema called `<database>_0` with a view named `shardConfig`, then a same-owner table in zero-cache's schema and a cast outside it on its type (reviews). The start refuses instead. It names everything it found and says how to remove it: `mise run db:reset` for the development database, or by hand. Nothing is removed (`zero-cleanup.test.ts`).
651
+ - `registry/test/dev-restart.test.ts` starts the system as `mise run dev` does, twice on one database with zero-cache in between. After a zero-cache that ran as `eloxiv`, the next start refuses and names what it left.
652
+ - **Bun's cold start missed on a slow runner the calibration called healthy.** In run 42691022411 (`2f207d36`), every Bun cold start took 7.1 to 8.4 s, though one core hashed in 124 ms and a process started in 5.3 ms. Serving the sign-in page took 930 ms where a healthy runner takes 320 to 360 ms, with the shell's code unchanged. The same job's Node run took a median of 3.9 s. The calibration now also times every core at once, a process's wake-up, and PostgreSQL round trips ([performance.md](performance.md)). Locally, Bun's cold start is about 4 s at load 10. Its critical path is zero-cache's own start, not the kernel: the kernel is ready at about 1.8 s, zero-cache at about 4 s. About 1 s of zero-cache's start is setting up its CVR tables. Each statement there takes about 75 ms instead of 1 to 3 ms, because zero-cache's own DDL event triggers compute the whole published schema on every statement, and the example app now publishes the collab and inbox modules' tables too. On the local cluster (development and tests), zero-cache's CVR now lives in a database of its own, `<database>_cvr` (`zeroCvrDatabaseFor`, `ZERO_CVR_DB`). It is created before zero-cache starts and tagged with its parent's name and a random token, which the parent records (a line of its comment, after the test run's tag). It is used, and dropped with its parent, only when the tag matches the parent's token: a database of that name the harness did not make for the parent is refused and left alone (`zero-cvr.test.ts`; a review dropped an unrelated `<name>_cvr` before). Never on a managed host's profile. Its change log stays in the app's database, where the kernel's erasure deletes from it. On a managed host's profile nothing changes. Interleaved locally on Bun, zero-cache was ready at 2.8 to 2.9 s against 3.9 to 4.0 s. After merging `f9eccebc`, three cold `mise run dev` starts had the kernel ready at 1.44 to 1.53 s and zero-cache at 2.54 to 2.66 s. `kernel-inventory.test.ts` reads the CVR's tables from its database. On CI (run 42707289006, `e4d432fd`), the five cold starts took 3768 to 4210 ms on Bun (median 3939) and 3782 to 4217 ms on Node (median 3984). The kernel, ready at 2.2 s (Bun) and 2.7 s (Node), is now the critical path there, with zero-cache ready at 3.0 and 2.9 s.
653
+ - **Timing-dependent tests on Node, one per run, never the same one.** Most of these ran on `build/main`, without the shared-port fix above, which affected every test that starts processes. This branch's Node suite passed in all seven CI runs since `7c2ec0c1`. The deadlines that did not scale are fixed:
654
+ - `connection-sync.test.ts`, "two simultaneous runs …" (5 > 5): the first page waited at most 10 s for the other kernel to fetch, then committed alone, so the runs never overlapped. It now waits up to a scaled 45 s, and the test asserts that the runs overlapped.
655
+ - `sync-optional.test.ts`: its replica's first complete answer had 30 s; it now has a scaled 60 s.
656
+ - `agent-sync.test.ts`: a run, two replicas' hydration and two 30 s waits had the default 60 s; it now has a scaled 120 s.
657
+ - `optimistic.test.ts`, "queues writes while offline …": a hang of 90 s with nothing printed after the drop. It is not reproduced: 10 of 10 alone, 5 of 5 pinned to one core, 4 of 4 with the whole file. The test now waits a bounded, scaled time for the replica to reconnect, and on failure it reports every connection state the replica went through.
658
+ - The `testing` and `registry` projects' test and hook timeouts now scale with `ELOXIV_TEST_TIMEOUT_SCALE` (1 unless a job sets it), like the harness's own deadlines (`slow`).
659
+ - **Other intermittent failures:**
660
+ - Already fixed on 2026-11-04: `ingress.test.ts` "4242" (hex bodies contain it by chance), `agent-concurrency.test.ts` (reserved budgets) and `sync-property.test.ts` (fixed seeds).
661
+ - Load only: policy-compiler's property tests take 5 to 6 s alone against a 60 s timeout, so they time out only under heavy load.
662
+
663
+ ### Manifest review (2026-11-03)
664
+
665
+ An independent review of the full manifest and directory groups and roles found two blocking issues and three more. Each test below was watched failing on the code before the fix (the review's reproducers, then the repository's versions).
666
+
667
+ | # | Finding | Fix | Test |
668
+ | --- | --- | --- | --- |
669
+ | 1 | a published query view called `"set_config"` and `"query_to_xml"` by quoted names, switched to the kernel role, read another organisation's data and switched back (Postgres records no dependency on built-in functions) | setup resolves every callable in the view's stored query tree against an allowlist of side-effect-free `pg_catalog` built-ins (see [ModuleManifest](contracts/module-manifest.md)); the lexical check, kept as a first filter, refuses quoted function names; views are read in a read-only scope (`QueryViews.read`, `ctx.queryView`), and actions hinted `readOnly` run where the database refuses writes | `query-view-escape.test.ts`: the review's view, quoted, schema-qualified and upper-case names, casts that call functions, a module operator, calls in CTEs, subqueries, `EXISTS` and `FROM`; allowed views accepted; refused at startup and at setup; read-only reads and handler |
670
+ | 2 | a revoked reviewer's connected replica received a secret created after the revocation: directory state was bound into the transform, which zero-cache keeps running | sync compiles the read filter symbolically and evaluates every directory test, and membership, live in zero-cache against replicated directory facts (`eloxiv.sync_fact`), kept by triggers in the change's transaction ([Sync](contracts/sync.md), guarantees 6 and 7) | `sync-revocation.test.ts`, live through zero-cache with retransform out of reach: group, role permission, role and member removal (nothing written after the revocation delivered, earlier rows removed), re-grant, signed-out session; `registry/test/sync.test.ts`: a revoked sharing grant leaves a connected replica |
671
+ | 3 | every action's policy applied to every entity table and was ORed into `SELECT`, so an unrestricted permit for the organisation-only `team.peek` exposed other organisations' documents | an action's filter applies only to the entities it declares (`writes`, `target`, `actsOn`); startup refuses policies that reach records not tied to the actor unless the action is `organisationWide`, which confines it to the acting organisation; the same check applies to `read` | `action-scope.test.ts` |
672
+ | 4 | a database failure during a directory write left no audit record | every failed write is audited once after the rollback (`SqlError`, `Defect`) | `directory-audit.test.ts` |
673
+ | 5 | a directory manager can grant themselves anything | kept: `eloxiv.directory.manage` is documented as the organisation's superuser permission; every grant records its subject's state before and after (`audit_log.detail`) | `directory-audit.test.ts` |
674
+
675
+ Other instances found: `read` policies were unchecked for scope (an unanchored group-only read across organisations is now refused at startup); signed-out sessions kept syncing until Zero's 300 s revalidation (now bounded by `ZERO_AUTH_REVALIDATE_INTERVAL_SECONDS`, 30 s in development and tests, and proven); a view's DDL relies on the driver sending one prepared statement, which Postgres refuses to split, not on the lexical check (pinned by a test); the system directory helpers did not audit failures either.
676
+
677
+ ### Manifest re-review (2026-11-04)
678
+
679
+ A second independent review of those fixes found three blocking issues. Each test below was watched failing on the code before the fix.
680
+
681
+ | # | Finding | Fix | Test |
682
+ | --- | --- | --- | --- |
683
+ | 1 | a migration created an enum and a volatile cast from it to `json` that switched to the kernel role; `to_json('box'::team.box)`, `row_to_json(ROW(...))` and `to_json(d.title::team.box)` passed the call check, because `to_json` looks the cast up when it runs | the view check resolves the type of every value in the stored query tree (each expression's result, every column read, every row type's fields) and accepts only allowlisted built-ins, `record`, `unknown`, and the module's enums and table row types made of them that no cast involves; setup refuses migrations that leave a cast to or from the module's types or through its functions, foreign tables, and base types with their own I/O | `query-view-types.test.ts`: the review's three variants and `to_jsonb`, `array_to_json`, `json_build_object`, `json_agg`, record output, `format`, `||`, a composite type, a whole row and a column of such a type, domains; plain values, rows and cast-free enums accepted; refused at setup, with or without views |
684
+ | 2 | a published view joined a migration-created `security_invoker` helper view that called the role-switching function; only the helper's schema was checked | a view may read only tables (relkind `r`, `p`) of the module's schema: never another view, materialised view or foreign table | `query-view-types.test.ts`: the review's helper view, a harmless view, a materialised view; refused at setup |
685
+ | 3 | a trusted `Directory.addMember`, which skipped the organisation lock managed writes take, overlapped `setRolePermissions` revoking a permission; its trigger read the old permission, waited on the fact row being deleted, and reinserted it after the revocation committed, so a connected replica received a record written after both calls | kernel migration `0017_serialised_sync_facts` (now `0024_serialised_sync_facts`): every trigger that maintains `sync_fact` or `sync_org` takes the organisation's directory lock (`eloxiv.lock_directory`) before it reads and recomputes from committed state, so every writer serialises, whatever path; a directory change outside READ COMMITTED is refused; existing facts are recomputed once. The system helpers and service-principal writes take the lock first, as management calls do | `sync-fact-concurrency.test.ts`: the review's schedule live through zero-cache, for a trusted `addMember` and a plain SQL insert; twelve rounds of 48 concurrent mixed writes through every path, then the facts must equal those recomputed from the directory |
686
+
687
+ Other instances found: the kernel's write log (`eloxiv.track_write`, `SECURITY DEFINER`, owned by the kernel role) runs `to_jsonb(NEW)` on every written module row, so a module's cast from a column's enum to `json` ran as the kernel role on any write, with no view involved (closed by setup's cast refusal); `createServicePrincipal` checked that a principal's roles grant nothing beyond the caller's permissions without the directory lock (it now takes it); `deleteServicePrincipal` removes a membership without the last-manager check that management calls make (still open: a principal that is the organisation's only manager can be deleted). No other trigger-maintained derived table exists (`invocation_write` is a per-transaction log, not derived state). The query surface is the published views (`QueryViews.read` selects `*` from them), so it shares this check; its results are encoded only through allowed types' built-in output functions. The CLI tests left their temporary directories in `/tmp`; they now remove them.
688
+
689
+ ### Manifest re-review, round 3 (2026-11-04)
690
+
691
+ An independent re-review of round 2 found two blocking issues and one should-fix. Module migrations are not trusted with superuser rights: agent-made (MAKE) modules use the same manifest and migrations. Each test below was watched failing on the code before the fix.
692
+
693
+ | # | Finding | Fix | Test |
694
+ | --- | --- | --- | --- |
695
+ | 1 | setup's checks read the catalogue by unqualified names on the session migrations had run on, where PostgreSQL searches `pg_temp` first: a migration's `CREATE TEMP VIEW pg_cast AS ... WHERE false` hid its enum-to-json cast, which then leaked another organisation's data through a published view | every catalogue relation in setup's checks (and in the schema snapshot) is named `pg_catalog.*`, the checks run with `pg_temp` last on the search path, and they run again on setup's own session, where no migration runs; module roles may not create temporary objects at all (`TEMPORARY` revoked from `PUBLIC`) | `migration-session.test.ts`: the review's view end to end and the hidden cast at setup; every check run in a session holding empty temporary views named after each catalogue it reads and temporary tables named `text`, `oid` and `regclass` still finds every problem |
696
+ | 2 | migrations ran on setup's superuser session under `SET LOCAL ROLE <owner>`, which `RESET ROLE` (or `set_config('role', 'none')`, or `SET SESSION AUTHORIZATION`) undid; the reproducer set BYPASSRLS on a runtime role | each module's migrations run on a connection that logs in as its owner role (LOGIN and a one-time password only while setup connects it, under the cluster's role lock), in that session's own transaction, which records them (`eloxiv_setup.record_migration`, kernel migration `0018_owner_migrations`, now `0025_owner_migrations`), closes the module (forced row-level security, no policies, no privileges) and checks it before committing; setup then hardens on its own session ([Release](contracts/release.md), guarantee 2). Every setup strips module roles of every privileged attribute, password, LOGIN and membership | `migration-session.test.ts`: `RESET ROLE`, `set_config` in a DO block and in a created function, and `SET SESSION AUTHORIZATION` each fail setup, leave BYPASSRLS unset and create nothing outside the module; the owner role holds no privileged attribute or membership and cannot log in after setup; `release.test.ts` and `release-atomic.test.ts` unchanged |
697
+ | 3 | `TRUNCATE` skips the row triggers that keep the sync facts | a statement trigger refuses `TRUNCATE` on every directory table (`0018_owner_migrations`, now `0025`) | `sync-fact-concurrency.test.ts`: `TRUNCATE ... CASCADE` of each directory table refused, facts unchanged; a directory change at REPEATABLE READ or SERIALIZABLE refused |
698
+
699
+ (The release review's single transaction and this round's owner sessions were reconciled in "Setup integration" below.) Other instances found: `'eloxiv.guard_key'::regproc` and `'pg_rewrite'::regclass` in the checks resolved names through the search path (now catalogue lookups by name, or qualified); module roles' attributes and memberships were never re-checked after creation (now every setup); a migration's default privileges would grant objects created later (now refused).
700
+
701
+ ### Setup integration (2026-11-04)
702
+
703
+ `build/release-fixes` (one transaction for all of setup on the lease's session, the libpg-query preflight, recorded security state and repair) and the manifest re-review's round 3 (module migrations on owner-login sessions, fail-closed steps) were merged into one setup ([Release](contracts/release.md), guarantee 2), keeping every guarantee of both:
704
+
705
+ - **Order.** Preflight (libpg-query; it covers what owner sessions run too) → module roles restored under the cluster's role lock (`enforceModuleRoles`, reported in `repaired`) → the lease → step 0, committed: module schemas and `eloxiv_setup.record_migration` (created by bootstrap when missing, since owner sessions record their migrations while the kernel's are still uncommitted) → step 1: each module on its owner session, in its own transaction, closed and checked, committed only if the lease session's pid still holds the lock (`assertLeaseHeldBy`) → step 2, one transaction on the lease session: Better Auth's, the kernel's and Effect cluster's migrations, hardening with the security state and role hygiene, views, publication, snapshots.
706
+ - **Atomicity.** Stronger than round 3, which committed the kernel's and Better Auth's migrations before the owner sessions: they are now in step 2 with the hardening, so a module migration that fails leaves the database exactly as it was, a fresh database's Better Auth tables included (`release-atomic.test.ts`). Holding owner transactions open until step 2 could commit was rejected: step 2 cannot check or harden what it cannot see, and with a DDL-serialising event trigger (zero-cache's `pg_advisory_xact_lock` on every `CREATE`/`ALTER TABLE`) two open DDL transactions wait on each other forever, which is also why step 2 does no DDL before the owner sessions commit. What remains is the documented window: a failure in step 2 leaves the migrated modules closed (new test: the Release kit's `stage.misnamed`, then `stage.renamed` reopens it).
707
+ - **Lease.** Owner sessions cannot read the lease's record, so they check the lease session's backend pid in `pg_locks`; a setup that takes the lock first terminates any owner session a lost setup left (application name `eloxiv-setup-migrations`), so `release-lease-loss.test.ts` holds with the blocked migration on an owner session.
708
+ - **Roles.** `MODULE_ROLE_LOGIN` is false for both roles: the owner logs in only while setup connects it, under the role lock. Step 2 restores everything but the owner's LOGIN (another database's setup may be connecting the same owner role), and the owner's LOGIN is left out of the recorded security state (format 3), so a concurrent connect never reads as drift.
709
+ - **Migrations.** Kernel migrations renumbered to one sequence: `0017_serialised_sync_facts`, `0018_owner_migrations`, `0019_hardening_state` (was release-fixes' `0017_hardening_state`), and again in integration round 3, after build/main's `0017` to `0023`: `0024_serialised_sync_facts`, `0025_owner_migrations`, `0026_hardening_state`; each is safe to run again, which `release.test.ts` checks by applying all three again on a database that recorded them under other names. Snapshots regenerated with `vitest -u`.
710
+ - Also found: the Release kit's and `release-atomic.test.ts`'s catalogue descriptions aggregated with `ORDER BY 1`, which orders by a constant, so trigger and policy lists came in plan order and a test failed once under load; they now order by value.
711
+
712
+ ### Setup review (2026-11-04)
713
+
714
+ An independent review of the integrated setup found two blocking issues and four should-fix ones; neither blocking issue was new (both exist at `61995210`). Each test below was watched failing on the code before the fix.
715
+
716
+ | # | Finding | Fix | Test |
717
+ | --- | --- | --- | --- |
718
+ | B1 | zero-cache's DDL event triggers run as the role issuing DDL and use zero-cache's own schema, so every module migration, kernel migration and Better Auth DDL failed (`permission denied for schema <shard>`) in a database zero-cache had replicated, also after it stopped | setup disables the shard's triggers for its run (re-enabled however it ends, and by the next setup after a crash) and announces each schema change itself, in the statement's transaction: `ddlUpdate` with the statement's command tag for table and index DDL (what the trigger would have emitted), zero-cache's `update_schemas()` snapshot hook otherwise, through a fixed superuser-owned `eloxiv_setup.announce_schema(tag)` (`db/ZeroDdl.ts`; evidence in [spikes/sync-and-rpc.md](spikes/sync-and-rpc.md)). Statements now run one at a time, split with libpg-query | `zero-upgrade.test.ts`: a syncing client receives a new column's values and a new table's rows its migration wrote, with zero-cache running, and with it stopped during setup and resumed from its replica without a reset; a kernel migration and Better Auth's DDL; replication continues |
719
+ | B2 | a manifest could claim `auth`, `eloxiv`, `eloxiv_setup`, `pg_catalog` or another module's schema, a module could be named `eloxiv`, and role names could exceed 63 bytes; setup then made the owner role the schema's owner (`schema: "auth"` dropped Better Auth's tables). An owner session could record `9999_future` | module names: a plain identifier of at most 52 characters, not `eloxiv`, `eloxiv_*` or `pg_*` (`moduleNameProblem`, with the manifests); schemas: not PostgreSQL's, `public`, `auth`, `eloxiv` or `eloxiv_*` (but the kernel's own modules' `eloxiv_<name>`), never shared, and every entity in its module's schema (`ModuleIdentity.ts`, in `appProblems` and the Registry); setup refuses an existing schema owned by anyone but the module's roles; `record_migration` records only names setup planned for that module (`eloxiv_setup.migration_plan`) | `module-identity.test.ts`: twelve reserved schemas, six names, a shared schema, a stray entity; a foreign `ledger` schema left as it was; `9999_future` refused and nothing recorded |
720
+ | S1 | a module with query views was re-hardened and reported `repaired` on every setup: its state was recorded before its views were granted | `hardenModules` publishes each module's views before it records the state | Release kit "records a module's state with its published views" |
721
+ | S2 | a closed module kept the schema privileges a migration granted (`CREATE`), and `ALL FUNCTIONS` left procedures | closing revokes everything on the schema and `ALL ROUTINES` from everyone but the owner, the runtime role and `PUBLIC` included; hardening revokes routines before granting functions | Release kit fail-closed test: the closed module's runtime role holds nothing on the schema, its relations or routines; reopened without the `CREATE` or the procedure |
722
+ | S3 | grants on kernel and Better Auth tables to module roles, `TEMPORARY` on the database, per-role settings and kernel function bodies were not security state (kernel-schema changes were simply re-recorded); an owner left with `LOGIN` was not reported; the `NOLOGIN` finalizer ignored errors | the module's state records its roles' privileges in the kernel's and Better Auth's schemas, `CREATE`/`TEMPORARY` on the database and their settings, all revoked or reset before any owner session connects (`moduleSessionHygiene`); the kernel's schemas have a recorded state of their own, compared before setup changes anything and refused, never recorded (`kernelSecurityState`, `assertKernelState`); `status` reports an owner role with `LOGIN` while its login lock is free; removing the login after connecting fails the setup, the finalizer logs | Release kit role drift (seven new cases) and kernel drift (`eloxiv_ctx.has_role` replaced) |
723
+ | S4 | the one-time password went to PostgreSQL in clear, in a traced statement (`db.query.text`) | setup sends a SCRAM-SHA-256 verifier it computes (`db/Scram.ts`), in an untraced statement; `pg_hba.conf` rules that let owner roles in without a password are refused with `ELOXIV_ENV=production` and a warning otherwise | `owner-login.test.ts`: no traced statement holds a password; the verifier equals PostgreSQL's for the same salt; production refuses this cluster's `trust` rules |
724
+ | note | the lease's termination sweep matched owner sessions by application name, which a migration can change | it matches the role they logged in as | `release-lease-loss.test.ts` (`stage.blockingRenamed`) |
725
+
726
+ Also found: a migration file chunk holding two statements failed (`cannot insert multiple commands into a prepared statement`); statements are now split with libpg-query. In tests, a Zero client of an old schema left connected while the kernel serves the new one schedules a page reload on a timer shared by every client in the process; `zero-upgrade.test.ts` closes it first.
727
+
728
+ ### Setup re-review (2026-11-04)
729
+
730
+ A second independent review of the setup confirmed the first round's fixes and found one blocking issue (older than the branch), three should-fix ones and notes. Each test below was watched failing on the code before the fix.
731
+
732
+ | # | Finding | Fix | Test |
733
+ | --- | --- | --- | --- |
734
+ | K1 | PUBLIC may run `pg_catalog.pg_logical_emit_message`: a migration with no DDL forged zero-cache's DDL message and zero-cache dropped `eloxiv.sync_org` from every replica | setup revokes it (both forms) and the large-object constructors from PUBLIC in the app's database, and holds that as the kernel's security state; the audit of what else every role may run is in [Release](contracts/release.md) ("Not yet guaranteed") | `catalog-privileges.test.ts`: the forging migration refused, nothing recorded; no module or kernel role may run them; granted back, setup refuses |
735
+ | S1 | re-enabling zero-cache's triggers ran on the lease session and ignored failure: a lost lease left them disabled | they are enabled again on a fresh connection, failures logged; `status` reports them disabled while no setup holds the lease (`insecure`: `zero-cache`); the next setup enables them | `zero-ddl.test.ts`: lease terminated mid-migration, triggers enabled again; left disabled, `status` reports it and setup repairs it |
736
+ | S2 | DDL inside a `DO` block, a function or a trigger was announced only after the statement, after the rows written with it, so zero-cache halted and reset its replicas | an Eloxiv `ddl_command_end` event trigger, superuser-owned, enabled only while setup runs, announces each DDL command where it happens (an event trigger is the only place PostgreSQL reports it there; refusing nested DDL would refuse ordinary migrations and still miss DDL run by triggers) | `zero-upgrade.test.ts` "a column a DO block adds and fills" live (failed with the event trigger off); `zero-ddl.test.ts` positions |
737
+ | S3 | the kernel's recorded state was in a kernel-owned table, and a missing record was skipped | the record is in `eloxiv_release.kernel_state`, which only setup's superuser writes; after the first setup a missing or foreign-format record is refused unless the operator re-baselines (`rebaselineKernelState`, `ELOXIV_SETUP_REBASELINE=1`) | `kernel-state.test.ts`: the kernel role replaces a kernel function and tries to delete the record, setup still refuses; a missing record refused, then re-baselined |
738
+ | notes | owner-role `pg_hba.conf` methods other than password; zero-cache's schemas claimable by modules; `announce_schema` took no lock and trusted any shard schema; kernel state lacked column privileges, default privileges and view definitions; a migration could record a later one of its own module | every method but `scram-sha-256` (`md5`/`password` warn) is refused in production; zero-cache's `<app id>` and `<app id>_<n>` are reserved (`ELOXIV_ZERO_APP_ID`); `announce_schema` takes zero-cache's DDL lock and refuses a shard a superuser does not own; the kernel state covers those; `record_migration` records only the migration setup marked as being applied | `owner-login.test.ts`, `module-identity.test.ts`, `zero-ddl.test.ts`, `kernel-state.test.ts` |
739
+
740
+ Operators of databases set up before this change run setup once with `ELOXIV_SETUP_REBASELINE=1`: their kernel state was recorded in the old place.
741
+
742
+ ### Integration round 3 (2026-11-04)
743
+
744
+ `build/setup` (the manifest and release fixes and the setup design above) merged into `build/main`, which had gained the query surface, settings and flags, the agent, sharing, connections, the daemon and devices since `61995210`:
745
+
746
+ - **Kernel migrations:** `0024_serialised_sync_facts`, `0025_owner_migrations`, `0026_hardening_state`, after `0023_devices`; each runs again unchanged under any earlier name (`release.test.ts`).
747
+ - **Kernel-provided modules** (inbox, notifications, approvals, consent, scheduler, sharing, settings, flags, query, agent, devices, connections) are marked once, by `provideKernelModule`, and only they may take a schema `eloxiv_<name>` (`ModuleIdentity.ts` asks `KernelModule.ts`, so no package export can mark a module); the query module moved from `eloxiv_query_module` to `eloxiv_query`. An existing database keeps an empty `eloxiv_query_module` schema owned by `eloxiv_own_query` (drop it, or reset the database; nothing was deployed).
748
+ - **The query surface and platform reads** follow setup's steps (see "The query surface, settings and flags"); the legacy `REASSIGN OWNED` of a runtime role's objects runs only when that role still owns something in its schema, since it would hand over the module's query-surface views too.
749
+ - **View checks:** build/main's `treeProblems` (surface queries: views of the surface only, no set-returning functions, constants and encoding arguments of allowed types) with setup's checks of views (every value's type, tables of the module's schema only, the catalogue read qualified); encoding functions accept the module types setup's `typeProblems` admits (an enum or a table row with no cast involved, field by field).
750
+ - **Found on the way:** the email fact's trigger (`0020_sharing`) recomputed a member's facts without the directory lock, so an email change racing a revocation restored the revoked permission (fixed in `0024`; `sync-fact-concurrency.test.ts`). A run cancelled mid-turn did not cancel its device turn (its own cancellation guard refused the call), and a harness could still act until the runner's next heartbeat (the relay now asks the kernel before each call); `agent-device.test.ts`.
751
+
752
+ ## Directory map
753
+
754
+ ```
755
+ mise.toml tools, environment and tasks
756
+ packages/
757
+ contracts/ @eloxiv/contracts (src/: errors, records, manifests; src/contracts/: kernel service
758
+ contracts; schema/*.json and schema/contracts/*.json, scripts/emit.ts)
759
+ kernel/ @eloxiv/kernel (src/: Invocation, Identity, Approvals, Directory, Outbox, Sync,
760
+ Notifications, WorkItems, Release, Readiness, Workflows, Scheduler, Server;
761
+ inbox/ (the approvals, consent, inbox and notifications modules and their workflows),
762
+ machine/ (MachineIdentity, the OAuth server and its pages, tokens), ingress/,
763
+ notifications/ (SMTP; push: APNs, FCM, decision tokens), durable/ (Definition, Trust: the kernel's workflows), KernelModule
764
+ (the kernel boundary), scheduler/, policy/ (Cedar compiler, RLS), surfaces/, sharing/,
765
+ query/, settings/, flags/, agent/, connections/ (Secrets, Connections, Metering, sync),
766
+ devices/ (paired devices, the turn queue), sandbox/ (QuickJS), make/ (MAKE), files/ (Files, the storage backends, SigV4,
767
+ sniffing), search/ (Search, the index's sources), ingestion/ (Ingestion, extraction,
768
+ chunking), records/ (record access for kernel code), db/ (bootstrap, kernel migrations,
769
+ schema.snapshot.json), runtime/)
770
+ client/ @eloxiv/client (src/; @eloxiv/client/sync: the kernel's sync tables;
771
+ @eloxiv/client/expo-sqlite: a Zero store for React Native)
772
+ testing/ @eloxiv/testing (src/: startKernel, startSystem, SMTP sink; src/conformance/: the
773
+ kits, their reference subjects and fixture apps (fixture, purchases, desk, ledger, archive);
774
+ src/fakes/: protocol fakes (Graph, Google, acme, S3);
775
+ test/: the kernel's tests and their fixture apps)
776
+ daemon/ @eloxiv/daemon (src/: pairing, custody, relay, harness adapters, headless runner;
777
+ fixtures/: the fake harness and recorded real streams; scripts/build-sidecar.ts)
778
+ cli/ @eloxiv/cli (src/: Cli, App, Registry, Update, Merge, Publish, Remote, Run, Deploy,
779
+ Postgres, DbAdmin, Guards, Docs, Migrate, Dossier, Blueprint, Changelog, Evals, AgentWeb, Brand)
780
+ registry/
781
+ registry.json shadcn registry index (items: app, hello, notes, people, mail, calendar, shell-foldkit, hello-ui-foldkit, notes-ui-foldkit, chat-ui-foldkit, approvals-ui-foldkit, home-ui-foldkit, inbox-ui-foldkit, members-ui-foldkit, people-ui-foldkit, mail-ui-foldkit, calendar-ui-foldkit, theme, desktop, desktop-rune, mobile, microsoft-graph, google, slack, openai, meeting-prep)
782
+ app/ item sources in app layout (modules/, connectors/, shell/, desktop/, server/, eloxiv.*.ts)
783
+ public/r/ built items (shadcn build), with immutable copies per version (<item>/<version>.json)
784
+ test/ integration tests over registry/app (__snapshots__/: module schema snapshots)
785
+ scripts/ index.ts (registry.json), publish.ts (immutable versions), compose.ts (registry/app's
786
+ composition files)
787
+ examples/hello-app/ app assembled only through the CLI (eloxiv.json, eloxiv.lock.json; mobile/ is its Expo host)
788
+ examples/headless-app/ the same, with no UI
789
+ e2e/ Playwright end-to-end suite and its global setup
790
+ bench/ budgets, benchmarks (src/), browser benchmark (browser/)
791
+ tools/
792
+ dev/ mise run dev
793
+ done/ the definition-of-done gate (mise run done); documentation.ts: every CLI command and flag,
794
+ contract version and registry item documented (criterion 18)
795
+ scripts/ pg.sh, test.sh, bench.sh, desktop-lane.ts (CI's desktop lanes), react-native-harness.ts,
796
+ mobile-harness.ts (CI's mobile lane: the Expo host driven on an Android emulator)
797
+ react-native/ the React Native guard: an Expo app (not in the pnpm workspace; npm); its harness is scripts/react-native-harness.ts
798
+ fallow/ client portability rule pack
799
+ docs/
800
+ decisions.md the settled architecture (unchanged)
801
+ goal.md, progress.md the goal and the working record toward it
802
+ scaffold.md this document
803
+ security/ threat-model.md: assets, actors, trust boundaries, threats per area mapped to code and tests
804
+ backlog.md accepted skeleton limits, as backlog items for the full build
805
+ getting-started.md for an outside developer: an app from the registry, a module of its own, screens on the
806
+ Foldkit adapter and a chat on the headless chat SDK (every step run as written)
807
+ registry/ one page per registry item (README.md, the index); connectors' pages are in connectors/
808
+ contracts/ one page per published kernel contract (README.md lists them)
809
+ connectors/ one page per connector: what it uses, its protocol fake, real-account setup
810
+ cli.md the eloxiv CLI
811
+ parity.json, parity.md ledger parity and its report
812
+ research/ research notes
813
+ spikes/ decision 5 and decision 2 records, evidence/tauri/
814
+ ```
815
+
816
+ ## System changes outside the repository
817
+
818
+ - mise installs under `~/.local/share/mise/installs` (Node, Bun, pnpm, PostgreSQL binaries, Rust via rustup into `~/.rustup` and `~/.cargo/bin`).
819
+ - Playwright Chromium under `~/.cache/ms-playwright`.
820
+ - pacman: `xorg-server-xvfb` and `webkitgtk-6.0` (for `WebKitWebDriver`), installed by the desktop work.
821
+ - Crate downloads in `~/.cargo/registry`; Tauri webview data in `~/.local/share/dev.eloxiv.app` (the desktop lane and the launch benchmark use a temporary `XDG_DATA_HOME` instead: state left there by another checkout stopped the shell rendering).
822
+ - The React Native guard was built and run locally with a JDK 17 from mise (`java@temurin-17`, not in `mise.toml`) and an Android SDK, emulator and `android-35` x86_64 image under `~/.cache/eloxiv-android`; CI uses the runner's own JDK and SDK.
823
+
824
+ ## Upstream versions
825
+
826
+ Effect 4.1.2 (`effect`, `@effect/platform-node`, `@effect/platform-bun`, `@effect/sql-pg`, `@effect/vitest`), `@rocicorp/zero` 1.11.3, Better Auth 1.7.15, `@cedar-policy/cedar-wasm` 4.14.0, AI SDK (`ai`) 7.0.159, Drizzle ORM 0.45.4 and Kit 0.31.11, Foldkit 0.170.0 (`foldkit`, `@foldkit/ui`; `@foldkit/vite-plugin` 0.29.0), StyleX 0.19.1, Vite 8.3.5, shadcn 4.23.0 (the registry's build only), Tauri 2.12 (CLI 2.12.4), TypeScript 7.0.2, Oxlint 1.90.0, oxfmt 0.75.0, fallow 3.38.1, Turborepo 2.11.10, Vitest 5.0.5, Playwright 1.64.1, Changesets 3.0.3, `quickjs-emscripten-core` and `@jitl/quickjs-wasmfile-release-sync` 0.32.0. Note that in Effect 4 the platform abstractions (`FileSystem`, `Path`, HTTP, RPC, SQL, CLI, AI) live in `effect` itself; `@effect/platform` is the Effect 3 package and is not used.