@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,109 @@
1
+ # Settings
2
+
3
+ Scoped values that modules declare in their manifests, each with a value schema and a default, read one key at a time (decisions.md "Settings"; the ledger's keyed `getSetting`, A-002, A-043).
4
+
5
+ - Kind: kernel service. Version 1.0.0.
6
+ - Schema: [`packages/contracts/schema/contracts/Settings.json`](../../packages/contracts/schema/contracts/Settings.json) (source [`Settings.ts`](../../packages/contracts/src/contracts/Settings.ts)).
7
+ - Implementation: the `Settings` service in [`packages/kernel/src/Settings.ts`](../../packages/kernel/src/Settings.ts); the kernel module `settingsModule` ([`settings/module.ts`](../../packages/kernel/src/settings/module.ts)); the client's sync table and resolver in [`@eloxiv/client/sync`](../../packages/client/src/PlatformSync.ts).
8
+ - Kit: `@eloxiv/testing/conformance/Settings` ([source](../../packages/testing/src/conformance/Settings.ts)).
9
+
10
+ ## Declaring a setting
11
+
12
+ In the module manifest ([ModuleManifest](module-manifest.md)):
13
+
14
+ ```ts
15
+ settings: {
16
+ "hello.defaultVisibility": {
17
+ description: "Who sees a new greeting when the caller does not say.",
18
+ scope: "user", // user | org | app | module
19
+ schema: Visibility,
20
+ default: "org", // encoded (JSON); must decode against the schema
21
+ },
22
+ },
23
+ ```
24
+
25
+ **Secrets never go in settings.** A setting whose schema is marked sensitive (annotated `sensitive: true` or `writeOnly: true`, a `password` format, or an Effect `Redacted`, anywhere inside it) is refused when the app's manifests are loaded; secrets belong to the Secrets contract.
26
+
27
+ ## Levels and resolution
28
+
29
+ A value can live at four levels, narrowest first:
30
+
31
+ | Level | Where it lives | Who sets it |
32
+ | --- | --- | --- |
33
+ | `user` | `eloxiv_settings.value`, per person and organisation | the person (`settings.set`) |
34
+ | `org` | `eloxiv_settings.value`, per organisation | organisation administrators (`eloxiv.settings.manage`) |
35
+ | `app` | `KernelApp.settings.app`, overridden by `eloxiv.deployment_setting` | configuration, or a deployment administrator (`configure`) |
36
+ | `module` | `KernelApp.settings.module`, overridden by `eloxiv.deployment_setting` | configuration, or a deployment administrator |
37
+
38
+ A setting's declared **scope is the narrowest level it accepts**. A read resolves the levels from its scope outwards and takes the first that holds a value, else the default (`resolveSetting` in `@eloxiv/contracts`):
39
+
40
+ - `user`: the person's own value, the organisation's, the deployment's, the module installation's, the default;
41
+ - `org`: the organisation's, the deployment's, the module installation's, the default;
42
+ - `app`: the deployment's, the module installation's, the default;
43
+ - `module`: the module installation's, the default.
44
+
45
+ So an organisation administrator can give a user-scope setting an organisation-wide value that each person may override, and a deployment can set a default for every organisation.
46
+
47
+ Configured values (`KernelApp.settings`) are checked at startup: the key must be declared, the level must be one its scope reaches, and the value must decode against its schema; a problem stops the kernel like any manifest problem. A stored value that no longer decodes (a module changed the schema) is skipped with a warning, and the next level applies.
48
+
49
+ ## Operations
50
+
51
+ | Operation | As | Input | Output |
52
+ | --- | --- | --- | --- |
53
+ | `get` | the action `settings.get` (read-only, every member) | `{ key }` | `SettingRead`: `key`, the encoded `value`, and `source` (the level, or `default`) |
54
+ | `set` | the action `settings.set` | `SettingWrite`: `key`, `value` (encoded), optional `level` (`user` or `org`, default the setting's scope) | `SettingChanged`: `id`, `key`, `level` |
55
+ | `clear` | the action `settings.clear` | `{ key, level? }` | `SettingChanged` |
56
+ | `configure` | in process only, `Settings.configure` (operators: no surface reaches it) | `{ key, level: "app" \| "module", value }` (`null` removes it) | |
57
+
58
+ Handlers read settings through **`ctx.settings.get(key)`**, which resolves the key for the caller exactly as `settings.get` does and returns the value decoded with the setting's schema; an undeclared key is a defect.
59
+
60
+ **How a handler reads them.** On the handler's own connection and transaction, without ever switching its role: the handler's runtime role cannot read `eloxiv.deployment_setting` or the `settings` module's table, so both are read through the platform read functions setup creates in schema `eloxiv_platform` (`deployment_setting(key)` and `stored_setting(key)`). Each is `SECURITY DEFINER`, owned by the dedicated NOLOGIN role `eloxiv_platform_read`, with a fixed search path; it takes only the key, refuses a transaction with no invocation context, and returns only that key's values for the caller the context records (their own `user` value and their organisation's `org` value; the `app` and `module` values). Only module runtime roles may execute them. A role switch around the reads would also apply to statements the handler runs concurrently on the same transaction (`Effect.all` with concurrency), which would run as the kernel; none happens.
61
+
62
+ There is **no operation that lists settings**: every read names its key, on the action and on the sync query alike.
63
+
64
+ Errors: `InvalidInput` for an undeclared key, a level the setting's scope does not have, or a value that does not decode against its schema; `Forbidden` when the caller may not write that level (a member writing the organisation's value, anyone writing an `app` or `module` scope setting through an action); `Unauthenticated`.
65
+
66
+ ## Authorisation
67
+
68
+ The `settings` module's Cedar policy, enforced by the invocation path and row-level security:
69
+
70
+ - a person sets and clears their own `user`-level values, in the organisation they act in;
71
+ - organisation administrators (`eloxiv.settings.manage`, which the built-in `admin` role grants) set and clear `org`-level values of their organisation;
72
+ - members read their own `user`-level values and their organisation's `org`-level values;
73
+ - `app` and `module` levels are not writable through actions: they are configuration, or `configure`.
74
+
75
+ An agent acting for a person writes what the person may write.
76
+
77
+ ## Sync
78
+
79
+ The `settings` module's table syncs to each person's replica: their own `user`-level values and their organisation's `org`-level values, in the organisation they act in. Add `platformTables` and `platformQueries` from `@eloxiv/client/sync` to the app's sync configuration. The named query `settings.value` takes the key as its argument (`zero.query.settings.value("hello.defaultVisibility")`), so the replica too is read by key. A row's `value` is `{ v: <encoded value> }`, or `null` once cleared.
80
+
81
+ `settingFromReplica(declaration, rows, deployment?)` resolves the value locally as the kernel does, including skipping a value (synced or passed as `deployment`) that no longer decodes against the declaration's `schema`, so the next level applies. Deployment values (`app` and `module` levels) are configuration and are not in the replica: an app that sets them reads them once with `settings.get` and passes them as `deployment`.
82
+
83
+ ## Setup checklists
84
+
85
+ A module's (or app's) onboarding is a checklist kept in a setting (ledger B-067): `defineChecklist({ key, title, description, scope?, steps })` (`@eloxiv/contracts`) gives the setting to declare under its key (`settings: { [checklist.key]: checklist.setting }`), whose value is a `ChecklistState` (the steps done or dismissed, with when, and whether the list is collapsed or dismissed; empty by default). Because it is a setting, a `user` checklist's progress is the person's alone, in the organisation they act in, durable and on every device they sign in on (their replica holds it: `checklistFromReplica(checklist, rows)` over `settings.value`); an `org` checklist is one shared list that organisation administrators complete and every member reads.
86
+
87
+ The headless state is pure (`completeStep`, `dismissStep`, `reopenStep`, `collapseChecklist`, `dismissChecklist`; a step the checklist does not declare changes nothing), and `checklistSummary(checklist, state)` is what a screen or an agent shows: each declared step's status in order, the counts, `complete`, `collapsed` and `visible` (neither dismissed nor complete). A change is written as the next state through `settings.set` (`checklistWrite(checklist, state)` is its input), so it goes through the one invocation path, is audited, and the person's agent can make it as they could (`packages/testing/test/checklists.test.ts`).
88
+
89
+ **Limit, stated:** a write replaces the whole state, so two devices changing the same checklist at the same moment keep the later write (a tick can be lost and is made again); progress is never shared between people.
90
+
91
+ ## Audit
92
+
93
+ Every `set` and `clear` is an invocation, audited once ([Audit](audit.md)), with `detail` `{ key, level, subject, before, after }` (the encoded values; `subject` is the person or the organisation). Refused writes are audited as `denied` or `failed`. `configure` is audited as `eloxiv.settings.configure` with the same `detail` (`subject` is the operator).
94
+
95
+ ## Preferences
96
+
97
+ The kernel's `settings` module declares each person's preferences (`PREFERENCE_SETTINGS`, user scope): `settings.locale` (a BCP 47 tag, or null for the browser's), `settings.timeZone` (an IANA zone, or null for the device's) and `settings.theme` (`system`, `light` or `dark`; default `system`). They resolve like any user-scoped setting (the person's own value, else their organisation's, which administrators set, else the default), are checked against their schemas, and sync to the person's replica, so every device of theirs shows the same. In the client: `preferencesFromReplica(rowsOf)` reads them from the replica's `settings.value` rows as the kernel does; `savePreference(transport, "theme", "dark")` and `clearPreference` write the person's own value through `settings.set` and `settings.clear`. A cron schedule created with `timeZone: "local"` runs in its creator's time zone preference as it is then (UTC without one; [Scheduler](scheduler.md)). Tested in [`preferences.test.ts`](../../packages/testing/test/preferences.test.ts).
98
+
99
+ ## How an implementation is checked
100
+
101
+ `settingsConformance(start)` takes a `PlatformSubject` (see [QuerySurface](query-surface.md#how-an-implementation-is-checked)). The fixture's `crm` module declares `crm.pageSize` (user scope, an integer from 1 to 200, default 25), `crm.currency` (org, `USD`, `EUR` or `SAR`, default `USD`), `crm.region` (app, configured `me-central`) and `crm.limit` (module, configured 250), and its `crm.peek` action returns what `ctx.settings.get` gives.
102
+
103
+ The kit checks: keyed reads with their source, on several surfaces, and that no list operation exists; resolution through every level in order, including a deployment administrator's value over configuration and an app-level value under an organisation's; authorisation per level (members, administrators, another organisation's administrator, deployment scopes, an agent acting for a person); validation against the schema; each person's replica holding exactly their own values and their organisation's, per key, and nothing for another organisation or a non-member; the audit records of writes, refusals and `configure`; `ctx.settings.get` in a handler; and sensitive schemas refused. The Eloxiv kernel runs it in [`packages/testing/test/settings.test.ts`](../../packages/testing/test/settings.test.ts); a handler's role staying its own while `ctx.settings.get` and `ctx.flags.isEnabled` read, and the platform read functions' grants and answers, in [`handler-role.test.ts`](../../packages/testing/test/handler-role.test.ts); `settingFromReplica` in [`platform-sync.test.ts`](../../packages/testing/test/platform-sync.test.ts); the pure resolution and manifest checks are proven in [`packages/contracts/test/platform.test.ts`](../../packages/contracts/test/platform.test.ts).
104
+
105
+ ## Not yet guaranteed
106
+
107
+ - **Deployment values on the client**: `app` and `module` levels are not synced (they have no organisation); clients read them with `settings.get`.
108
+ - **Per-person values across organisations**: a person's `user`-level value belongs to the organisation they set it in.
109
+ - **No settings UI**: settings pages are registry code over these actions.
@@ -0,0 +1,77 @@
1
+ # Sharing
2
+
3
+ Per-record grants to a user, a group, the whole organisation or a link, and access requests (decisions.md, the Sharing row; decision 2). Grants compile into the same policy filters that row-level security, sync and the query views apply, evaluated for the acting principal only.
4
+
5
+ - Kind: kernel service. Version 1.0.0.
6
+ - Schema: [`packages/contracts/schema/contracts/Sharing.json`](../../packages/contracts/schema/contracts/Sharing.json) (source [`Sharing.ts`](../../packages/contracts/src/contracts/Sharing.ts)).
7
+ - Implementation: the kernel's [`Sharing`](../../packages/kernel/src/Sharing.ts) service (`forActor`, the trusted `grant` and `revoke`, the expiry `sweep`) and the kernel-provided [`sharing` module](../../packages/kernel/src/sharing/module.ts) (`sharingModule`), whose actions are the operations below; tables in kernel migration `0017_sharing` ([`KernelSchema.ts`](../../packages/kernel/src/db/KernelSchema.ts)) and the module's `eloxiv_sharing.access_request`.
8
+ - Kit: `@eloxiv/testing/conformance/Sharing` ([source](../../packages/testing/src/conformance/Sharing.ts)).
9
+
10
+ ## The model
11
+
12
+ **A shareable entity** declares one or more *sharing attributes* among its policy attributes: `{ kind: "sharing", permission }`, a `Set<Eloxiv::User>` in Cedar. The permissions it can be shared with are exactly those attributes' `permission` values (a book with `readers` (`read`) and `editors` (`edit`) can be shared with `read` or `edit`). A policy tests a grant with `resource.<attribute>.contains(principal)` (or `containsAny([principal])`): the acting principal holds a grant with that permission on the record.
13
+
14
+ **A grant** gives one permission on one record (by Cedar type and primary key) to one grantee, optionally until an instant. It is always in its **record's own organisation**, which the kernel reads from the record (its one `Eloxiv::Org` attribute, which every shareable entity must have; startup refuses one without), never from the acting context; it is made only by someone acting in that organisation, and it counts only for someone acting there:
15
+
16
+ | Grantee | Who holds it |
17
+ | --- | --- |
18
+ | `{ user }` | That user, while acting in the record's organisation (the user must be a member of it when the grant is made) |
19
+ | `{ group }` | Members of that group of the record's organisation, while they act in it and are in the group |
20
+ | `{ org }` | Every member of the record's organisation while acting in it (no other organisation) |
21
+ | `{ link: {} }` | Members of the record's organisation who redeemed the link's token, while acting in it |
22
+
23
+ **Links.** Creating a link returns its token (`eloxiv_link_` and 32 random bytes, base64url) exactly once; the kernel stores only its SHA-256. Presenting it (`redeemLink`) while signed in and acting in the organisation it was made in records the redemption; from then on the redeemer holds the grant. A link always expires (30 days by default, at most 365); revoking or expiring it removes it, and with it every redemption. *Decided here:* links are for members of the organisation, never anonymous: every read in Eloxiv is an authenticated actor's, and the replicas, row-level security and audit all key on one. Anonymous public access would need an anonymous principal model and is not offered.
24
+
25
+ **Who may share** is the record's entity's own Cedar policy for the action `share` in its module's namespace (for example `Library::Action::"share"`), which the kernel's schema declares on every shareable entity (module actions may not be named `share` or `read`). It decides sharing, listing and revoking a record's grants, and deciding access requests for it. The kernel checks it for the caller against the record, in the operation's transaction, at the moment of the operation, as the entity's module role (so the record's row-level security applies as well), and requires the record to be in the organisation the caller acts in. A record that does not exist, a record of another organisation and a record the caller may not share get the same answer. Startup refuses a `share` policy not tied to the actor (as for every action: by organisation, a user field, or a grant).
26
+
27
+ ## Operations
28
+
29
+ Every operation is an action of the `sharing` module: on every surface (RPC, HTTP, MCP, agent tools, CLI), on the one invocation path (identity, consent, idempotency, audit). `grant` is marked for consent: an agent acting for a person (agent tools, MCP, an agent session) is held with `ConsentRequired` until the person approves the exact call; `revoke` is destructive, so it is held as well. Handlers have the same operations, authorised the same way, as `ctx.sharing` (`share`, `unshare`, `listGrants`, `redeemLink`, `canShare`).
30
+
31
+ | Operation (action) | Input | Output | Effect |
32
+ | --- | --- | --- | --- |
33
+ | `grant` (`sharing.grant`) | `{ entity, id, grantee, permission, expiresAt? }` | `{ grantId, token, expiresAt }` | Grant `permission` on the record. The same grantee and permission, shared again in the same organisation, is the same grant, with the new expiry (a group is a group of the organisation the grant is made in, so the same group id shared from two organisations is two grants). `token` is set for a new link only. |
34
+ | `revoke` (`sharing.revoke`) | `{ grantId }` | `{ revoked }` | Revoke a grant of a record the caller may share. |
35
+ | `list` (`sharing.list`) | `{ entity, id }` | `{ grants: Grant[] }` | The record's unexpired grants (kind, grantee, permission, grantor, created, expires, a link's redemption count; never a token). Read-only. |
36
+ | `redeemLink` (`sharing.redeemLink`) | `{ token }` | `{ entity, id, permission }` | Redeem a link while acting in its organisation. |
37
+ | `access` (`sharing.access`) | `{ entity, id }` | `{ access, canShare, requests }` | For an access gate: `allowed` if the caller may read the record now (its entity's `read` policy, as its module role under row-level security, in the organisation they act in), else `unavailable`, the same answer for a record that does not exist or is another organisation's; `canShare` (false unless `allowed`); the caller's own access requests for the record, most recent first (`id`, `permission`, `status`, `updatedAt`). Read-only. |
38
+ | `requestAccess` (`sharing.requestAccess`) | `{ entity, id, permission, message? }` | `{ id, status }` | Ask for a permission. Every other member of the organisation who may share the record now (its *managers*, by the `share` policy) gets a work item (source `sharing.accessRequests`), a notification (category `sharing`) and the `decide` grant on the request, which lets them read and decide it. Asking again reopens the same request. The answer is the same whether or not the record exists or has managers. |
39
+ | `approveRequest` (`sharing.approveRequest`) | `{ id }` | `{ id, status, grantId }` | Grant the requester the permission, if the approver may still share the record; close every manager's item and notify the requester. |
40
+ | `denyRequest` (`sharing.denyRequest`) | `{ id }` | `{ id, status, grantId: null }` | Refuse; the same closing and notification. |
41
+
42
+ Errors are the standard invocation errors: `Forbidden` (the caller may not share the record, the grant or link is not theirs to manage or not valid, a decider is not one or may no longer share), `InvalidInput` (an entity that cannot be shared, a permission it does not declare, a grantee outside the record's organisation, an expiry in the past or a link's beyond a year, a decided request), `ConsentRequired` for an agent's `grant` or `revoke`.
43
+
44
+ The trusted kernel API `Sharing.grant` and `Sharing.revoke` (seeds, tests, the kernel's own approval flow) apply no policy and accept any grantee. `Sharing.grant` takes the record's organisation (`orgId`, required): a grant recorded in any other organisation, or in none, authorises no one, because every check compares it with the record's own column.
45
+
46
+ ## Records
47
+
48
+ `Grantee`, `SharedRecord` (`{ entity, id }`), `Grant`, `GrantKind`, `AccessRequest` (`id, orgId, requesterId, resourceType, resourceId, permission, message, status, decidedBy`), `AccessRequestStatus` (`pending`, `approved`, `denied`), `ShareGrantColumns` (the columns of `eloxiv.share_grant`: `id, resource_type, resource_id, grantee_kind, grantee_id, org_id, permission, expires_at`).
49
+
50
+ ## Guarantees
51
+
52
+ 1. **Grant checks answer only for the acting principal.** In SQL, `eloxiv_ctx.has_grant(type, id, permission, record_org)` (a `SECURITY DEFINER` function, the only way module roles reach grants) answers whether the principal of the transaction's invocation context holds the grant: its user grants, its groups' grants in the acting organisation, the acting organisation's grants, and links it redeemed there; and only where the record's organisation (`record_org`, which the compiled filter passes from the record's own column), the grant's and the acting organisation are one (migration `0018_sharing_organisation`). No form answers for another grantee, so module code cannot learn who holds a grant. A policy that tests a sharing set for any other user (`resource.editors.contains(Eloxiv::User::"bob")`) does not compile unless Bob is the bound principal; it fails closed.
53
+ 2. **The same grants everywhere.** Row-level security, the kernel's target checks, the query views and every replica's sync filter apply the same compiled predicate; a replica's filter tests grants live, as permission subqueries zero-cache evaluates over its replicated `eloxiv.share_grant`, `eloxiv.share_redemption` and directory facts, whose rows never reach a client ([Sync](sync.md), guarantee 7). A grant or revocation (of any kind, by any path) reaches a connected replica as soon as zero-cache replicates it, without reconnecting.
54
+ 3. **Expiry.** An expired grant authorises nothing in the database from the instant it expires. The kernel deletes expired grants every second (`ELOXIV_SHARE_SWEEP_MS`; `KernelOptions.sharingSweep`), which removes them from connected replicas; a replica's filter also ignores grants that had expired when its query was transformed. Bound: a connected replica can hold a record an expired grant admitted for at most the sweep interval plus replication lag.
55
+ 4. **Who may share is a policy**, checked at each operation against the record for the caller; nothing about a record the caller may not share is revealed (the same `Forbidden` as for a missing record; an access request answers the same either way).
56
+ 5. **In the record's organisation.** Every operation (grant, revoke, list, requesting, approving and denying access) acts on a record only while the caller acts in the record's organisation; a request made from another organisation reaches no one. Grantees are a member or group of that organisation, or the organisation; permissions are the entity's declared ones. Row-level security, the query views and sync count a grant only where the record's, the grant's and the acting organisation are one, so no grant (whoever made it) carries a record into another organisation.
57
+ 6. **Audited and consent-bound** like every action: one audit row per call (`succeeded`, or `denied`/`failed`/`approval-required` after rollback), with its surface.
58
+ 7. **Access requests reach managers** as work items and notifications in the request's transaction, and a decision is checked against the record's `share` policy for the decider at the moment of deciding.
59
+ 8. **An access gate reveals nothing.** `sharing.access` says only whether the caller may read the record now; a missing record, another organisation's and an unreadable one answer exactly alike, and the requests listed are the caller's own.
60
+
61
+ ## Clients
62
+
63
+ `@eloxiv/client/sharing` ([ClientSDK](client-sdk.md#collaboration-sharing-and-history-controllers)) has the headless controllers over these actions: `shareController` (a record's grants changed optimistically and reconciled, with a grant to the whole organisation held until confirmed), `wideningTransition` (the same confirmation for a module's own visibility change), `accessGate` (allowed, unavailable, signed out; requesting access and noticing its approval) and `decideAccessRequest`.
64
+
65
+ ## How an implementation is checked
66
+
67
+ `sharingConformance(start)` runs against an `InboxSubject` ([`InboxSubject.ts`](../../packages/testing/src/conformance/InboxSubject.ts)) serving the **sharing conformance app** ([`library/app.ts`](../../packages/testing/src/conformance/library/app.ts)): the `library` fixture (books with `read` and `edit` grants, shared by their owner or an editor; pages with `view` grants, readable through one hop to their book's owner) with the inbox modules and the sharing module. It checks user, group, organisation and link grants (by the sync filter and by actions), that a grant stays in its record's organisation (an editor who belongs to two organisations cannot share, list, revoke or have requested a record of one while acting in the other; a grant counts only acting in the record's organisation, and one recorded in another organisation for no one), who may share, permission and grantee validation, links (token once, never listed, redemption in the organisation only, revocation), expiry (refused at once, then deleted), every surface (RPC and HTTP share; agent tools and MCP are held for consent; audit rows per surface), access requests (managers by policy, work items, notifications, approval and denial, a manager who lost the right, a missing record), the access gate's answer (the same for a missing, another organisation's and an unreadable record; only the caller's own requests), and the sync filter (grants bound to the caller only; pages reached from a book filtered by their own policy).
68
+
69
+ The Eloxiv kernel runs it in [`packages/testing/test/sharing.test.ts`](../../packages/testing/test/sharing.test.ts). Live through zero-cache, [`sharing-live.test.ts`](../../packages/testing/test/sharing-live.test.ts) proves every grant kind and its revocation or expiry reaching a connected replica without reconnecting, and child queries (below). [`sync-property.test.ts`](../../packages/testing/test/sync-property.test.ts) proves, for generated policies, actors and data with grants of every kind, that a replica holds exactly what Cedar authorises.
70
+
71
+ ## Not yet guaranteed
72
+
73
+ - **Anonymous links** (public access without signing in): not offered, by design (above).
74
+ - **Sharing across organisations**: not offered, by design. A grant counts only in its record's organisation, so a user of another organisation must be a member of the record's organisation, acting in it, to hold one.
75
+ - **Shell screens** for sharing and access requests (registry UI, deferred by decision 11); the client SDK has the headless controllers above.
76
+ - **A trashed state**: records have no kernel trash state, so the gate has none; a module whose records can be trashed makes a trashed record unreadable by its `read` policy (the gate then says `unavailable`) or answers its own trash state.
77
+ - **Invitations**: grants are to members, groups and the organisation (above); bringing someone new into the organisation is the Directory's.
@@ -0,0 +1,48 @@
1
+ # Slot
2
+
3
+ Extension points modules declare, and the contributions other modules make to them, resolved across every installed module into one deterministic order. A home space's launcher, a record page's side panels and a toolbar's buttons are slots; the modules that fill them do not know about each other.
4
+
5
+ - Kind: shell contract. Version 1.0.0.
6
+ - Schema: [`packages/contracts/schema/contracts/Slot.json`](../../packages/contracts/schema/contracts/Slot.json) (source [`Slot.ts`](../../packages/contracts/src/contracts/Slot.ts)). Declared with the manifest's `slots` and `contributions` ([ModuleManifest](module-manifest.md)).
7
+ - Implementation: `shellRegistry(...).slots()` and `.slot(id)` in `@eloxiv/shell-core` ([`Navigation.ts`](../../packages/shell-core/src/Navigation.ts)).
8
+ - Kit: `@eloxiv/testing/conformance/Slot` ([source](../../packages/testing/src/conformance/Slot.ts)).
9
+
10
+ ```ts
11
+ // In a module's manifest
12
+ slots: { "home.launcher": { description: "Tiles on the home space", accepts: "view" } },
13
+ contributions: { "mail.launcherTile": { slot: "home.launcher", view: "mail.inbox", order: 10 } },
14
+
15
+ // In the shell
16
+ for (const entry of shell.slot("home.launcher")) render(entry.target) // { view } or { command }
17
+ ```
18
+
19
+ ## Operations
20
+
21
+ | Operation | Input | Output | What it does |
22
+ | --- | --- | --- | --- |
23
+ | `list` | `{}` | `SlotDescriptor[]` | Every slot, in module installation order, then by id |
24
+ | `resolve` | `{ slot }` | `SlotEntry[]` | The slot's contributions from every installed module, each resolved to the view's descriptor or the command's palette entry, in order. `UnknownSlot` if no module declares the slot |
25
+
26
+ ## Records
27
+
28
+ - **`SlotDescriptor`**: `id`, `module`, `description`, `accepts` (`view` or `command`).
29
+ - **`SlotEntry`**: `contribution` (its id), `module` (who contributed it), `order?`, `target` (`{ view: ViewDescriptor }` or `{ command: PaletteEntry }`).
30
+ - **Error**: `UnknownSlot { slot }`.
31
+
32
+ ## Guarantees
33
+
34
+ 1. **One deterministic order**: `order` ascending; entries without an `order` after every entry with one; then the contributing module's installation order; then contribution id. It does not depend on the order a manifest lists its contributions in.
35
+ 2. **Resolved targets only.** Each entry carries the view's descriptor (with its route) or the command's palette entry, never a dangling id.
36
+ 3. **Checked at startup.** The manifest check (`manifestProblems`, run by the kernel) refuses a contribution to a slot that does not exist, of a view or command that does not exist, or of the wrong kind (a view to a command slot).
37
+
38
+ ## MAKE views in slots
39
+
40
+ A MAKE module's view can be shown in the app's view slots too: its source names them (`view.slots`), and `make.slots` lists the organisation's installed ones in the same order rule ([Sandbox](sandbox.md#make)). They are the organisation's, not the app's, so they are not in `shellRegistry`'s static resolution: a shell adds them to a slot's entries at run time (`makeSlot`) and renders each in its sandboxed frame.
41
+
42
+ ## How an implementation is checked
43
+
44
+ `slotConformance(make)` builds the implementation over the shell fixture ([`atlas/contract.ts`](../../packages/testing/src/conformance/atlas/contract.ts): `atlas.panels` for views and `atlas.toolbar` for commands, filled by both modules, ordered and unordered) and checks the slots, the resolved order and targets, that reversing a manifest's contributions changes nothing while swapping installation order breaks ties the other way, `UnknownSlot`, and the manifest check's refusals. The Eloxiv implementation runs it in [`shell-navigation.test.ts`](../../packages/testing/test/shell-navigation.test.ts).
45
+
46
+ ## Not yet guaranteed
47
+
48
+ - **No filtering by policy or space**: a slot lists every contribution of the installed modules; the shell decides what to show of a view the person cannot use.
@@ -0,0 +1,67 @@
1
+ # Space
2
+
3
+ Curated entry points over several modules' views. The organisation defines its spaces as data, its roles grant them, and each person personalises within the spaces granted to them. The home space (launcher, inbox, agent, admin) is one such space, defined by the app.
4
+
5
+ - Kind: shell contract. Version 1.0.0.
6
+ - Schema: [`packages/contracts/schema/contracts/Space.json`](../../packages/contracts/schema/contracts/Space.json) (source [`Space.ts`](../../packages/contracts/src/contracts/Space.ts)).
7
+ - Implementation: the kernel-provided `spaces` module (`spacesModule`, [`packages/kernel/src/spaces/module.ts`](../../packages/kernel/src/spaces/module.ts)), its sync tables (`spacesTables`, `spacesRelationships` and `spacesQueries` in `@eloxiv/client/sync`, the tables generated from the module's Drizzle tables), and `resolveSpaces` in `@eloxiv/shell-core` ([`Spaces.ts`](../../packages/shell-core/src/Spaces.ts)).
8
+ - Kit: `@eloxiv/testing/conformance/Space` ([source](../../packages/testing/src/conformance/Space.ts)).
9
+
10
+ Install it by adding `spacesModule` to the app's modules and the three sync exports to its sync schema. Then:
11
+
12
+ ```ts
13
+ // An administrator (eloxiv.spaces.manage) defines a space
14
+ await client.call("spaces.define", {
15
+ id: "sales", title: "Sales", entries: [{ view: "crm.deals" }, { view: "mail.inbox" }],
16
+ audience: { roles: ["sales", "sales-lead"] },
17
+ })
18
+ // A member pins it and reorders it
19
+ await client.call("spaces.personalise", { space: "sales", pinned: true, entryOrder: ["mail.inbox", "crm.deals"] })
20
+ // The shell resolves the replica's rows against the installed views
21
+ const grants = await zero.run(spacesQueries.spaces.granted())
22
+ const prefs = await zero.run(spacesQueries.spaces.preferences())
23
+ const spaces = resolveSpaces(grants, prefs, shell) // ResolvedSpace[]
24
+ ```
25
+
26
+ ## Operations
27
+
28
+ | Operation | Action | Input | Output | What it does |
29
+ | --- | --- | --- | --- | --- |
30
+ | `define` | `spaces.define` | `SpaceDefinition` | `{ id }` | Defines or replaces a space of the acting organisation (holders of `eloxiv.spaces.manage`). Replacing it re-grants it: an audience no longer in it loses the space at once |
31
+ | `remove` | `spaces.remove` | `{ id }` | `{ id }` | Withdraws a space from everyone (`eloxiv.spaces.manage`) |
32
+ | `personalise` | `spaces.personalise` | `SpacePreference` | `{ id }` | Sets the caller's own preferences for a space granted to them; `Forbidden` for any other space, whether or not it exists |
33
+ | `reset` | `spaces.reset` | `{ id }` | `{ id }` | Drops the caller's preferences for a space |
34
+ | `mine` | (client) | `{ includeHidden? }` | `ResolvedSpace[]` | The caller's spaces, from their replica, resolved and ordered (`resolveSpaces`) |
35
+
36
+ ## Records
37
+
38
+ - **`SpaceDefinition`**: `id` (`^[a-z][a-z0-9-]{0,62}$`, unique per organisation), `title`, `description?`, `icon?` (a name the shell's icon set knows), `entries` (`{ view }`, at most 100), `audience` (`{ everyone: true }`, the only way to grant everyone, or `{ roles: [...] }`: 1 to 50 Directory role ids, `^[a-z0-9][a-z0-9_-]{0,62}$`, so a wildcard such as `*` is refused), `position?` (the organisation's order).
39
+ - **`SpacePreference`**: `space`, `pinned?`, `hidden?`, `position?`, `entryOrder?` and `hiddenEntries?` (view ids of the space's own entries).
40
+ - **`ResolvedSpace`**: `id`, `title`, `description?`, `icon?`, `pinned`, `hidden`, `position`, `entries` (`ViewDescriptor[]`, [View](view.md)).
41
+
42
+ ### Storage and sync
43
+
44
+ The module's schema is `eloxiv_spaces`:
45
+
46
+ - `space_grant`: one row per space and audience (`<org>/<space>/<audience>`, audience `*` for everyone or a role), with the definition, `withdrawn`, `updated_by`, `updated_at`. Read policy: in the organisation the member acts in, not withdrawn, and the audience is `*` or a role the member holds there (`principal.roles.contains(resource.audience)`: row-level security calls `eloxiv_ctx.has_role(audience)`, and sync tests the replicated directory facts live). Rows are withdrawn, never deleted, because `define` and `remove` name no target ([the action contract](../scaffold.md#the-action-contract)).
47
+ - `preference`: one row per member, space and grant it was set through (`<org>/<user>/<space>/<audience>`, `grant_id` referencing the grant row), readable and writable by that member only and only while that grant reaches them (the policy follows the reference: `resource.grant` not withdrawn, for everyone or a role the member holds). `personalise` writes a row for every grant that reaches the member, so a preference lasts while any of them does; the client takes the newest.
48
+
49
+ Queries: `spaces.granted` (`Spaces::Grant`) and `spaces.preferences` (`Spaces::Preference`).
50
+
51
+ ## Guarantees
52
+
53
+ 1. **Only managers define.** `define` and `remove` need `eloxiv.spaces.manage` in the acting organisation (the built-in `admin` role grants it; migration `0028_spaces_manage` gives it to existing administrators), act in that organisation only, and are audited like every call.
54
+ 2. **A replica holds exactly the granted spaces**: those granted to everyone in the organisation it acts in, or to a role its member holds there, never another organisation's, never a withdrawn one.
55
+ 3. **Live.** Gaining a role brings its spaces to the replica; losing it, a redefinition without it, or `remove` takes them away, while the replica stays connected.
56
+ 4. **Preferences are private and bounded by the grant.** A member reads and writes only their own, only for a space granted to them (a withdrawn grant takes them off the replica, and `reset` reaches none); `entryOrder` and `hiddenEntries` keep only the space's own entries, so personalising never adds one.
57
+ 5. **Resolution** (`resolveSpaces`): a space granted through several roles is one space (the newest row); entries naming views no installed module declares are dropped; the person's entry order comes first, then the space's remaining entries, minus their hidden entries; ordered pinned first, then position (the person's, else the organisation's), then title, then id; hidden spaces only with `includeHidden`.
58
+
59
+ ## How an implementation is checked
60
+
61
+ `spaceConformance({ kernel, resolve })` runs against a kernel serving the spaces conformance app ([`atlas/app.ts`](../../packages/testing/src/conformance/atlas/app.ts)) through `InboxSubject`: refusals without the permission (and success with a role granting only it), audit outcomes, wildcard and malformed roles refused, the sync endpoint's rows for members of different roles and organisations, a **connected replica** (the subject's sync server re-runs no query on its own) receiving a space and its preference as the member gains a role and losing both as they lose it, never receiving a later grant to the lost role, and unaffected by the same role held in another organisation, redefinition and withdrawal, and preferences (owner only, granted spaces only, foreign entries dropped, withdrawn with their grant, reset); and the client resolution rules above. The Eloxiv implementation runs it in [`space.test.ts`](../../packages/testing/test/space.test.ts). The compiler's support for a role named by a record is also covered by the Cedar differential tests ([`policy-compiler.test.ts`](../../packages/kernel/test/policy-compiler.test.ts), [`policy-sql.test.ts`](../../packages/testing/test/policy-sql.test.ts)).
62
+
63
+ ## Not yet guaranteed
64
+
65
+ - **Entries are not checked against the installed views by the kernel**; the client drops the ones it cannot resolve.
66
+ - **No group audiences** (roles and everyone only), and no per-person spaces (a person's own collections).
67
+ - **Withdrawn rows accumulate** (one per space and audience ever used); they are never synced.
@@ -0,0 +1,45 @@
1
+ # StorageAdapter
2
+
3
+ Where a client's local replica lives (decision 7): IndexedDB on the web, SQLite on desktop, servers and mobile, memory for tests. The replica is a transactional key-value store (Zero's store interface); an adapter is what `connectSync({ storage })` takes.
4
+
5
+ - Kind: shell contract. Version 1.0.0.
6
+ - Schema: [`packages/contracts/schema/contracts/StorageAdapter.json`](../../packages/contracts/schema/contracts/StorageAdapter.json) (source [`StorageAdapter.ts`](../../packages/contracts/src/contracts/StorageAdapter.ts)).
7
+ - Implementation: `@eloxiv/client/storage` ([`Storage.ts`](../../packages/client/src/Storage.ts)): `indexedDbStorage()`, `sqliteStorage(open, options)`, `memoryStorage()`; and `expoSQLiteStoreProvider` in `@eloxiv/client/expo-sqlite` on React Native.
8
+ - Kit: `@eloxiv/testing/conformance/StorageAdapter` ([source](../../packages/testing/src/conformance/StorageAdapter.ts)).
9
+
10
+ ```ts
11
+ import { sqliteStorage } from "@eloxiv/client/storage"
12
+ import { Database } from "bun:sqlite" // or: import { DatabaseSync } from "node:sqlite"
13
+
14
+ const replica = sqliteStorage((file) => new Database(file), { directory: stateDir })
15
+ const zero = connectSync({ server, schema, userId, token, orgId, storage: replica.storage })
16
+ ```
17
+
18
+ | Adapter | Where | Durable | How |
19
+ | --- | --- | --- | --- |
20
+ | `indexedDbStorage()` | browsers, webviews (the Tauri desktop host included) | yes | Zero's IndexedDB store (`"idb"`) |
21
+ | `sqliteStorage(open)` | desktop processes, servers, the daemon | yes | Zero's `SQLiteStore` over any synchronous SQLite binding (`bun:sqlite`, `node:sqlite`); the SDK imports none itself, so it stays portable. One file per person and organisation in `directory`. `drop` wipes the store in place (its table dropped, the file vacuumed, the WAL truncated) and fails if anything is left; `remove`, if given, also deletes the files |
22
+ | `expoSQLiteStoreProvider()` | React Native | yes | Zero's expo-sqlite store |
23
+ | `memoryStorage()` | anywhere | no | Zero's memory store (`"mem"`) |
24
+
25
+ **Tauri's own SQLite**: not provided. Zero's SQLite store opens transactions with synchronous `BEGIN`/`COMMIT` on one connection, and `tauri-plugin-sql` offers only asynchronous calls over a connection pool, so it cannot back the store. The desktop host's webview uses IndexedDB, which WebKitGTK, WKWebView and WebView2 all provide; a native SQLite replica on desktop goes through the daemon sidecar instead, as the Rune host's does (LocalClient: the daemon's client core on `sqliteStorage`, [desktop-rune](../registry/desktop-rune.md)).
26
+
27
+ ## Operations
28
+
29
+ The store interface, as records: `info` (`{ kind, durable, platforms }`), and on a named store `get`, `has`, `put`, `del`, `commit`, `close` and `drop`. `put`, `del` and `commit` happen in a write transaction; `get` and `has` in a read or write transaction. Errors: `StoreClosed`, `StorageFailure`.
30
+
31
+ ## Guarantees
32
+
33
+ 1. **Transactions**: a write's changes are visible to it at once, to others on commit, and never if it is released without committing; many readers or one writer (a writer waits for readers).
34
+ 2. **Isolation by name**: one store per person and organisation (`connectSync` names it from the user and `orgId`), so two never share rows.
35
+ 3. **Durability**: a durable adapter keeps a store across closing it, and the replica reopened with no server to reach reads its rows from storage.
36
+ 4. **Policy holds in storage too**: a replica stores only rows its person may read in its organisation.
37
+
38
+ ## How an implementation is checked
39
+
40
+ `storageAdapterConformance({ adapters, system })` runs, for each adapter, the store checks (when it exposes its store provider: commit and abandon, readers and a waiting writer, isolation, durability across close, drop, a closed store) and the replica scenario against a real kernel and zero-cache: another person's org-visible write arrives, a private one never does, a second organisation's replica is a store of its own, and a durable replica reopened against an unreachable server reads the row back. Eloxiv's adapters run it in [`registry/test/storage-adapter.test.ts`](../../registry/test/storage-adapter.test.ts): SQLite over `bun:sqlite` (Bun) or `node:sqlite` (Node), IndexedDB over `fake-indexeddb` (standing in for a browser's; the browser's own IndexedDB holds the shell's replica in the Playwright suites), and memory. `expo-sqlite` runs the replica, offline included, in CI's React Native lane ([`tools/react-native/journey.ts`](../../tools/react-native/journey.ts)).
41
+
42
+ ## Not yet guaranteed
43
+
44
+ - **No OPFS adapter**: Zero has no OPFS store, and an OPFS SQLite store needs a synchronous file handle, which only a worker has.
45
+ - **No encryption at rest** of the replica beyond the platform's own (disk encryption, the browser profile).
@@ -0,0 +1,56 @@
1
+ # StorageBackend
2
+
3
+ Where the bytes of files live (decisions.md "Capability contracts"; ledger A-045, C-055). A capability the deployment chooses, never a module's: the [Files](files.md) contract keeps every file's metadata, attachment and authorisation in the kernel's tables and hands the backend opaque keys it made itself.
4
+
5
+ - Kind: capability. Version 1.0.0.
6
+ - Schema: [`packages/contracts/schema/contracts/StorageBackend.json`](../../packages/contracts/schema/contracts/StorageBackend.json) (source [`StorageBackend.ts`](../../packages/contracts/src/contracts/StorageBackend.ts)).
7
+ - Implementations: a local directory ([`LocalStorage.ts`](../../packages/kernel/src/files/LocalStorage.ts), development and tests) and any S3-compatible object store ([`S3Storage.ts`](../../packages/kernel/src/files/S3Storage.ts): AWS S3, MinIO, R2, Garage, rclone's `serve s3`), with Signature Version 4 written on web-standard crypto ([`SigV4.ts`](../../packages/kernel/src/files/SigV4.ts)). The in-process interface is `StorageBackendShape` ([`Storage.ts`](../../packages/kernel/src/files/Storage.ts)).
8
+ - Kit: `@eloxiv/testing/conformance/StorageBackend` ([source](../../packages/testing/src/conformance/StorageBackend.ts)).
9
+
10
+ ## Choosing a backend
11
+
12
+ `ELOXIV_STORAGE` (or `KernelConfig.storage`, or a layer in `KernelOptions.storage`):
13
+
14
+ | Value | Backend |
15
+ | --- | --- |
16
+ | `local:<directory>` | A local directory, for one kernel process. Objects are stored under the SHA-256 of their key, so no key names a path; each put writes a new version file and changes to one key run one at a time, so concurrent puts and reads always see one whole version |
17
+ | `s3://<bucket>?endpoint=<url>&region=<region>[&prefix=<p>][&pathStyle=false]` | An S3-compatible store; credentials in `ELOXIV_STORAGE_ACCESS_KEY_ID` and `ELOXIV_STORAGE_SECRET_ACCESS_KEY`. Path-style addressing unless `pathStyle=false` (AWS's virtual-hosted style). `prefix` keeps one deployment's keys apart in a shared bucket |
18
+
19
+ An app that installs the kernel's `filesModule` without a backend gets a local `.eloxiv/storage` directory in development and is refused in production.
20
+
21
+ ## Operations
22
+
23
+ Bodies are bytes in process; the JSON form carries them base64-encoded.
24
+
25
+ | Operation | What it does |
26
+ | --- | --- |
27
+ | `capabilities` | `signedUrls`, `multipart`, `ranges`: what the backend does beyond the core operations |
28
+ | `put` | Store an object, replacing any object at the key atomically (a reader sees the old or the new, whole) |
29
+ | `get` | The content, whole or an inclusive byte range (a range starting past the end is `StorageConflict`; one ending past it is cut) |
30
+ | `head` | The metadata: size, etag (changes with the content), content type, modification time |
31
+ | `delete` | Delete; deleting a missing object succeeds |
32
+ | `list` | Objects under a prefix in key (byte) order, a page at a time with a cursor; unfinished multipart uploads are not listed |
33
+ | `signedUrl` | A URL a client uses directly: `GET` (with response type and disposition overrides) or `PUT` of exactly `contentLength` bytes, or one multipart part. It works until it expires (1 s to 7 days) and cannot be revoked before |
34
+ | `createMultipart`, `uploadPart`, `listParts`, `completeMultipart`, `abortMultipart` | Multipart uploads: parts (1 to 10000) in any order, again on retry; `listParts` is how an upload resumes; completion assembles exactly the named parts in part order, each by the etag its upload returned; nothing is visible at the key before |
35
+
36
+ **Keys** are 1 to 1024 characters of `A-Z a-z 0-9 / _ . = -`, with no empty, `.` or `..` segment and no leading or trailing `/` (`STORAGE_KEY_PATTERN`). Every backend refuses any other key with `StorageInvalid` before touching anything, so a key cannot escape its backend.
37
+
38
+ **Errors:** `StorageNotFound`, `StorageConflict` (a part list that does not match, a range past the end), `StorageInvalid` (a bad key or part number, a missing capability), `StorageUnavailable` (unreachable, the deployment's credentials refused, with the store's status).
39
+
40
+ ## Guarantees
41
+
42
+ 1. Bytes come back exactly as stored; an object is replaced atomically.
43
+ 2. No key outside `StorageKey` is accepted; the local backend writes nothing outside its root.
44
+ 3. A multipart upload is invisible until completed, and completes only from the parts named with the etags they were uploaded with.
45
+ 4. A signed URL works for exactly what was signed (method, key, length, overrides) and only until it expires.
46
+ 5. A backend authorises nothing: the kernel issues keys and signed URLs only after its own policy checks ([Files](files.md)).
47
+
48
+ ## How an implementation is checked
49
+
50
+ `storageBackendConformance(name, start)` takes a subject: the backend, its minimum part size, and whether it replaces a part uploaded again with different content (`replacesParts: false` for a store that streams parts through, like rclone's; the same content again must always work). The kernel's runner, [`storage-backend.test.ts`](../../packages/testing/test/storage-backend.test.ts), runs it against the local backend, against the S3 backend talking to an **in-process S3 protocol fake** ([`S3Fake.ts`](../../packages/testing/src/fakes/S3Fake.ts), a stand-in that verifies every Signature Version 4 signature with its own implementation), and, where `rclone` is installed, against a real S3-compatible server (`rclone serve s3`). The signer matches AWS's published S3 examples ([`sigv4.test.ts`](../../packages/kernel/test/sigv4.test.ts)). No container runtime is needed.
51
+
52
+ ## Not yet guaranteed
53
+
54
+ - The S3 backend is proven against the fake and rclone's server, not against AWS S3 itself (no account is set up); CI runs the fake only.
55
+ - Server-side encryption, storage classes and object lock are not exposed.
56
+ - Files uses neither signed URLs nor direct uploads: every byte goes through the kernel's routes, which check each part and each download (see [Files](files.md)).