@eloxiv/cli 0.0.0-stage → 0.1.1

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 +110 -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 +50 -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 +35 -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,99 @@
1
+ # Versioning
2
+
3
+ Module versions (the installed version of each module, its upgrade history, and compatibility between a module's version and the kernel's) and record history for entities that opt in (decisions.md "Kernel contracts"; the ledger's A-053, B-042, C-025).
4
+
5
+ - Kind: kernel service. Version 1.1.0 (1.1.0 added agent edit groups: `versioning.agentEdits`, `ctx.history.revert` and the `agent` of a version).
6
+ - Schema: [`packages/contracts/schema/contracts/Versioning.json`](../../packages/contracts/schema/contracts/Versioning.json) (source [`Versioning.ts`](../../packages/contracts/src/contracts/Versioning.ts); `satisfiesRange` in [`Versions.ts`](../../packages/contracts/src/Versions.ts)).
7
+ - Implementation: setup's checks and records in [`packages/kernel/src/Release.ts`](../../packages/kernel/src/Release.ts) (`moduleVersionProblems`, `recordModuleVersions`); the `Versioning` service in [`packages/kernel/src/Versioning.ts`](../../packages/kernel/src/Versioning.ts); the kernel module `versioningModule` ([`versioning/module.ts`](../../packages/kernel/src/versioning/module.ts)); kernel migrations `0030_platform_services` and `0185_agent_edit_groups`.
8
+ - Kit: `@eloxiv/testing/conformance/Versioning` ([source](../../packages/testing/src/conformance/Versioning.ts)).
9
+
10
+ ## Module versions
11
+
12
+ A module's manifest has a `version` (`major.minor.patch`) and may declare the kernel versions it works with:
13
+
14
+ ```ts
15
+ defineModuleContract({ name: "journal", version: "1.2.0", kernel: ">=0.1.0 <1.0.0", ... })
16
+ ```
17
+
18
+ Ranges are space-separated comparators that must all hold (`>=`, `<=`, `>`, `<`, `=`), alternatives joined by `||`, `^x.y.z` (same major; same minor below 1.0), `~x.y.z` (same minor), `x`-wildcards (`1.x`) and `*`. The kernel refuses at startup a range or a version it cannot read.
19
+
20
+ **Setup** (the [Release](release.md) contract), before it changes anything, refuses a module whose range excludes the kernel's version (`KERNEL_VERSION`) and a module older than the version installed (a downgrade; a MAKE module goes back only through MAKE's `make.rollback`, an administrator's audited action to a version installed before, which runs this setup with it): the setup fails with `MigrationFailed` naming the module, and the database is as it was. In the transaction that applies the kernel's migrations and hardens every module, it records each module's version and kernel range (`eloxiv.module_version`) and, for every module whose version changed or that is new, a history row (`eloxiv.module_version_history`: from, to, the kernel's version, when). So the record never disagrees with the schema.
21
+
22
+ ## Record history
23
+
24
+ An entity opts in with `history: true` in its definition (`defineEntity(table, { ..., history: true })`, `@eloxiv/contracts/drizzle`; the manifest publishes it on the entity). Setup installs the entity's write-log trigger with `'history'` (`eloxiv.track_write(<pk>, 'history')`), so the log keeps the row each change left, or the row as it was for a delete. After an action's writes pass the invocation path's checks, the kernel records **one version per record the call changed** in `eloxiv.record_history`: the record's last state in that call, `insert`, `update` or `delete`, numbered after the record's previous versions, with the acting person, the action and its invocation id (the same id as the call's audit record), in the call's transaction. A record created and deleted in one call leaves nothing. A refused or failed call records nothing.
25
+
26
+ The history table is the kernel's: **no module role may read, write or delete it** (setup grants nothing on it; the platform read role may select the columns `record_version` returns).
27
+
28
+ **Reading** (`versioning.history`, `versioning.version`): a record's history is shown to whoever the record's own read policy admits **in its latest state**: the current row, read as its module's runtime role under row-level security, or, once deleted, the last recorded version, filtered by the compiled read policy as that role. So making a record private takes its whole history from everyone the policy no longer admits, earlier org-visible versions included. Anything else (no such record, no history, an entity without history, not readable, another organisation) is one `Forbidden`.
29
+
30
+ **Restoring** is the module's own action, so its own policy decides who may restore:
31
+
32
+ ```ts
33
+ restore: (input, ctx) =>
34
+ ctx.history.restore("entry", input.id, input.version).pipe(Effect.map((id) => ({ id, restoredVersion: input.version }))),
35
+ ```
36
+
37
+ `ctx.history.restore(entity, id, version)` works only on the calling module's own entities with history. It checks the caller can read the record (as it stands, or as last recorded once deleted), reads the version through the platform read function `eloxiv_platform.record_version` (`SECURITY DEFINER`; only the acting module's entities, in the caller's organisation, as the invocation context records them), and writes it back on the handler's connection as the handler's role: an `UPDATE` of the entity's columns, or an `INSERT` of the whole row for a deleted record. The write goes through the action's policy and checks like any other (declare the entity as `writes`); an update row-level security filters out is a refusal. The restore is recorded as a new version.
38
+
39
+ ## Agent edit groups
40
+
41
+ Every change an agent run makes is kept with the run, and with the conversation and the person's message that started it (a sub-agent's changes with its parent's): the run records its **edit group** when it is queued and gives it to each tool call (an agent's call that waits for a business approval keeps it in the request's provenance, and executes with it once approved), the invocation path records it on the call's invocation context and on every version the call makes (`RecordVersion.agent`: `{ runId, conversationId, messageId }`), and the [CollabDocument](collab-document.md#agent-autosaves-and-revert) service keeps an autosave of each document the run changes. That is the agent's autosave: nothing for the module or the app to register.
42
+
43
+ A group is named by its conversation and, optionally, a message: `{ conversationId, messageId }` is the run that message started (with its sub-agents'), `{ conversationId }` every run of the conversation, back to the start of the chat. **Only the caller's own runs belong to their group**: the versions recorded with the caller as the actor (the person the agent acted for), so nobody lists or reverts another person's agent's changes, whoever may read the records.
44
+
45
+ **Listing** (`versioning.agentEdits`): the records of entities with history the group changed, with the versions it made, and the documents it changed, among those the caller may read now (each record by its read policy, as `versioning.history`; documents as `collab.history`).
46
+
47
+ **Reverting a record** is the module's own action, as restoring is, so its policy decides who may revert:
48
+
49
+ ```ts
50
+ export const revert = defineAction({
51
+ name: "journal.revert",
52
+ input: Schema.Struct({ id: Schema.String, ...AgentEditGroup.fields }),
53
+ output: RecordRevertResult,
54
+ writes: "entry", // no target: a revert may delete what the agent created, or bring back what it deleted
55
+ })
56
+ // handler
57
+ revert: (input, ctx) => ctx.history.revert("entry", input.id, { conversationId: input.conversationId, messageId: input.messageId }),
58
+ ```
59
+
60
+ `ctx.history.revert(entity, id, group)` first takes the locks every writer of the record's collaborative document takes, in their order (the search lock shared, then the record's own advisory lock), then locks the record's row (`FOR UPDATE`); all are held until the call ends, so nobody changes the record or its document between the decision and the write. It then reads its versions through the platform read function `eloxiv_platform.record_agent_versions` (the acting module's entities only, in the caller's organisation, for a Cedar type of the acting module's namespace, which the invocation path records), checks the record's **read policy** for the caller (on the record as it stands, or as last recorded once deleted: not row-level security, which also admits what the action may change), and writes on the handler's connection as the handler's role, so the action's policy and row-level security decide the write like any other; nothing written is a refusal (`Forbidden`). What it does:
61
+
62
+ - **Fields.** What the group changed is found version by version, each against the one before it, so a change someone else made between two of the group's is never taken for the group's. A field the group changed goes back to its value before the group's last run of changes to it, **unless someone changed it since**: then it keeps the later value and is listed in `kept`. A run of changes stops at someone else's delete or re-creation of the record (a restore): a field never goes back across it. A field already back (an earlier revert) is left alone, so a second revert writes nothing. Fields the group did not change are never touched.
63
+ - **Earlier reverts of the same chat.** A version a revert made records the group it reverted (`revert_conversation_id`, `revert_message_id`). The caller's revert of a group, or of one of its messages when the group is the whole chat, counts as the group's own undoing, never as someone's later change: reverting message 2 and then the whole chat goes on from what message 2's revert left.
64
+ - **A record the group created** (its first change was the `insert`) is deleted, unless anyone changed it since: the record, or its collaborative document (any update the group's runs did not make, other than reverts of the group; then `kept`). Only an insert proves it: a record whose recorded history starts with the group's update (created outside actions, by a migration or a seed) is refused (`InvalidInput`), since nothing shows what it was before. This delete is the one an action without a target may make: the kernel accepts exactly the write-log entry the revert's own DELETE made (read back through `eloxiv_platform.revert_delete_write`, which answers only for the caller's own transaction), in that attempt of the call (a run again after a conflict starts with none); a savepoint rolled back takes the entry with it, so nothing is left to excuse another delete. The action's policy still governs it.
65
+ - **A record the group deleted** is brought back as the delete found it, its fields the group changed back as they were, unless it was created again since (`kept`).
66
+
67
+ The result is `{ id, outcome, kept }`: `reverted`, `unchanged` (nothing of the group's left to undo, or the group never changed the record), or `kept` (nothing written: everything the group changed was changed again since). A revert is recorded as a new version, by the caller, with the action.
68
+
69
+ The client SDK's `agentEdits` controller ([ClientSDK](client-sdk.md#collaboration-sharing-and-history-controllers)) lists a group and reverts it item by item: documents through `collab.revert`, records through the module actions the app passes per entity.
70
+
71
+ ## Operations
72
+
73
+ | Operation | Action | Input | Output |
74
+ | --- | --- | --- | --- |
75
+ | `modules` | `versioning.modules` (read-only) | `{}` | `{ kernelVersion, modules: [{ module, version, kernelRange, installedAt, updatedAt }], history: [{ module, fromVersion, toVersion, kernelVersion, at }] }` |
76
+ | `history` | `versioning.history` (read-only) | `{ entity: "<module>.<entity>", id }` | `{ entity, id, exists, versions: RecordVersion[] }` oldest first |
77
+ | `version` | `versioning.version` (read-only) | `{ entity, id, version }` | one `RecordVersion` |
78
+ | `restore` | in process, `ctx.history.restore` in a module action | `{ entity, id, version }` | the id |
79
+ | `agentEdits` | `versioning.agentEdits` (read-only) | `{ conversationId, messageId? }` | `{ conversationId, messageId, records: [{ entity, id, versions }], documents: [{ entity, id, runs }] }` |
80
+ | `revert` | in process, `ctx.history.revert` in a module action | `{ entity, id, conversationId, messageId? }` | `{ id, outcome: "reverted" \| "unchanged" \| "kept", kept: [field] }` |
81
+
82
+ `RecordVersion`: `{ version, op, snapshot, actorUserId, action, invocationId, at, agent? }`; the snapshot holds the table's columns; `agent` (`{ runId, conversationId, messageId }`) is the agent edit group of a version an agent run made.
83
+
84
+ ## How an implementation is checked
85
+
86
+ `versioningConformance(start)` takes a `ServicesSubject` (see [Progress](progress.md#how-an-implementation-is-checked)); `journal.entry` keeps history and `journal.restore` restores. The kit checks: installed versions, ranges and the install recorded; setup refusing an excluding range and a downgrade with nothing changed, and an unreadable range refused at startup; insert, updates and delete recorded on every surface with the actor, action and the audit record's invocation id, refused calls recording nothing; history visible exactly as the read policy admits the latest state (organisation members, the author once private, nobody in another organisation, nothing for missing records or other modules' entities); no module role able to read, insert or delete history; restore through the module's action, refused by its policy for others, recorded as a version, bringing back a deleted record; an upgrade recorded with its previous version. The Eloxiv kernel runs it in [`packages/testing/test/versioning.test.ts`](../../packages/testing/test/versioning.test.ts). Agent edit groups are proven against a real agent run (the scripted model) in [`packages/testing/test/agent-revert.test.ts`](../../packages/testing/test/agent-revert.test.ts): a run's versions and autosave kept with its run, conversation and message and listed by message or conversation; one message's run reverted in a record and a document with a person's later edits to both kept; a whole chat reverted through the client SDK, a record the agent created deleted; a person who may no longer edit refused, and another person's agent's edits never theirs to revert.
87
+
88
+ ## Not yet guaranteed
89
+
90
+ - **Writes outside actions are not versioned**: subscribers' writes and migrations change records without a history entry; the latest version is then not the current row.
91
+ - **A module's own code can read its own entities' history** in the organisation it acts in, through `eloxiv_platform.record_version`, whatever its caller may read: the read policy holds for callers (people, agents, other modules) on every action, not against the module's own handlers, which are trusted app code. A sandboxed (MAKE) module will need the function closed to it.
92
+ - **Downgrades** are refused, except a MAKE module's rollback through `make.rollback` (an administrator's audited action; MAKE's migrations are additive, so the older code runs over the same schema). Built-in modules have no downgrade path.
93
+ - **Retention**: history grows without bound, except for privacy erasure, which purges every version about the person (deleted records' included) of every entity whose declaration does not retain its records, and replaces their id as the actor of the rest.
94
+ - **Agent edit groups cover records with history and collaborative documents.** An agent's change to an entity without `history: true` is audited but not revertible. Runs queued before kernel migration `0185` have no group.
95
+ - **Device turns** (a run on one of the person's paired devices, whose harness calls tools through the daemon's relay with the turn's agent session) carry no edit group: their changes are audited, with the device in the call's authority, but not listed or reverted with the run. Carrying it needs the turn's credential resolved to its run when the relayed call is authenticated.
96
+ - **A field the group changed twice with someone's change in between** goes back to that person's value (the value before the group's last run of changes to it), not to the value before the group's first change.
97
+ - **Out-of-order Yjs updates**: an update that integrates another client's pending changes (structs that arrived earlier and waited for a missing dependency) may claim them for its own group, so a revert of that group can undo them too.
98
+ - **A revert is per record, not one transaction across a group**: the client SDK reverts each record and document with its own call, so a refused item (the person may no longer change it) leaves the others reverted, and the outcome lists each.
99
+ - **A shared conversation's** group is per person: someone replying in a conversation shared with them reverts only what their own runs changed.
@@ -0,0 +1,65 @@
1
+ # View
2
+
3
+ The views modules declare in their manifests, registered across every installed module, resolved from a shell route, and addressed by deep links. A view is data: the module names its title, its route and what it shows; a registry UI item renders it. No UI code is in the contract.
4
+
5
+ - Kind: shell contract. Version 1.0.0.
6
+ - Schema: [`packages/contracts/schema/contracts/View.json`](../../packages/contracts/schema/contracts/View.json) (source [`View.ts`](../../packages/contracts/src/contracts/View.ts)). Views are declared with the module manifest's `views` ([ModuleManifest](module-manifest.md)).
7
+ - Implementation: `shellRegistry(modules, { origin, scheme })` in `@eloxiv/shell-core` ([`Navigation.ts`](../../packages/shell-core/src/Navigation.ts)), which also implements [Slot](slot.md) and [Command](command.md).
8
+ - Kit: `@eloxiv/testing/conformance/View` ([source](../../packages/testing/src/conformance/View.ts)).
9
+
10
+ ```ts
11
+ import { shellRegistry } from "@eloxiv/shell-core"
12
+ import { contracts } from "./eloxiv.modules.ts"
13
+
14
+ const shell = shellRegistry(contracts, { origin: "https://app.example.com", scheme: "example" })
15
+ shell.resolve("/hello/abc?org=acme") // { view: <hello.greetings>, record: "abc", org: "acme", params: {} }
16
+ shell.link({ view: "hello.greetings", record: "abc" }).url // "https://app.example.com/hello/abc"
17
+ shell.parseLink("example://open/hello/abc") // { view: "hello.greetings", record: "abc" }
18
+ ```
19
+
20
+ ## Operations
21
+
22
+ | Operation | Input | Output | What it does |
23
+ | --- | --- | --- | --- |
24
+ | `list` | `{}` | `ViewDescriptor[]` | Every view of every installed module, in module installation order, then by id |
25
+ | `get` | `{ view }` | `ViewDescriptor` | One view; `UnknownView` if no module declares it |
26
+ | `resolve` | `{ path }` | `RouteMatch` | The view a shell path opens: the longest route equal to the path, or followed by exactly one more segment (the record, percent-decoded). `org` and the other query parameters come back apart (for a repeated key, the first wins); a fragment is ignored. `UnknownView` otherwise |
27
+ | `link` | `DeepLink` | `{ path, url }` | Writes a link: `<route>[/<record>][?org=<org>&<params sorted>]`, and its absolute URL on the app's origin, else `<scheme>://open<path>` |
28
+ | `parseLink` | `{ url }` | `DeepLink` | Reads a link back: a shell path, a URL on the app's origin, or a URL in its scheme (host `open`). `InvalidLink` otherwise |
29
+
30
+ ## Records
31
+
32
+ - **`ViewDescriptor`**: `id` (namespaced by its module, `hello.greetings`), `module`, `title`, `description?`, `route` (unique across the app, `/hello`), `shows` (`{ entity }` or `{ queryView }`).
33
+ - **`DeepLink`**: `view`, `record?`, `org?`, `params?` (string to string).
34
+ - **`RouteMatch`**: `view` (the descriptor), `record?`, `org?`, `params`.
35
+ - **`WrittenLink`**: `path`, `url`.
36
+ - **Errors**: `UnknownView { view }`; `InvalidLink { url, reason }` with `reason` `foreign-origin`, `scheme`, `malformed` or `unknown-view`.
37
+
38
+ ## Guarantees
39
+
40
+ 1. **One registry.** Ids and routes are unique across the installed modules (the manifest check refuses duplicates at startup; the implementation refuses to build over them), so one route never resolves two ways.
41
+ 2. **Longest route wins.** `/atlas/archive` opens the view at that route even though `/atlas/<record>` would also match.
42
+ 3. **Links round-trip.** For every view, record (except `.` and `..`, which URLs resolve away), organisation and parameter set, `parseLink(link(x).url)`, `parseLink(link(x).path)` and the same through the scheme give back `x`. A record whose segment would spell another view's route has its first character percent-encoded, so it still names the record.
43
+ 4. **Only the app's own links.** A URL on any other origin (another host, `http` for an `https` app, a look-alike suffix), any other scheme (`javascript:`, `data:`, another app's), a scheme URL whose host is not `open`, and a path that is not a shell path (`//host/...`) are refused.
44
+ 5. **A link only navigates.** It carries a view, a record, an organisation and plain string parameters; nothing in it runs an action (an `action=` parameter is just a parameter).
45
+
46
+ ## How an implementation is checked
47
+
48
+ `viewConformance(make)` builds the implementation over the shell fixture ([`atlas/contract.ts`](../../packages/testing/src/conformance/atlas/contract.ts): `atlas` with `/atlas`, `/atlas/archive` and `/atlas/cards`, and `almanac`) and checks the order and contents of `list`, `get`'s error, resolution (longest route, records, percent-decoding, trailing slashes, fragments, repeated `org`, malformed paths), written links, the round trip as a property over 300 generated links, refused origins and schemes, and that a link carries nothing to run. The Eloxiv implementation runs it in [`shell-navigation.test.ts`](../../packages/testing/test/shell-navigation.test.ts).
49
+
50
+ ## Navigation conveniences
51
+
52
+ `@eloxiv/shell-core` adds two helpers over the registry ([`Redirects.ts`](../../packages/shell-core/src/Redirects.ts)): `redirectingShell(shell, redirects)` resolves an app's legacy paths where they live now (`{ from: "/settings/*", to: "/preferences/*" }` carries the rest of the path over; the query is kept; at most five hops; a loop, or a redirect to anything but a shell path, is refused; a requested path, and every path a redirect expands it to, must stay a shell path on the shell's own origin, as written and once percent-decoded: `/legacy/*` to `/*` never turns `/legacy//host`, `/legacy/%2F%2Fhost` or `/legacy/\host` into `//host`, and `redirected` answers undefined for them), and `recordLink(shell, { module, entity, id }, { view?, org? })` writes the link that opens a record in a view that shows its entity (the one named, else the first in the registry's order), or nothing when no installed view shows it. Tested in [`screen-commands.test.ts`](../../packages/testing/test/screen-commands.test.ts).
53
+
54
+ ## The error view
55
+
56
+ `viewError(error, { development?, home? })` classes any failure a screen meets (an action's typed error, a request's, a route no view serves, a renderer that threw) as `not-found`, `signed-out`, `forbidden`, `outdated`, `offline` or `failed`, with its status, catalogue keys to word it (`error.<kind>.title`, `error.<kind>.body`), whether trying again can help, the home link, the stack only in development, and a `report` for a reporting action that holds the kind, status and tag only (never a message or stack). `guardView(render, fallback)` runs a screen's renderer and gives its error view when it throws ([`ViewError.ts`](../../packages/shell-core/src/ViewError.ts), [`view-error.test.ts`](../../packages/testing/test/view-error.test.ts)).
57
+
58
+ ## In the reference shell
59
+
60
+ `shell-foldkit` 0.5.0 routes legacy paths where they live now and replaces the address (`/home` is the home, `/settings/<section>` the settings, `/agent` the conversation screen and `/access-requests/<id>` the inbox when those screens are installed, after the app's own `redirects`), and draws every screen through `guardView`, so a screen that throws shows the error view for its kind, in the person's language, with a home link, a retry where that can help and the stack only in a development build. A link that names an organisation (`?org=<id>`, as MCP's record links do) opens in it when the person belongs to it, switching to it first if another is chosen; one they do not belong to is ignored. Tested in [`shell-foldkit-lifecycle.test.ts`](../../registry/test/shell-foldkit-lifecycle.test.ts).
61
+
62
+ ## Not yet guaranteed
63
+
64
+ - **Views are not filtered by policy.** The registry lists every installed view; what a view's rows show is filtered by sync and policy, and which views a person is offered is the [Space](space.md) contract's.
65
+ - **No route parameters** beyond one record segment (`/mail/:folder/:id` is not a route form).
@@ -0,0 +1,99 @@
1
+ # WorkItems
2
+
3
+ The unified inbox (decision 3): the cross-module list of things that need someone. A work item has a source (a module and one of its records), a state, an assignee (a member or a group) and a link back to the record. Every module feeds work items the same way; each person's replica holds the items assigned to them or to their groups. The inbox screens are a registry module of the home space; this contract is headless.
4
+
5
+ - Kind: kernel service. Version 1.0.0.
6
+ - Schema: [`packages/contracts/schema/contracts/WorkItems.json`](../../packages/contracts/schema/contracts/WorkItems.json) (source [`WorkItems.ts`](../../packages/contracts/src/contracts/WorkItems.ts)).
7
+ - Implementation: the API in [`packages/kernel/src/WorkItems.ts`](../../packages/kernel/src/WorkItems.ts); the kernel-provided `inbox` module ([`inbox/workItems.ts`](../../packages/kernel/src/inbox/workItems.ts), schema `eloxiv_inbox`); the sync tables and queries in `@eloxiv/client/sync` ([`InboxSync.ts`](../../packages/client/src/InboxSync.ts)).
8
+ - Kit: `@eloxiv/testing/conformance/WorkItems` ([source](../../packages/testing/src/conformance/WorkItems.ts)), run by [`packages/testing/test/work-items.test.ts`](../../packages/testing/test/work-items.test.ts); replicas through zero-cache in [`inbox-sync.test.ts`](../../packages/testing/test/inbox-sync.test.ts).
9
+
10
+ ## Feeding the inbox
11
+
12
+ A module declares its work-item sources in its manifest ([ModuleManifest](module-manifest.md) `workItemSources`: the entity, the title field, how its states map to inbox states, the link view), then puts items from its handlers and subscribers:
13
+
14
+ ```ts
15
+ handlers: {
16
+ placeOrder: (input, ctx) =>
17
+ Effect.gen(function* () {
18
+ // ... insert the order ...
19
+ yield* ctx.workItems.put({
20
+ source: "purchases.reviews", // a source this module declares
21
+ sourceId: id, // the record
22
+ title: `Review ${input.item}`,
23
+ state: "placed", // an inbox state, or one the source maps
24
+ assignee: { group: "buyers" }, // or { user: userId }
25
+ dueAt: null,
26
+ })
27
+ return { id }
28
+ }),
29
+ markReviewed: (input, ctx) =>
30
+ ctx.workItems.close({ source: "purchases.reviews", sourceId: input.id, state: "done" }).pipe(Effect.as(input)),
31
+ }
32
+ ```
33
+
34
+ Subscribers get the same `ctx.workItems` (for the event's organisation). The kernel applies what the handler asked for **after** the handler's own writes are checked, in the same transaction, so a rolled-back call leaves no item; a subscriber's items commit with its delivery. Kernel features (approvals, consent) feed the inbox through the same API, from their own modules' sources.
35
+
36
+ ## Operations
37
+
38
+ | Operation | Input | Output | Errors |
39
+ | --- | --- | --- | --- |
40
+ | `put` | `WorkItemPut`: `source`, `sourceId`, `title`, optional `state`, `assignee`, optional `dueAt`, optional `key` | `id` | `InvalidWorkItem` |
41
+ | `close` | `WorkItemClose`: `source`, `sourceId`, `state` (`done`, `dismissed`), optional `key` | `closed` (count) | `InvalidWorkItem` |
42
+ | `retitle` (in process, `ctx.workItems.retitle`) | `source`, `sourceId`, `title`, `generation`: every item of the record, whatever its state (closed ones too), takes the title. A title copies record text, so a module calls it whenever that text changes or goes; the kernel clears the titles of a deleted or tombstoned record's items itself, and keeps a live record's items titled when the module words the source's titles in the kernel (`defineModule({ workItemTitles: { [source]: (value) => title } })`, from the source's title field): after every call's writes and on every setup ([Search](search.md#derived-copies-and-how-each-goes)) | nothing | `InvalidWorkItem` |
43
+ | `basis` (in process, `ctx.workItems.basis`) | `source`, `sourceId`: the source record's generation, under the record's lock (held to the end of the call). A module's `put` and `retitle` state the generation their title was prepared from (taken after the module's own write of the record) and are skipped, never applied, if the record has changed since; a subscriber states the generation its event carries | the generation | none |
44
+ | `claim` | action `inbox.claim`: `id` | `id`, `state` | the standard error set |
45
+ | `complete` | action `inbox.complete`: `id` | `id`, `state` | the standard error set |
46
+ | `dismiss` | action `inbox.dismiss`: `id` | `id`, `state` | the standard error set |
47
+ | `reassign` | action `inbox.reassign`: `id`, `assignee` | `id`, `state` | the standard error set |
48
+
49
+ In a call, `put`, `retitle` and `basis` act on the caller's behalf and require the call's assertion ([Invocation, "Authority"](invocation.md#authority)); `basis` takes the record's lock after the call's authority links (the one lock order). A subscriber's `ctx.workItems` acts as the organisation's system actor, which carries no chain.
50
+
51
+ `put` and `close` are the module API (`ctx.workItems`, and the `WorkItems` kernel service). A `put` is refused (`InvalidWorkItem`; from a handler the call fails with `ActionFailed` and rolls back) when the source is not one the calling module declares, the state is neither an inbox state nor one the source maps, or the assignee is not a member or group of the organisation. An item is identified by (organisation, source, source id, key); the key defaults to the assignee (`user:<id>`, `group:<id>`), so one record can have one item per assignee, and putting it again updates it. `close` closes the record's open items (or only the one with `key`).
52
+
53
+ `claim`, `complete`, `dismiss` and `reassign` are actions of the kernel-provided `inbox` module, on every surface, authorised by its policy and audited:
54
+
55
+ - `claim`: an open item assigned to you or to one of your groups becomes `in_progress`, assigned to you alone;
56
+ - `complete` / `dismiss`: an item assigned to you or your group becomes `done` / `dismissed` (an already closed item is `InvalidInput`);
57
+ - `reassign`: an item assigned to you or your group (or any item, with the `inbox.manage` permission) goes to another member or group of the organisation (`InvalidInput` otherwise); it reopens, and records who assigned it. The authority comes from the item as it stands only: having assigned an item grants nothing afterwards, so a former assignee cannot take it back or pass it on. The policy says so with `context.row` (see [DbTx](db-tx.md)): its `"old"` rule requires the current assignment or `inbox.manage`, its `"new"` rule requires the item left behind to name the caller as who assigned it.
58
+
59
+ ## Records
60
+
61
+ - **`WorkItem`**: `id`, `orgId`, `module`, `source`, `sourceId`, `state` (`open`, `in_progress`, `waiting`, `done`, `dismissed`), `sourceState` (the module's own value when the source maps states), `assigneeUserId` or `assigneeGroupId` (exactly one), `title`, `link` (`EntityReference`: module, entity, id), `view` (the source's link view), `dueAt`, `claimedBy`, `createdAt`, `updatedAt`, `closedAt`.
62
+ - **`WorkItemAssignee`**: `{ user }` or `{ group }`. **`EntityReference`**: `{ module, entity, id }`.
63
+
64
+ ## Sync
65
+
66
+ Apps that install the inbox modules add the kernel's inbox sync tables and queries to their sync schema:
67
+
68
+ ```ts
69
+ import { createSchema, defineQueries } from "@eloxiv/client"
70
+ import { inboxQueries, inboxRelationships, inboxTables, shareGrant } from "@eloxiv/client/sync"
71
+
72
+ const schema = createSchema({ tables: [shareGrant, ...moduleTables, ...inboxTables], relationships: [...inboxRelationships] })
73
+ const queries = defineQueries({ ...moduleQueries, ...inboxQueries })
74
+ ```
75
+
76
+ The tables are generated from the inbox modules' Drizzle tables (`KernelTables.gen.ts` in `@eloxiv/client`). The queries are `inbox.items` (open items), `inbox.all`, `notifications.mine` and `approvals.requests`; the kernel infers each one's entity from the table it reads and filters it by the `inbox` module's read policy:
77
+
78
+ ```cedar
79
+ permit (principal, action == Inbox::Action::"read", resource is Inbox::WorkItem)
80
+ when { resource.org == principal.org && (resource.assignee == principal || principal in resource.assigneeGroup) };
81
+ ```
82
+
83
+ `principal in resource.assigneeGroup` compiles (decision 2) to a live test against the replicated directory facts for sync (`eloxiv.sync_fact` holds the group for the actor in the acting organisation, see [Sync](sync.md)) and to `eloxiv_ctx.in_group(assignee_group_id)` for row-level security, both from the live directory, so a change of group membership reaches a connected replica without reconnecting. A person's replica therefore holds exactly the items assigned to them or to a group they belong to, in the organisation they act in; a group of the same id in another organisation does not count.
84
+
85
+ ## Guarantees
86
+
87
+ 1. Modules feed items only through the API, for their own declared sources, in the transaction of the change.
88
+ 2. Each person syncs exactly the items assigned to them or to their groups, in the organisation they act in.
89
+ 3. Claim, complete, dismiss and reassign are authorised by the policy (refused as `Forbidden` otherwise, on every surface) and audited.
90
+
91
+ ## How an implementation is checked
92
+
93
+ `workItemsConformance(start)` registers, against the inbox conformance app: a handler puts items for a member and a group, linked to the record and its view, with the source's mapped state; an assignee outside the organisation fails the call and rolls it back; the sync endpoint's scoped query holds exactly each person's own and group items (not a non-member's, not another organisation's same-named group, and another organisation's sync is refused); claim by a group member (others refused, the claim is audited, then only the claimer sees and completes it); dismiss by the assignee only; reassign (refused for others and for assignees outside the organisation; the new assignee sees it, the old one no longer; a former assignee cannot reassign or complete it, while the new assignee can pass it on); the module closes its items through the API.
94
+
95
+ ## Not yet guaranteed
96
+
97
+ - Group-assigned items stay in progress only for the claimer; there is no "unclaim".
98
+ - Live replicas are not re-filtered when someone joins or leaves a group until they resync (see [Sync](sync.md)).
99
+ - The kernel does not read a source's records to fill items (state and assignee fields of the declaration are documentation for the inbox screens); modules pass them in `put`. The title field is read only to keep a live record's titles in step, and only for a source the module words in the kernel (`workItemTitles`); items are still put by the module.
@@ -0,0 +1,82 @@
1
+ # Workflow
2
+
3
+ Durable execution for jobs, approvals and durable agent runs: resumable, fenced, journalled steps.
4
+
5
+ - Kind: kernel service. Version 1.3.0 (1.1.0: an execution identity carries the provenance of the call that asked for the work, its origin, agent session and credential scope, checked again when it runs; 1.2.0: a person's own session is a link of the authority, held and unexpired, and never recorded for deferred work; 1.3.0: the system actor's identity carries the `scope` it was narrowed to, as a person's does).
6
+ - Schema: [`packages/contracts/schema/contracts/Workflow.json`](../../packages/contracts/schema/contracts/Workflow.json) (source: [`packages/contracts/src/contracts/Workflow.ts`](../../packages/contracts/src/contracts/Workflow.ts))
7
+ - Kernel implementation: [`packages/kernel/src/Workflows.ts`](../../packages/kernel/src/Workflows.ts) on Effect cluster's workflow engine ([`durable/Cluster.ts`](../../packages/kernel/src/durable/Cluster.ts))
8
+ - Conformance kit: [`packages/testing/src/conformance/Workflow.ts`](../../packages/testing/src/conformance/Workflow.ts), run by [`packages/testing/test/workflow.test.ts`](../../packages/testing/test/workflow.test.ts)
9
+ - Restart proofs: [`packages/testing/test/durable-restart.test.ts`](../../packages/testing/test/durable-restart.test.ts)
10
+
11
+ ## Defining a workflow
12
+
13
+ A module (or the app, through `KernelApp.workflows`) defines workflows with `defineWorkflow` and lists them in `defineModule({ workflows })`:
14
+
15
+ ```ts
16
+ import { defineModule, defineWorkflow } from "@eloxiv/kernel"
17
+ import { Effect, Schema } from "effect"
18
+
19
+ export const monthlyClose = defineWorkflow({
20
+ name: "billing.monthly-close",
21
+ input: Schema.Struct({ month: Schema.String }),
22
+ output: Schema.Struct({ approved: Schema.Boolean }),
23
+ run: (input, ctx) =>
24
+ Effect.gen(function* () {
25
+ yield* ctx.invoke("draft", { action: "billing.draftClose", input: { month: input.month } })
26
+ const decision = yield* ctx.waitForSignal("decision", Schema.Struct({ approved: Schema.Boolean }))
27
+ if (decision.approved) yield* ctx.invoke("post", { action: "billing.postClose", input: { month: input.month } })
28
+ return decision
29
+ }),
30
+ })
31
+ ```
32
+
33
+ Workflow names are unique across the app (the kernel refuses to start otherwise): an execution is identified by (workflow, key).
34
+
35
+ `schedulable: true` lets members start the workflow from runtime schedules (see [Scheduler](scheduler.md)); it is off by default.
36
+
37
+ What the body can do, through its context:
38
+
39
+ | Method | Behaviour |
40
+ | --- | --- |
41
+ | `invoke(step, { action, input, surface? })` (surface `workflow`, `scheduler` or `ingress`) | Invokes an action through the one invocation path (identity, policy, approval, idempotency, audit, outbox) as the execution's identity, with the idempotency key `<execution id>:<step>`. Returns `{ invocationId, replayed, result }`, where `result` is the action's envelope: `{ kind: "output", output }` or, when the step had already run the action, `{ kind: "replay", receipt }` |
42
+ | `step(name, schema, body)` | Runs `body(key)` once as a journalled step and returns its result (encoded with `schema`). Use it for effects outside the database, made idempotent on `key`. The result is encoded as JSON before the step is recorded as succeeded: one that cannot be (a `Date` where the schema says `Unknown`) fails the step with `WorkflowFailed`, naming the step and where the value is not JSON |
43
+ | `sleep(name, duration)` | Waits durably: the execution suspends, and a timer stored in the database resumes it, also after a restart |
44
+ | `waitForSignal(name, schema)` | Suspends until the named signal is sent, then continues with its value. A signal sent before the execution reaches the wait is kept |
45
+ | `ingress` | An Ingress handler's only (absent elsewhere): `reply(step, { text })` in the delivery's own conversation, and `agentAnswer(step, { runId, timeoutMs })`, a bounded, durable wait for one of the sender's agent runs ([Ingress, "Replying"](ingress.md#replying-in-the-deliverys-conversation)) |
46
+ | `noop(reason, evidence?)` | Declares that the execution did nothing on purpose (no work found, a condition that does not hold): when the body then returns, the execution ends a no-op (`status` carries `noop: { reason, evidence }`; a scheduled run's history says `noop`), not a plain success. Recorded at once, the same on every replay; keep the reason free of a person's data |
47
+ | `each(name, operations, schema, body)` | One journalled step per operation (unique ids), in order: the operations are journalled first (`<name>/plan`), so a resumed execution works through the same N; a completed operation returns its journalled result, the first unfinished one runs again with the same key (`<execution id>:<name>/<index>`). Returns `{ total, completed, results }` only when every operation completed (`completed === total`, the terminal proof); an operation that fails fails the batch, leaving those before it completed |
48
+
49
+ **Kernel workflows are the kernel's alone.** The kernel's own workflows (`eloxiv.approval`, `eloxiv.approval-expiry`, `eloxiv.ingress`: see [Approvals](approvals.md) and [Ingress](ingress.md)) are the only ones whose bodies run with the kernel's services and whose `invoke` may act as another identity or pass `approval` (the approved request a call executes). Trust belongs to the definition object, recorded in a closure-private set in `packages/kernel/src/durable/Trust.ts` when the kernel defines one; that file is not exported from `@eloxiv/kernel`, the package exposes no path to it, and a fallow boundary (`kernel-trust`) refuses an import of it from any other package. Module and app workflows run with none of the kernel's services (their body and their `step` bodies see only the engine's per-execution services and Effect's references: no database connection, no `Invocation`, no `Workflows`, no file system), so a module that casts its way to a service finds none; a step that asks for another identity is refused (`Forbidden`), and an `approval` it passes is ignored (the call goes through the approval stage like any other). A module workflow that ingress runs as a source's handler gets the same module context, acting as the delivery's actor. The kernel refuses to start an app whose own or modules' workflows are named in the kernel's namespace (`eloxiv.*`).
50
+
51
+ The body is replayed from the start whenever the execution resumes. Completed steps return their journalled result without running; the first unfinished one runs. Keep everything that is not a step deterministic (no clocks, random ids or reads outside steps), and give every step a unique name within the workflow.
52
+
53
+ ## Operations
54
+
55
+ | Operation | Input | Output | Errors |
56
+ | --- | --- | --- | --- |
57
+ | `start` | `workflow`, `key`, `identity`, `input` (JSON) | `executionId`, `started` | `UnknownWorkflow`, `InvalidInput` |
58
+ | `status` | `executionId` | `ExecutionStatus`: `running`, `suspended`, `succeeded` (with `output`), `failed` (with `error`: tag and message) or `cancelled` | `UnknownExecution` |
59
+ | `signal` | `executionId`, `signal`, `value` (JSON) | `delivered` | `UnknownExecution` |
60
+ | `cancel` | `executionId` | nothing | `UnknownExecution` |
61
+ | `journal` | `executionId` | `steps`: each step's `attempts`, `state`, `invocationId` and `replayed` | `UnknownExecution` |
62
+
63
+ In the kernel these are the methods of the `Workflows` service. They are internal: no surface exposes them, because who may start or signal what is a business rule. Business approvals, for example, will be actions that signal the execution waiting on them.
64
+
65
+ ## Guarantees
66
+
67
+ - **Identified.** An execution's id is derived from (workflow, key). Starting the same key again joins the existing execution (`started: false`) and never starts a second one; its input is the first start's.
68
+ - **Acts as one identity.** An execution carries an `ExecutionIdentity`: a user in an organisation (with, for work deferred on someone's behalf, the call's provenance: `agentSession` for an agent's work, `origin: "person"` for a person's own call an approval executes, `scope`, the scope of the credential it was asked with, which narrows every step's call, and `authority`, the chain of authorities it was asked under (the credential, agent session, device, linked identity, consent), asserted inside every step's call ([Invocation](invocation.md#authority)): once any link no longer holds, the calls are refused; a person identity that names no chain, or `unrecorded`, is refused, so trusted server code starting work in a person's name with no revocable link says `authority: { scope: null, chain: [] }`), or the organisation's system actor (`$system`, the identity outbox subscribers use; policies grant it explicitly), with the `scope` its work was narrowed to (an agent run limited to some tools acts within the actions they are, and work it defers keeps that scope). It is resolved again at every step: a user who has left the organisation is refused (`Forbidden`, audited), never acted for with stale rights. The invocation path is not bypassed: policy, approval, idempotency, audit and the outbox all run, and the audit record's surface is `workflow` (or `scheduler` for scheduled runs).
69
+ - **Stated limit: a run's tool limit and the work its events start.** A run's tool limit governs what the run itself calls. Automations and event triggers that react to its events run with their own owner's authority.
70
+ - **Journalled.** Every step's result is stored before the next step runs. Effect cluster's activity replies (in `eloxiv_cluster`) are the authoritative record; the kernel also keeps `eloxiv.workflow_step` (attempts, invocation, replay) for `journal`.
71
+ - **Resumes after the process dies.** Executions, timers and signals live in PostgreSQL. A kernel that starts on the database resumes every unfinished execution of the shards it takes. A step cut off by the crash runs again: an action step gets the replay receipt (the action does not run twice), and a `step` body runs again with the same `key`, so external effects must be idempotent on it.
72
+ - **Fenced.** Each execution belongs to one of 32 shards, and a kernel runs a shard's executions only while it holds that shard's PostgreSQL advisory lock, on a session of its own. Two kernels on one database therefore never run the same execution at once. When a kernel dies its session ends and its locks are released: the same kernel restarted (same runner address) takes them back at once; another kernel takes them once the dead kernel's registration expires (`ELOXIV_SHARD_LOCK_EXPIRATION_MS`, default 35 s).
73
+ - **Signals.** The first value sent for a signal name is the signal's value; later sends return `delivered: false` and change nothing. A retried send after a crash completes the signal with the first value.
74
+ - **Failure.** An action error in a step (for example `Forbidden`) fails the execution with that error unless the body handles it; the body may also fail with `WorkflowFailed`. Defects (a lost connection) are retried inside the step a few times before it fails. A step's result that cannot be journalled as JSON fails that step, visibly (journal `failed`, the execution's error naming it); for an action step the action has run, and the failure (`ActionFailed`) names its invocation. The workflow's output is encoded the same way.
75
+ - **Ends are recorded.** An execution records how it ended on its row (`eloxiv.workflow_execution.state`: `succeeded`, `noop`, `failed` with the failure's tag, `cancelled`) before the engine stores its result; the Scheduler's run history and failure streaks read it.
76
+ - **Owned records reach a terminal state.** A definition's `onFailure(input, { tag, message }, ctx)` runs when the execution fails (never on a suspension or a cancellation), before the failure is stored, and again if the process dies while it runs, so it must be idempotent. The kernel's own workflows use it: an agent run ends `failed` with its stream closed, a business approval records a failed execution and dismisses its approvers' items, an ingress delivery is settled `failed`.
77
+
78
+ ## Deployment
79
+
80
+ - Runner address: `ELOXIV_RUNNER_HOST` and `ELOXIV_RUNNER_PORT` (default: the host name and `ELOXIV_PORT`). It must be unique among live kernels on one database and the same across restarts of one kernel.
81
+ - Polling: `ELOXIV_DURABLE_POLL_MS` (default 1000) is how quickly a kernel notices messages another process stored for it (starts, signals and timers sent from elsewhere).
82
+ - Seeds and scripts (`runProgram`, `runPrepare`) are clients: they can start and signal executions, never run them.
@@ -0,0 +1,163 @@
1
+ # Eloxiv decisions
2
+
3
+ The settled architecture and stack. Agents building Eloxiv treat this file as fixed: propose a change to the user rather than making it. Evidence behind many entries is in [the agent-native feature ledger](research/agent-native-feature-ledger.md).
4
+
5
+ Last updated 2026-11-09.
6
+
7
+ ## What Eloxiv is
8
+
9
+ Eloxiv is a framework for building agent-native applications: apps whose modules expose their functionality to agents as fully as to people. It replaces agent-native (Builder.io) as the foundation the user builds on.
10
+
11
+ Every app built on Eloxiv is assumed to have organisations, more than one actor, and modules, so each app is OS-like. Its domain can be anything: an internal business tool or any other kind of application. Business modules such as People, Mail and Calendar are examples, not the product.
12
+
13
+ Eloxiv is three things:
14
+
15
+ 1. **Kernel:** a headless, versioned package that apps depend on and never copy. It has no product UI.
16
+ 2. **Registry:** modules, connectors, the web shell, a UI kit, spaces, themes and agent skills. They are installed shadcn-style into each app's repository and owned there, with provenance (version and hash) so updates can be diffed.
17
+ 3. **Apps:** one repository per app, assembled from the registry and extended locally.
18
+
19
+ UI is secondary. Registry UI items are optional templates that an app copies in and owns; nothing in the kernel imposes UI. Eloxiv is for building apps, not for shipping finished ones (decision 11).
20
+
21
+ T964 OS motivated Eloxiv and is one source of requirements in the feature ledger. Its code, its upgrade path and its workaround register are not part of Eloxiv's scope or definition of done.
22
+
23
+ ## Architecture
24
+
25
+ - **One runtime, modules not apps.** A module is a code, schema and ownership boundary inside a single process. Modules interact only through actions, events, entity references and capability contracts, never through each other's tables.
26
+ - **Module isolation is enforced by the database.** Each module owns a Postgres schema and a database role that cannot read or write other modules' schemas.
27
+ - **One action registry is the source of truth.** One definition produces the typed client, HTTP, MCP tools and agent tools. Every call, from any surface, goes through one invocation path: identity → policy → consent or business approval → idempotency → execute → audit → events via the outbox.
28
+ - **One agent over the whole registry.** No agent-to-agent protocol between modules. A2A is kept for external agents only, later.
29
+ - **Spaces** are curated entry points over several modules. The org defines them, roles grant them, and people personalise within them.
30
+ - **The home space** (the successor of Dispatch) holds the launcher, the unified inbox, the global agent and admin. Opening a module is a route change in one web shell (Tauri on desktop, browser on the web). No iframes, except sandboxed MAKE views.
31
+ - **Data:** the cloud is the source of truth. Each client keeps a policy-scoped partial replica with optimistic writes, so reads are local and navigation feels native. A device daemon is optional (offline use, local agents, coding tools).
32
+ - **Integrations have three layers:** a kernel Connection (one grant, merged scopes, custody, refresh, correct 401-versus-403 handling); kernel capability contracts with cursor-based delta sync, a standard error set, per-operation scopes, capability flags and a conformance kit; and connectors as registry code. MCP servers and a generic HTTP/OpenAPI connector cover everything else.
33
+ - **MAKE:** a module made by a user or the agent uses the same manifest as built-in modules, with a capability profile and a sandbox (QuickJS-WASM or wasmtime). It goes through draft → preview → approve → install → version → roll back.
34
+ - **Contracts are language-neutral** (JSON Schema). Rust is used only for leaf components that earn it, such as a wasmtime sandbox, a search index or native integration.
35
+
36
+ ### Settled 2026-11-02
37
+
38
+ 1. **Directory is minimal in the kernel.** The kernel owns actors, organisations, groups, memberships and roles. Employees, positions, reporting lines and companies belong to a registry People module.
39
+ 2. **Policy is declarative and compiled into SQL filters.** One policy both filters what syncs to each client and authorises each action. A code escape hatch exists, kept narrow and always audited. Cedar is the candidate. The skeleton must prove it can compile per-record sharing grants into SQL filters; if it cannot, Eloxiv defines its own small policy language.
40
+ 3. **The unified inbox is a kernel contract.** The kernel defines work items (source, state, assignee, link back to the record), and every module feeds them the same way. The inbox screens are a registry module in the home space. "Inbox" here means the cross-module list of things that need someone, not email.
41
+ 4. **Cross-module writes go through the outbox by default.** A module reacts to another's events, which are written in the same transaction as the change and delivered reliably with retries. Single-transaction composite actions are allowed only between modules that ship and install together. "Outbox" here means the transactional outbox pattern, not outgoing email.
42
+ 5. **Effect RPC vs oRPC and Zero vs Electric are settled by a spike, under a rule.** The building agent runs the spike in the walking skeleton and chooses **Effect RPC** and **Zero** unless they fail any of these checks: the typed client is projected from the action registry without hand-written glue; sync is policy-scoped and partial, driven by decision 2; it runs on both Bun and Node; it works inside Tauri. The agent records the evidence in `docs/spikes/` and proceeds without waiting.
43
+ 6. **The agent's SQL access is a policy-filtered, read-only query surface.** Modules publish read-only views; the agent queries only those, filtered by policy. Every write goes through actions.
44
+ 7. **Desktop: the daemon is kernel, the desktop host is registry.** The kernel provides a Host contract (deep links, push, secure storage, updates, file access), a storage adapter for the local replica (IndexedDB or OPFS on the web, SQLite on desktop and mobile), and the daemon package: pairing, relay, local agent runtimes on the person's own subscriptions (Codex, Claude Code and other harnesses), token custody, and a headless runner for always-on machines. The daemon ships as a sidecar binary built with Bun. The registry provides a Tauri desktop host template that the app owns and that runs the daemon as its sidecar.
45
+ 8. **Mobile: guarded, not built.** No mobile host in this build. CI proves the client SDK and sync run under React Native, and the Host contract covers push and secure storage, so a mobile host (Expo is the preferred candidate) can be added later without kernel changes. (Amended 2026-11-21 at the user's direction: the mobile host is built. The registry item `mobile` is an Expo/React Native host on the client core of decision 14, and the kernel delivers push to it through APNs and FCM; CI drives it on an Android emulator and attempts an iOS simulator build. The React Native guard stays.)
46
+
47
+ ### Settled 2026-11-04
48
+
49
+ 9. **One definition per module, sync behind Eloxiv's API.**
50
+ - **Drizzle is the source.** The Drizzle table is the only place a module declares its fields. Eloxiv's entity is a thin layer on top of it that references Drizzle column objects (not column-name strings) for policy attributes, the Cedar type and sharing. From those two, Eloxiv generates the Zero table, the app-wide typed sync schema (removing `Zero<any>`) and the entity's JSON Schema. Use drizzle-zero if it handles per-module schemas, column renames and the sharing relationship; otherwise Eloxiv writes the generator.
51
+ - **Action inputs and outputs stay separate Effect Schemas**, since they rarely match a table's shape. Contracts that cross boundaries (actions, events, MCP tools, published schemas) stay language-neutral JSON Schema.
52
+ - **Modules and registry UI reach sync only through `@eloxiv/client`.** The query builder, named queries and hooks such as `useQuery` are re-exported or wrapped there. Queries keep ZQL's shape; Eloxiv does not invent a new query language. A module's sync file holds only its named queries.
53
+ - **The kernel infers a query's entity from the table it reads.** Modules no longer declare `queryEntities`.
54
+
55
+ ### Settled 2026-11-09
56
+
57
+ 10. **Frontend: Foldkit, StyleX and Vite, proven before broad migration.** Recorded at the user's direction from a separate frontend discussion. It supersedes React 19, TanStack Router, shadcn/ui and Tailwind as the intended frontend in the Stack table, **subject to a representative integration proof**; until that proof passes, the direction is approved but not verified.
58
+ - **Rune (a Rust/GPU UI) is deferred.** No Rust UI, no Rust SDK, no replacement of the web frontend with Rune. (Amended by decision 14: Rune is the desktop client; the web frontend stays Foldkit.)
59
+ - **The default registry shell (web and desktop)** is built on Foldkit (TypeScript, Effect, The Elm Architecture: a Schema-defined Model, typed Messages, a pure update returning Commands, Subscriptions, resources, Submodels, routing), with Foldkit UI primitives and Eloxiv-owned higher-level components, StyleX for appearance, and Vite. Pin an exact Foldkit release compatible with Effect 4.1.x before implementation; it is pre-1.0. Keyboard, focus, accessibility, dark/light and RTL requirements carry over unchanged.
60
+ - **No extra state layers.** Foldkit's own form and validation approach is used. TanStack Query, Zustand, Effect Atom or similar are not added as defaults. Lucide icon designs may stay; React bindings are replaced. Non-React DOM libraries enter through Foldkit Mounts where justified. Foldkit can embed in other hosts (`Runtime.embed`, typed Ports), but Eloxiv does not keep two permanent frontend architectures without a concrete need.
61
+ - **Registry UI items stay optional and app-owned**, in the shadcn registry *format* (which needs neither React nor Tailwind), with provenance, versions, diff, update and eject.
62
+ - **Unchanged:** the UI-free kernel, contracts and shell-core, TypeScript and Effect on Bun and Node, PostgreSQL and Drizzle, Cedar, Better Auth, Effect RPC, HTTP and MCP, Zero, connectors, durable workflows, the AI SDK behind ModelProvider, the daemon, Tauri as the desktop host, Paraglide and Yjs (bindings adapted), and the repository tooling. Decision 9 holds: Foldkit Models hold interaction state (selection, drafts, loading and errors), never a second declaration of entity fields, and UI reaches sync only through `@eloxiv/client`.
63
+ - **Sync in the UI.** Zero keeps replication, local storage, queued optimistic writes and reconciliation. An Eloxiv-owned Foldkit adapter turns live query results into Messages, scopes query and connection lifetimes, reports failures and rejections, and tears down on organisation or session changes. Query snapshots feed the Model without a second entity cache; authoritative writes go through the invocation path and the generated optimistic mutators, with scoped Effect integration and cancellation designed explicitly.
64
+ - **Mobile is unchanged.** Foldkit targets the browser; a future Expo/React Native app has its own UI model and shares the headless SDK and contracts. The Hermes SDK guard stays.
65
+ - **Testing.** Foldkit Story and Scene cover most UI logic and interaction (Model transitions, emitted Commands, virtual-node views); separate Effect tests cover Command implementations; a small Playwright suite covers what only a browser proves (real CSS and StyleX output, layout, focus and portals, IndexedDB, WebSockets, network). Real desktop and device checks remain. Vitest stays.
66
+ - **The proof, before any broad migration or new screens:** one real journey in the browser and in Tauri, within the performance budgets: sign in; switch organisations with no transient rows from the old organisation; read live replica data; an optimistic write, and a rejected one rolled back with a typed error; sign out with the connection revoked and closed; routing; a StyleX-styled accessible dialog with keyboard and focus behaviour; optional UI installed and assembled through the CLI (including a headless module without its UI); light, dark and RTL. If it succeeds, the existing shell migrates and new UI is built on it. If it shows a consequential incompatibility, the evidence and the decision needed go to the user; frameworks are not switched silently.
67
+ 11. **Registry UI is a thin reference layer; Eloxiv is for building apps, not shipping them.** Recorded at the user's direction. Apps built on Eloxiv customise their screens heavily, so finished product UI has little value and a lasting maintenance cost. The UI Eloxiv provides is:
68
+ - **The headless client layer (full investment):** the client SDK, the Foldkit adapter and a headless chat SDK (conversation, composer, transcript, approval, consent and inbox state). It carries the guarantees that are hard to get right (sync, optimistic writes, organisation isolation, revocation, auth teardown), so every app gets them without rebuilding them.
69
+ - **A small accessible UI kit:** themeable primitives on Foldkit UI and StyleX with keyboard, focus, dark/light and RTL handled. Not a full design system.
70
+ - **A thin reference shell and screens:** enough to prove the framework end to end and to serve as starting points an app or an agent copies and reshapes: the shell (routing, slots, theme and locale, organisation switcher, sign-in, error view), a minimal settings frame (profile, members, language and appearance), a basic chat screen, approval and consent prompts, the home space (launcher, unified inbox, global agent) and plain People, Mail and Calendar screens limited to what the example app's journeys exercise.
71
+ - **Not built:** the broad settings pages, the Dispatch-style admin control plane, devtools, visual editing, feedback and onboarding flows, rich kits (canvas, editor, data grid, dashboard, presence, sharing, motion, blocks), command menu UI and creative context. Their kernel capabilities and contracts stay in scope; only the screens are deferred (`deferred-by-user` in `docs/parity.json`). An app builds such screens itself on the client SDK, and the documentation shows how.
72
+
73
+ ### Settled 2026-11-10
74
+
75
+ 12. **Scope: the framework, not finished products or optional integrations.** Recorded at the user's direction, extending decision 11 from screens to whole products. In scope: the kernel and its contracts, the headless client layer, the reference shell and the People, Mail and Calendar reference modules, the Google, Microsoft Graph, Slack and OpenAI connectors, and the framework-level integration seams (a generic HTTP/OpenAPI connector and outbound MCP). Deferred (`deferred-by-user` in `docs/parity.json`): the additional domain modules (Analytics, Brain, expanded Content, Clips, Assets, Design, Slides, Forms, Plan, datasets and data programs, comments/review and Dreams as products); the scheduling/booking product; the telemetry and diagnostics products (session recording and replay, private problem reports, trace review and experiment products, monitoring/status products); the optional provider connectors other than those named above (GitHub, Notion, Sigma, Jev, LaunchDarkly, n8n/Zapier, voice and transcription, ChatGPT subscription and directory, browser extension, further messaging channels, institutional document sources). The kernel capabilities these would build on stay in scope. Also deferred: the twenty screen-only rows and, as replaced by earlier decisions, the five rows the 2026-11-10 classification recommends dropping (A-149, B-005, B-034, B-081, C-049).
76
+ 13. **Performance budgets are judged on a runner fit to judge them, and exceptions are written down.** Recorded at the user's direction. A budget missed on a runner the benchmark's calibration rates too slow is reported as inconclusive, not as a failure and not as evidence the budget is met. A budget the evidence shows cannot be met, or is not worth its cost, is brought to the user with the numbers and a proposed alternative rather than chased; an accepted exception is recorded in `docs/progress.md` with its cause. Budgets are never raised silently.
77
+
78
+ ### Settled 2026-11-17
79
+
80
+ 14. **Several client runtimes over one client core.** Recorded at the user's direction. It amends decisions 7, 8 and 10 where they conflict.
81
+ - **The clients:** the web (Foldkit, decision 10), desktop (**Rune**, a Rust GPU UI), mobile (Expo/React Native, the registry item `mobile`) and agents (MCP). More devices (smart glasses and the like) may follow; each is a thin client over the same core and contracts, not a new framework.
82
+ - **One client core.** The guarantees that are hard to get right (the policy-scoped replica, optimistic writes with typed rejection, organisation isolation on a switch, revocation, teardown on sign-out) live in one portable TypeScript client runtime in `@eloxiv/client`. JavaScript clients (web, React Native) run it in process. Native clients reach it through **LocalClient**, a versioned, language-neutral protocol the device daemon serves on its loopback relay; its schemas are JSON Schema like every other contract, and native types are generated from them, never hand-written. No client implements a second sync, prediction or policy engine.
83
+ - **Desktop.** The daemon is required for a native desktop client: it signs the person in (DesktopSignIn), holds that session in its custody, keeps the replica in SQLite and serves LocalClient. It never hands a kernel credential to the app. The registry provides a Rune desktop host template (`desktop-rune`) alongside the Tauri one (`desktop`), which stays as a fallback and for apps that want their web shell on desktop. Rust for UI is allowed in host templates; the kernel, contracts and client core stay TypeScript.
84
+ - **MAKE views are host-neutral.** A view tree (decided in the Sandbox contract) is drawn natively by each host from its closed vocabulary; the web keeps its script-less frame, Rune draws it without a DOM. No host executes view code.
85
+ - **Proof before default.** The Rune host is recommended for new desktop apps once its journey passes on a real kernel: sign in, live replica data, an optimistic write and a refused one rolled back with its typed error, an organisation switch with no rows of the old organisation, a MAKE view step, sign out; with keyboard and screen-reader labels, light and dark, and right-to-left. The Expo host is built on the same core (the registry item `mobile`, 2026-11-21; decision 8 as amended).
86
+
87
+ ## Kernel contracts
88
+
89
+ Core services: Invocation, Actor, Directory, Db/Tx, Outbox, Approvals, Audit, Files, Search, Notifications, Connections, Secrets, Sync, Telemetry (including analytics and error capture), Sandbox, Versioning, CollabDocument, Progress, Flags, Readiness, Ingestion, ResultRendering, Daemon (terminal, coding tools), the module manifest and the action registry.
90
+
91
+ The module manifest declares entities, actions, permission vocabulary, declarative policy, events, jobs, migrations, settings, skills, views, slots, commands, work-item sources, entity resolvers and published query views.
92
+
93
+ Capability contracts: MailProvider, CalendarProvider, DocumentSource, DirectoryProvider, ModelProvider, StorageBackend and **Messaging** now; Transcription, Accounting and Meeting later.
94
+
95
+ Shell contracts: View, Space, Slot, Command, ScreenContext, ThemeTokens, Locale (an RTL-aware catalog), the headless ClientSDK and LocalClient (the protocol native clients reach the client core through, decision 14). The chat UI, settings pages, command menu and similar are registry code built on a headless chat SDK.
96
+
97
+ ### Added 2026-11-02 from the feature ledger's gaps
98
+
99
+ Each gets a kernel contract and a conformance suite.
100
+
101
+ | Contract | Owns |
102
+ |---|---|
103
+ | Scheduler | Cron and interval jobs with timezone and execution identity; event and schedule triggers; recovery sweeps |
104
+ | Workflow | Durable execution: resumable, fenced, journalled steps, used by jobs, approvals and durable agent runs |
105
+ | Ingress | Inbound webhooks: signature verification, replay protection, durable acceptance, linked platform identities |
106
+ | Settings | Scoped values (user, org, app, module) declared in manifests, with keyed reads |
107
+ | Agent, split into AgentRuntime, Memory, Delegation and ContextAccounting | The loop, turns, tools, `complete()` and attachments; memory and compaction; sub-agents and teams; context inventory and budgets |
108
+ | AgentResources | Instructions, skills and agent files in personal, org and app scopes |
109
+ | Sharing | Per-record grants to users, groups, orgs and links, plus access requests, compiled into policy filters |
110
+ | ActionConsent | Approval of tool calls and remembered permissions |
111
+ | Privacy | Analytics and cookie consent categories, regional rules, and data-subject export and erasure across modules, files and connectors |
112
+ | QuerySurface | The read-only, policy-filtered views modules publish (decision 6) |
113
+ | Metering | Quotas, budgets and rate limits; backpressure per connection; agent token and cost limits |
114
+ | NotificationChannel | Delivery channels for Notifications: system email with templates, push, chat destinations |
115
+ | MachineIdentity | Service principals, API tokens, and the OAuth authorisation server for MCP and API clients |
116
+ | DeviceControl | Paired devices, browser-extension sessions and computer use, extending Daemon |
117
+ | Release | Migration ownership under a lease, schema snapshots, client/server version skew, deployment topology |
118
+
119
+ Comments and discussion on any record are a registry module that anchors to records through entity references.
120
+
121
+ ## Stack
122
+
123
+ | Layer | Choice |
124
+ |---|---|
125
+ | Language and runtime | TypeScript with Effect 4, on Bun, written against `@effect/platform` so Node remains a fallback. CI runs both |
126
+ | Contracts | Effect Schema as the source, emitting JSON Schema |
127
+ | Surfaces | Effect RPC (typed client), Effect HttpApi (HTTP), Effect McpServer (MCP), agent tools; all projected from the action registry. Subject to decision 5 |
128
+ | Database | PostgreSQL with Drizzle ORM and Kit; a schema and role per module |
129
+ | Sync | Zero, subject to decision 5 |
130
+ | Durable work | Effect cluster workflows inside the one runtime; Restate as the fallback |
131
+ | Auth | Better Auth; WorkOS when enterprise SSO or SCIM is needed |
132
+ | Policy | Cedar, subject to decision 2 |
133
+ | OAuth custody | Candidate: Nango, self-hosted per deployment (ELv2 permits this, not a managed service). Not yet decided; the Connections contract must not depend on it |
134
+ | AI | Vercel AI SDK behind ModelProvider; coding agents through harness adapters |
135
+ | Collaboration | Yjs |
136
+ | Search | PostgreSQL full-text search; a Rust index later if relevance demands it |
137
+ | Observability | OpenTelemetry through Effect, Sentry for errors, PostHog for product analytics |
138
+ | Shell | Foldkit and Vite as a single-page app, subject to decision 10's proof (was React 19 and TanStack Router); Tauri on desktop, with the daemon as a Bun-built sidecar; Rune for native desktop clients over LocalClient (decision 14) |
139
+ | Registry UI | Foldkit UI primitives and Eloxiv components styled with StyleX, subject to decision 10's proof (was shadcn/ui and Tailwind CSS); distributed in the shadcn registry format |
140
+ | Translations | Paraglide JS, right-to-left aware |
141
+ | Repository | pnpm workspaces, Turborepo, mise, TypeScript 7 strict, Oxlint, oxfmt, Vitest, Playwright, fallow boundaries, Changesets |
142
+ | Distribution | `@eloxiv/*` packages published to private GitHub Packages; registry items served from a private GitHub repository |
143
+ | Hosting | A long-running server per deployment (self-hosted, Railway or Fly); Neon for managed Postgres. Cloudflare Workers is ruled out because sync needs long-running processes |
144
+
145
+ Stack preferences set aside: Node for servers (Eloxiv runs on Bun), TanStack Start (a single-page app suits a shell that reads from a local replica and runs in Tauri), Astryx, and Cloudflare-first jobs and hosting.
146
+
147
+ ## Performance budgets
148
+
149
+ Enforced in CI. The building agent may tighten them once benchmarks show headroom, but not loosen them without asking.
150
+
151
+ | Measure | Budget |
152
+ |---|---|
153
+ | Shell route change served from the local replica | p95 ≤ 50 ms |
154
+ | Invocation overhead, excluding the handler | p50 ≤ 5 ms |
155
+ | A write reaching another client | p95 ≤ 250 ms |
156
+ | Kernel start on a set-up database | ≤ 2 s |
157
+ | Hello app in development | ≤ 2 GB RAM, cold start ≤ 5 s |
158
+ | Whole example app in development | ≤ 2 GB RAM; cold start ≤ 8 s as a regression tripwire (reported, not a gate) |
159
+ | Desktop launch to interactive | ≤ 1.5 s |
160
+
161
+ ## Example app
162
+
163
+ `examples/` holds an app assembled only through the Eloxiv CLI, as an outside developer would: the home space (launcher, inbox, global agent, member administration), People, Mail and Calendar, with Microsoft Graph and Google connectors. Its UI is a plain reference (decision 11), limited to what its journeys exercise, not a finished product. Its acceptance scenarios must pass through the client SDK and MCP alone, with no registry UI installed, and its end-to-end journeys must pass in the browser and in the Tauri desktop host, with the daemon running as its sidecar and a paired headless runner serving agent turns.