@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,173 @@
1
+ # Contracts
2
+
3
+ Each kernel service, capability and shell contract is published three ways:
4
+
5
+ - **Schema:** `packages/contracts/src/contracts/<Name>.ts` (`defineServiceContract`), emitted as JSON Schema to [`packages/contracts/schema/contracts/<Name>.json`](../../packages/contracts/schema/contracts) by `pnpm --filter @eloxiv/contracts emit`. Operations are described by their input, output and errors; in-process operations are described the same way, as the records they exchange.
6
+ - **Documentation:** a page here per contract: what it is for, every operation, its records and errors, the guarantees an implementation must give, how an implementation is checked, and what is not yet guaranteed.
7
+ - **Conformance kit:** `@eloxiv/testing/conformance/<Name>` ([`packages/testing/src/conformance`](../../packages/testing/src/conformance)): a function that registers Vitest tests against a subject the caller supplies. The Eloxiv kernel's own tests run every kit; another implementation can run the same suites.
8
+
9
+ `tools/done/test/contracts.test.ts` checks all three for every registered contract.
10
+
11
+ ## Kernel contracts published
12
+
13
+ | Contract | Page | Kit |
14
+ | --- | --- | --- |
15
+ | Invocation | [invocation.md](invocation.md) | `@eloxiv/testing/conformance/Invocation` |
16
+ | Db/Tx (`DbTx`) | [db-tx.md](db-tx.md) | `@eloxiv/testing/conformance/DbTx` |
17
+ | Outbox | [outbox.md](outbox.md) | `@eloxiv/testing/conformance/Outbox` |
18
+ | Audit | [audit.md](audit.md) | `@eloxiv/testing/conformance/Audit` |
19
+ | Sync | [sync.md](sync.md) | `@eloxiv/testing/conformance/Sync` |
20
+ | ModuleManifest | [module-manifest.md](module-manifest.md) | `@eloxiv/testing/conformance/ModuleManifest` |
21
+ | ActionRegistry | [action-registry.md](action-registry.md) | `@eloxiv/testing/conformance/ActionRegistry` |
22
+ | Actor | [actor.md](actor.md) | `@eloxiv/testing/conformance/Actor` |
23
+ | Directory | [directory.md](directory.md) | `@eloxiv/testing/conformance/Directory` |
24
+ | Workflow | [workflow.md](workflow.md) | `@eloxiv/testing/conformance/Workflow` |
25
+ | Scheduler | [scheduler.md](scheduler.md) | `@eloxiv/testing/conformance/Scheduler` |
26
+ | Approvals | [approvals.md](approvals.md) | `@eloxiv/testing/conformance/Approvals` |
27
+ | ActionConsent | [action-consent.md](action-consent.md) | `@eloxiv/testing/conformance/ActionConsent` |
28
+ | WorkItems | [work-items.md](work-items.md) | `@eloxiv/testing/conformance/WorkItems` |
29
+ | Notifications | [notifications.md](notifications.md) | `@eloxiv/testing/conformance/Notifications` |
30
+ | NotificationChannel | [notification-channel.md](notification-channel.md) | `@eloxiv/testing/conformance/NotificationChannel` |
31
+ | MachineIdentity | [machine-identity.md](machine-identity.md) | `@eloxiv/testing/conformance/MachineIdentity` |
32
+ | Ingress | [ingress.md](ingress.md) | `@eloxiv/testing/conformance/Ingress` |
33
+ | Release | [release.md](release.md) | `@eloxiv/testing/conformance/Release` |
34
+ | Readiness | [readiness.md](readiness.md) | `@eloxiv/testing/conformance/Readiness` |
35
+ | QuerySurface | [query-surface.md](query-surface.md) | `@eloxiv/testing/conformance/QuerySurface` |
36
+ | Settings | [settings.md](settings.md) | `@eloxiv/testing/conformance/Settings` |
37
+ | Flags | [flags.md](flags.md) | `@eloxiv/testing/conformance/Flags` |
38
+ | ModelProvider (capability) | [model-provider.md](model-provider.md) | `@eloxiv/testing/conformance/ModelProvider` |
39
+ | AgentRuntime | [agent-runtime.md](agent-runtime.md) | `@eloxiv/testing/conformance/AgentRuntime` |
40
+ | Memory | [memory.md](memory.md) | `@eloxiv/testing/conformance/Memory` |
41
+ | Delegation | [delegation.md](delegation.md) | `@eloxiv/testing/conformance/Delegation` |
42
+ | ContextAccounting | [context-accounting.md](context-accounting.md) | `@eloxiv/testing/conformance/ContextAccounting` |
43
+ | AgentResources | [agent-resources.md](agent-resources.md) | `@eloxiv/testing/conformance/AgentResources` |
44
+ | Metering (agent budgets and per connection) | [metering.md](metering.md) | `@eloxiv/testing/conformance/Metering` |
45
+ | Sharing | [sharing.md](sharing.md) | `@eloxiv/testing/conformance/Sharing` |
46
+ | Secrets | [secrets.md](secrets.md) | `@eloxiv/testing/conformance/Secrets` |
47
+ | Sandbox (and MAKE) | [sandbox.md](sandbox.md) | `@eloxiv/testing/conformance/Sandbox` |
48
+ | Connections | [connections.md](connections.md) | `@eloxiv/testing/conformance/Connections` |
49
+ | Files | [files.md](files.md) | `@eloxiv/testing/conformance/Files` |
50
+ | Search | [search.md](search.md) | `@eloxiv/testing/conformance/Search` |
51
+ | Ingestion | [ingestion.md](ingestion.md) | `@eloxiv/testing/conformance/Ingestion` |
52
+ | Progress | [progress.md](progress.md) | `@eloxiv/testing/conformance/Progress` |
53
+ | Versioning | [versioning.md](versioning.md) | `@eloxiv/testing/conformance/Versioning` |
54
+ | Telemetry (including analytics and error capture) | [telemetry.md](telemetry.md) | `@eloxiv/testing/conformance/Telemetry` |
55
+ | Privacy | [privacy.md](privacy.md) | `@eloxiv/testing/conformance/Privacy` |
56
+ | ResultRendering | [result-rendering.md](result-rendering.md) | `@eloxiv/testing/conformance/ResultRendering` |
57
+ | CollabDocument | [collab-document.md](collab-document.md) | `@eloxiv/testing/conformance/CollabDocument` |
58
+
59
+ ## Kernel seams
60
+
61
+ In-process TypeScript interfaces an app may implement itself (code, not data, so no JSON Schema); each names the kit that checks an implementation.
62
+
63
+ | Seam | Page | Checked by | Implementations |
64
+ | --- | --- | --- | --- |
65
+ | AuthProvider | [auth-provider.md](auth-provider.md) | the Actor kit's `sessions` (`@eloxiv/testing/conformance/Actor`) | Better Auth (default), the trusted proxy (`@eloxiv/testing/auth/TrustedProxyAuth`) |
66
+
67
+ ## Capability contracts published
68
+
69
+ | Contract | Page | Kit | Implementations |
70
+ | --- | --- | --- | --- |
71
+ | MailProvider | [mail-provider.md](mail-provider.md) | `@eloxiv/testing/conformance/MailProvider` | `microsoft-graph` (protocol fake only; no licensed test tenant yet), `google` (protocol fake, and the real service in CI with the exclusions in [connectors/google.md](../connectors/google.md)) |
72
+ | CalendarProvider | [calendar-provider.md](calendar-provider.md) | `@eloxiv/testing/conformance/CalendarProvider` | `microsoft-graph`, `google` (same) |
73
+ | DirectoryProvider | [directory-provider.md](directory-provider.md) | `@eloxiv/testing/conformance/DirectoryProvider` | `microsoft-graph`, `google` (same) |
74
+ | DocumentSource | [document-source.md](document-source.md) | `@eloxiv/testing/conformance/DocumentSource` | `microsoft-graph`, `google` (same) |
75
+ | Messaging | [messaging.md](messaging.md) | `@eloxiv/testing/conformance/Messaging` | the `slack` registry connector (against the Slack protocol fake and a real workspace) and the reference `acme` connector |
76
+ | StorageBackend | [storage-backend.md](storage-backend.md) | `@eloxiv/testing/conformance/StorageBackend` | the kernel’s local directory and S3-compatible backends (the S3 protocol fake in CI; rclone’s `serve s3` where installed) |
77
+ | Daemon | [daemon.md](daemon.md) | `@eloxiv/testing/conformance/Daemon` |
78
+ | DeviceControl | [device-control.md](device-control.md) | `@eloxiv/testing/conformance/DeviceControl` |
79
+
80
+ ## Shell contracts published
81
+
82
+ Headless: implemented without a UI framework in `@eloxiv/shell-core` (navigation, spaces, screen context, theme, locale, the Host interface; `@eloxiv/shell-core/web` is the web host) and `@eloxiv/client` (the SDK and the replica's storage adapters), so headless apps, the registry shell, the desktop host and tests share them. `@eloxiv/shell-core` is a package of its own so the client SDK stays the data SDK every app (headless ones and React Native included) needs, while only apps with a shell take the shell's model. The kernel imports none of it ([`kernel-headless.test.ts`](../../tools/done/test/kernel-headless.test.ts)).
83
+
84
+ | Contract | Page | Kit | Implementations |
85
+ | --- | --- | --- | --- |
86
+ | View | [view.md](view.md) | `@eloxiv/testing/conformance/View` | `shellRegistry` (`@eloxiv/shell-core`) |
87
+ | Slot | [slot.md](slot.md) | `@eloxiv/testing/conformance/Slot` | `shellRegistry` |
88
+ | Command | [command.md](command.md) | `@eloxiv/testing/conformance/Command` | `shellRegistry` |
89
+ | Space | [space.md](space.md) | `@eloxiv/testing/conformance/Space` | the kernel's `spacesModule`, `resolveSpaces` |
90
+ | ScreenContext | [screen-context.md](screen-context.md) | `@eloxiv/testing/conformance/ScreenContext` | `makeScreenContext`, `agent.send`'s `screen` |
91
+ | ThemeTokens | [theme-tokens.md](theme-tokens.md) | `@eloxiv/testing/conformance/ThemeTokens` | `themeCss` and friends; the registry `theme` item |
92
+ | Locale | [locale.md](locale.md) | `@eloxiv/testing/conformance/Locale` | `makeLocale` over Paraglide JS |
93
+ | ClientSDK | [client-sdk.md](client-sdk.md) | `@eloxiv/testing/conformance/ClientSDK` | `@eloxiv/client` |
94
+ | Host | [host.md](host.md) | `@eloxiv/testing/conformance/Host` | `webHost` (`@eloxiv/shell-core/web`), the desktop template's `desktopHost` |
95
+ | StorageAdapter | [storage-adapter.md](storage-adapter.md) | `@eloxiv/testing/conformance/StorageAdapter` | `@eloxiv/client/storage` (IndexedDB, SQLite, memory), `@eloxiv/client/expo-sqlite` |
96
+ | LocalClient | [local-client.md](local-client.md) | `@eloxiv/testing/conformance/LocalClient` | `@eloxiv/daemon` with a `clientApp`, over `ClientRuntime` (`@eloxiv/client/runtime`) |
97
+
98
+ ### Running the shell kits
99
+
100
+ The View, Slot and Command kits take a factory that builds the implementation over module contracts; they pass the **shell fixture** ([`atlas/contract.ts`](../../packages/testing/src/conformance/atlas/contract.ts): two modules with views, slots, contributions and commands). The ScreenContext kit takes the same kind of factory and, optionally, an agent subject (built on `AgentSubject`). The Space kit takes an `InboxSubject` serving the **spaces conformance app** ([`atlas/app.ts`](../../packages/testing/src/conformance/atlas/app.ts)) and the client resolution function. ThemeTokens and Locale take their functions (Locale compiles its own catalog with Paraglide JS). Host takes a harness (start, restart, deliver a link, storage at rest, the served version). ClientSDK and StorageAdapter run against a real kernel and zero-cache serving an app with one synced, policy-filtered write. Runners: `packages/testing/test/{shell-navigation,space,screen-context,locale,host-web}.test.ts` and `registry/test/{client-sdk,storage-adapter,theme-tokens,host-desktop}.test.ts`.
101
+
102
+ ## Running the kernel kits
103
+
104
+ The Files, Search and Ingestion kits share a `FilesSubject` ([`FilesSubject.ts`](../../packages/testing/src/conformance/FilesSubject.ts)): a kernel serving the archive conformance app ([`conformance/archive`](../../packages/testing/src/conformance/archive): searchable documents that accept and ingest files, shared per record, and author-only notes) with a scanner that flags the EICAR test string; the Eloxiv kernel's is [`FilesReference.ts`](../../packages/testing/src/conformance/FilesReference.ts), run by `packages/testing/test/{files,search,ingestion}.test.ts`. The StorageBackend kit takes a backend directly (`storage-backend.test.ts`).
105
+
106
+ The CollabDocument kit takes a `CollabSubject` ([`CollabSubject.ts`](../../packages/testing/src/conformance/CollabSubject.ts)): a kernel serving the collab conformance app ([`conformance/pad`](../../packages/testing/src/conformance/pad)) with its WebSocket transport; the Eloxiv kernel's is [`CollabReference.ts`](../../packages/testing/src/conformance/CollabReference.ts), run by `packages/testing/test/collab-document.test.ts`.
107
+
108
+ The Daemon and DeviceControl kits share a `DaemonHarness` ([`Daemon.ts`](../../packages/testing/src/conformance/Daemon.ts)): a kernel serving the workshop app ([`conformance/workshop`](../../packages/testing/src/conformance/workshop)) and daemons started in process or as their own process with the fake harness; the Eloxiv reference is [`DaemonReference.ts`](../../packages/testing/src/conformance/DaemonReference.ts), run by `packages/testing/test/daemon.test.ts`.
109
+
110
+
111
+ The ModuleManifest, ActionRegistry, Actor, Directory, Workflow, Scheduler, MachineIdentity and Ingress kits each take their own subject or harness, described on their pages (MachineIdentity and Ingress run over HTTP against the desk fixture, [`conformance/desk`](../../packages/testing/src/conformance/desk)); their runners are `packages/testing/test/conformance-{manifest,action-registry,directory}.test.ts`, `workflow.test.ts`, `scheduler.test.ts`, `machine-identity.test.ts` and `ingress.test.ts`. So does the Release kit: its subject (`ReleaseSubject` in [`Release.ts`](../../packages/testing/src/conformance/Release.ts)) sets up fresh databases with the fixture module `stage` and serves the fixture app below with a minimum client version; the Eloxiv kernel's is [`ReleaseReference.ts`](../../packages/testing/src/conformance/ReleaseReference.ts), run by `packages/testing/test/release.test.ts`. The Readiness kit takes a `ReadinessSubject`: a running `KernelSubject` (below) and a way to start a kernel whose build is ahead of its database; its runner is `packages/testing/test/readiness.test.ts`. The Invocation, DbTx, Outbox, Audit and Sync kits share one subject: a running kernel serving the **conformance fixture app** ([`packages/testing/src/conformance/fixture`](../../packages/testing/src/conformance/fixture)), on PostgreSQL. The app has two modules:
112
+
113
+ - **`docs`**: documents with an owner, an organisation, a lock and per-record `read` and `edit` sharing grants, with a Cedar policy ([`policy.cedar`](../../packages/testing/src/conformance/fixture/docs/policy.cedar)) and migrations. Its actions each exercise one guarantee, many by misbehaving (renaming more than their target, truncating, leaving their role, crashing after writing). Its handlers check no permissions of their own. Its subscribers record what they saw, one of them fails while a fault switch row is present, and one reaches across organisations.
114
+ - **`peer`**: a second module that records a reference to every document created in `docs`, through the outbox, with the role it ran as.
115
+
116
+ The kernel must run an approval stage that requires approval for exactly `docs.signOff` and `docs.archive` (`APPROVAL_REQUIRED`).
117
+
118
+ The subject (`KernelSubject` in [`Subject.ts`](../../packages/testing/src/conformance/Subject.ts)) is what an implementation supplies; none of it reaches into the Eloxiv kernel's internals:
119
+
120
+ | Member | What it does |
121
+ | --- | --- |
122
+ | `url` | The kernel's base URL (`/health`, `/ready`, `/release`, the surfaces) |
123
+ | `invoke(call)` | Invocation.invoke with the call's bearer token, `x-eloxiv-org` and idempotency key; returns the JSON result envelope or the standard error |
124
+ | `user`, `leave`, `setEmail` | Directory controls: a password user `<name>@example.com` in the given organisations (optionally with roles), signed in; removing a membership; changing the email a policy reads |
125
+ | `share`, `unshare` | A per-record sharing grant and its revocation, through the implementation's sharing service |
126
+ | `sql`, `rolledBack`, `barrier` | Superuser SQL on the app's database (the fixture's tables and the catalogue), statements in a rolled-back transaction (used to assume module roles), an advisory-lock barrier the fixture's gated handlers wait on |
127
+ | `kernelRole()`, `privateTables` | `current_user` on a connection from the kernel's own pool; the tables holding the kernel's own state (`auditLog`, and `others` such as the invocation context, memberships, users and sessions), which the kits check no module role can reach |
128
+ | `audit(filter)` | Audit.list |
129
+ | `outbox.events(filter)`, `outbox.retry(id)`, `outbox.dispatch()` | Outbox.events, Outbox.retry and one Outbox.dispatch pass (its output unchanged); the kernel's dispatcher also runs on its own |
130
+ | `outbox.deadLetters(filter)`, `outbox.manage(token, operation, input, org?)` | Outbox.deadLetters, and an administrator operation (`listDeadLetters`, `retryDeadLetter`, `discardDeadLetter`) as a signed-in user, returning the output or the standard error |
131
+ | `sync.query`, `sync.checkSchema`, `sync.serve` | The sync query endpoint for a caller (the query's entry in the endpoint's response, unchanged, or 401), Sync.checkSchema, and starting a kernel with another sync configuration |
132
+
133
+ The Eloxiv kernel's subject is [`Reference.ts`](../../packages/testing/src/conformance/Reference.ts) (`startReferenceKernel`): an in-process kernel on a fresh database. Its runners are `packages/testing/test/{invocation,dbtx,outbox,audit,sync-scope}.test.ts`; `registry/test/isolation.test.ts` runs the DbTx kit's isolation checks against the registry's own modules.
134
+
135
+ ```ts
136
+ import { invocationConformance } from "@eloxiv/testing/conformance/Invocation"
137
+
138
+ invocationConformance(() => startMyKernel()) // resolves to a KernelSubject serving the fixture app
139
+ ```
140
+
141
+ ### The inbox kits
142
+
143
+ The Approvals, ActionConsent, WorkItems and Notifications kits share another subject, `InboxSubject` ([`InboxSubject.ts`](../../packages/testing/src/conformance/InboxSubject.ts)): a running kernel serving the **inbox conformance app** ([`purchases/app.ts`](../../packages/testing/src/conformance/purchases/app.ts)): the `purchases` fixture (orders with approval rules, a consent-marked `purchases.wire`, a work-item source and a subscriber that notifies) beside the kernel's `inboxModules`, delivering system email to an SMTP server the subject runs. Its members: directory controls (users with roles, groups, leaving), `invoke` on any surface (in process, RPC, HTTP, MCP, agent tools) with any credential and extra headers, agent sessions, superuser SQL, the audit log, the sync endpoint and the rows its scoped query selects, the email received, `preview`, `deliveries` and following an unsubscribe link.
144
+
145
+ The Eloxiv kernel's subject is [`InboxReference.ts`](../../packages/testing/src/conformance/InboxReference.ts) (`startInboxReference`), run by `packages/testing/test/{approvals,action-consent,work-items,notifications}.test.ts`. The Sharing kit takes the same `InboxSubject`, serving the **sharing conformance app** instead ([`library/app.ts`](../../packages/testing/src/conformance/library/app.ts): books shared per record, pages reached from their book, the inbox modules and the `sharing` module); the kernel's runner is `packages/testing/test/sharing.test.ts` (`startInboxReference({ app: sharingApp })`). The NotificationChannel kit takes a channel and the SMTP server it delivers to (`packages/testing/test/notification-channel.test.ts`).
146
+
147
+ ### The platform kits
148
+
149
+ The QuerySurface, Settings and Flags kits share `PlatformSubject` ([`PlatformSubject.ts`](../../packages/testing/src/conformance/PlatformSubject.ts)): a running kernel serving the **platform conformance app** ([`crm/app.ts`](../../packages/testing/src/conformance/crm/app.ts)): the `crm` fixture (deals published as `crm.deals`, an unpublished note table, a module function, settings at every scope, two flags, and `crm.peek`, which returns what `ctx.settings` and `ctx.flags` give) and `team` (profiles published as `team.members`), beside the kernel's `queryModule`, `settingsModule` and `flagsModule` and their sync tables, with `crm.region` and `crm.limit` configured at the app and module levels and a 1.5 s query timeout. Its members: directory controls (users with roles, roles, groups joined and left), `invoke` on any surface, superuser SQL, the audit log, the sync endpoint with arguments and the rows its scoped query selects, `configure` (a deployment administrator's settings call) and `settingProblems` (what the implementation finds with extra setting declarations).
150
+
151
+ The Eloxiv kernel's subject is [`PlatformReference.ts`](../../packages/testing/src/conformance/PlatformReference.ts) (`startPlatformReference`), run by `packages/testing/test/{query-surface,settings,flags}.test.ts`.
152
+
153
+ ### The agent kits
154
+
155
+ The AgentRuntime, Memory, Delegation, ContextAccounting, AgentResources and Metering kits share a subject, `AgentSubject` ([`AgentSubject.ts`](../../packages/testing/src/conformance/AgentSubject.ts)): a running kernel serving the **agent conformance app** ([`notebook/app.ts`](../../packages/testing/src/conformance/notebook/app.ts): the `notebook` fixture, whose pages are written only through actions, with a destructive `notebook.tear`, a permission-gated `notebook.seal`, a published view and a skill with evals; the kernel's agent module; the inbox modules), whose model provider is the scripted one from `@eloxiv/testing` with a script the kit sets. Its members: people (with roles), the script and the model's recorded calls, sending messages and following runs over HTTP, the context x-ray, children, actions as a person, the agent's read routes, completions, sync rows, superuser SQL and the audit log. The Memory and ContextAccounting kits need small budgets (`MEMORY_SUBJECT_SETTINGS`, `CONTEXT_SUBJECT_SETTINGS`). The Eloxiv kernel's subject is [`AgentReference.ts`](../../packages/testing/src/conformance/AgentReference.ts) (`startAgentReference`), run by `packages/testing/test/agent-{runtime,memory,delegation,context,resources,metering}.test.ts`. The ModelProvider kit takes a provider and, optionally, an agent subject (`packages/testing/test/model-provider.test.ts`).
156
+
157
+ ### The platform-services kits
158
+
159
+ The Progress, Versioning, Telemetry, Privacy and ResultRendering kits share a subject, `ServicesSubject` ([`ServicesSubject.ts`](../../packages/testing/src/conformance/ServicesSubject.ts)): a running kernel serving the **platform-services conformance app** ([`studio/app.ts`](../../packages/testing/src/conformance/studio/app.ts)): `journal` (entries with record history, a restore action, renderers, a background import reporting progress, analytics events and a deliberate crash), `tasks` (two user fields, anonymised on erasure), `billing` (retained on erasure, with a reason) and `mailbox` (connector data), beside the kernel's `progress`, `privacy`, `versioning`, `telemetry` and `settings` modules and the inbox modules, with consent regions for the EEA (opt-in) and the United States (opt-out). The subject exports its telemetry to protocol fakes it runs ([`fakes/TelemetryFakes.ts`](../../packages/testing/src/fakes/TelemetryFakes.ts): an OTLP collector, a Sentry envelope endpoint, a PostHog batch endpoint) and has controls for setup with a changed module, the problems an app would be refused for, a person's Connection, a further data-subject source (files) it can hold, superuser SQL and SQL as a database role, the sync endpoint, the audit log and the agent surface's raw tool result. The Eloxiv kernel's subject is [`ServicesReference.ts`](../../packages/testing/src/conformance/ServicesReference.ts) (`startServicesReference`), run by `packages/testing/test/{progress,versioning,telemetry,privacy,result-rendering}.test.ts`.
160
+
161
+ ## Capability contracts
162
+
163
+ A capability contract (`kind: "capability"`) is implemented by connectors (registry items of kind `connector`, see [docs/connectors](../connectors)) over a kernel [Connection](connections.md). The connector never sees a token: it makes requests through the `ProviderHttp` the kernel gives it, and the kernel handles membership, backpressure, refresh and the meaning of 401, 403, 429 and 503. What they all share is in [`Capability.ts`](../../packages/contracts/src/contracts/Capability.ts):
164
+
165
+ - **The standard error set**, on every operation: `Unauthorized` (the Connection needs reauthorisation; already refreshed once), `Forbidden` (`missingScopes`, and a `consent` offer of `connections.reconnect`), `NotFound`, `RateLimited` (`retryAfterMs`, `retryAt`, `reason`), `Conflict`, `Unavailable`, `InvalidCursor`, and `InvalidInput` for a malformed request.
166
+ - **Per-operation scopes**: each operation names the abstract scopes it needs (`mail.read`, `calendar.write`, ...; the `scopes` of each operation in the JSON Schema). A connector maps each to its provider's scopes (`CapabilityDefinition.scopes`); `connections.connect` with `capabilities: ["mail"]` asks for them, and a 403 reports the missing ones.
167
+ - **Capability flags**: what a connector supports (`MailFlags`, `CalendarFlags`, ...), read with the bound capability.
168
+ - **Cursor-based delta sync**: `delta({ cursor, pageSize? })` returns `{ changes, cursor, hasMore, reset }`. `cursor: null` is a full sync (every item in scope as an upsert; the first page has `reset: true`). Changes are `{ kind: "upsert", id, item }` or `{ kind: "delete", id }`. The cursor is opaque; a consumer commits it with the page's changes and resumes from the last committed cursor, and fetching the same cursor again returns the same page. `InvalidCursor` means start again from null. The kernel's [sync engine](connections.md#sync) does this durably.
169
+ - **A write is never hidden.** A refusal (`RateLimited`, `NotFound`, `Forbidden`, `Conflict`, `InvalidInput`, ...) means the provider did nothing, and callers rely on it: the kernel runs a rate-limited external effect again ([Invocation](invocation.md#external-effects)), and a caller may repeat a refused call. So an operation that makes a request after one of its writes succeeded never answers that request's refusal as its own. Either its write is its last request (every external operation's is), or it answers from what the write answered when a later request fails (Gmail's `createDraft` reads the draft back, and reports the draft as written if that read fails), or it fails `Unavailable` ("it may have acted"; the connectors' `afterWrite`: Gmail's `updateMessage` reading the message back after relabelling it, Graph's `updateMessage` moving a message after marking it read). An operation that fails before it sends anything that changes the provider (a read it needs first) says so: `Unavailable` with `dispatched: false` means nothing was done and the operation is safe to run again, so the kernel runs such an external effect again as it does a rate-limited one (Gmail's `sendMessage` checking the send-as addresses before a send as an alias). The MailProvider and CalendarProvider kits check it against the fakes: with every request after an operation's write refused (`controls.throttleAfterWrite`), each write operation answers or fails `Unavailable`, never with a refusal.
170
+
171
+ A capability kit takes a `ProviderHarness` ([`CapabilityKit.ts`](../../packages/testing/src/conformance/CapabilityKit.ts)): the connector bound to a kernel and a test account, a `connect` that runs the consent flow, `call` for operations, item `seeds` (create, change, remove an item at the provider, as another client would; optionally confined to a label, calendar or folder of their own with `deltaInput` and `folderId`, or, where the delta cannot be confined (a drive's delta is the whole drive) on a shared account, compared over the items the run seeded only (`owns`), and with `settle`, a bounded wait for a real service's eventually consistent change feed, called before each delta compared exactly; or, for an account that may only read, `ExistingItems`, the ids already there, on which the delta checks run instead), and optional `controls` that only a protocol fake has (expire access tokens, revoke refresh tokens, revoke scopes, throttle with Retry-After, throttle the requests after an operation's write, expire cursors, count requests and refreshes). Every kit runs the shared delta checks (exact changes since a cursor including deletes; resume after a crash compared with an uninterrupted sync; InvalidCursor and recovery) and Connection checks (401 refresh-once; single-flight refresh; a failed refresh to `needs-reauth`, notification and fail-fast; 403 with missing scopes and no refresh; 429 and 503 Retry-After and the shared cooldown; merged scopes with another capability), and validates every output against the contract's schema. Against a real account (`startConnectorReference` replaced by `importConnection` and `liveHarness` in [`LiveConnection.ts`](../../packages/testing/src/conformance/LiveConnection.ts)) the checks that need the controls or the consent flow are skipped, every error is redacted (`redactor`: the account's secrets and OAuth tokens), and the kernel runs the connector with `patientConnector`'s limits (12 attempts within 120 s a request), so a shared account's rate limits are waited out request by request; an operation is never run again as a whole.
172
+
173
+ The protocol fakes ([`packages/testing/src/fakes`](../../packages/testing/src/fakes)) are local HTTP servers implementing the subset of each provider's API the connectors use, following the providers' documentation. A result against a fake is "proven against a protocol fake, not the real service".
@@ -0,0 +1,92 @@
1
+ # ActionConsent
2
+
3
+ A person's consent to what an agent does for them: an agent's call to an action marked `consent` is held, bound to its exact prepared input, until the person approves it; the person may remember the permission for the agent session or always, and revoke it. Separate from [Approvals](approvals.md) (business approval by someone else), and at the same stage of the invocation path:
4
+
5
+ ```
6
+ identity -> policy -> [consent, then business approval] -> idempotency -> execute -> audit -> outbox
7
+ ```
8
+
9
+ - Kind: kernel service. Version 1.4.0 (1.1.0: `reject` withdraws an approved consent that has not been used; a one-time consent is used up as the call it approved commits, and authorises nothing that call queues; 1.2.0 adds consent for each call; 1.3.0 adds `rejectPending`, a notification's Reject, and the person's read of one request, `get`; 1.4.0: each request records `title`, what people see the held call's action called as it was when held, returned by `get` and used in its work item and notifications; for a MAKE module's action the kernel's label of its id (the module's id first, never cut, then the readable words of the action (`mk_todos: Urgent`, only the words cut to fit 80 characters)), never the module's own title, and clients compute it from the id when rendering a stored request or event, and a title is one line of at most 80 characters wherever a subject uses it; the decisions and `get` are offered on no agent surface (`exposure: { agent: false, mcp: false }`), refused by name as before).
10
+ - Schema: [`packages/contracts/schema/contracts/ActionConsent.json`](../../packages/contracts/schema/contracts/ActionConsent.json) (source [`ActionConsent.ts`](../../packages/contracts/src/contracts/ActionConsent.ts)).
11
+ - Implementation: the consent stage in [`packages/kernel/src/Approvals.ts`](../../packages/kernel/src/Approvals.ts); agent sessions in [`Identity.ts`](../../packages/kernel/src/Identity.ts); the kernel-provided `consent` module ([`inbox/consent.ts`](../../packages/kernel/src/inbox/consent.ts)).
12
+ - Kit: `@eloxiv/testing/conformance/ActionConsent` ([source](../../packages/testing/src/conformance/ActionConsent.ts)), run by [`packages/testing/test/action-consent.test.ts`](../../packages/testing/test/action-consent.test.ts).
13
+
14
+ ## Marking an action
15
+
16
+ `defineAction({ ..., consent: true })`. It defaults to `hints.destructive`, so a destructive action needs consent unless it says `consent: false`.
17
+
18
+ `consent: "each-call"` is consent that no remembered permission covers: every agent call needs the person's approval of that exact call, even after they approved an earlier one with `remember: "always"` or for the session (the approval itself still runs its call once). For actions whose calls differ in kind, not just in input: each message an agent sends is a new message. The manifest publishes it as `consentEachCall: true`. An action that declares a capability operation others see (`effect: "external"`) must need consent, either kind ([Invocation](invocation.md#external-effects)). The manifest and the action registry publish the flag (`consent` in the JSON manifest and the action descriptor). An app with consent-marked actions installs the kernel's `inboxModules` (the kernel refuses to start otherwise).
19
+
20
+ ## Who is an agent
21
+
22
+ Consent is about an agent acting for the person, so it applies to **agent-originated** calls only. The kernel decides origin from the surface and the credential, never from anything the caller sends:
23
+
24
+ | The call arrives | Origin |
25
+ | --- | --- |
26
+ | On the agent tools surface (`AgentTools.toolsFor`) | agent |
27
+ | On MCP (`/mcp`): MCP clients are agents | agent |
28
+ | With an **agent session** credential, on any surface (RPC, HTTP, MCP, agent tools) | agent |
29
+ | With the person's own session, on RPC, HTTP or in process | person: never held |
30
+ | From a workflow or a scheduled run (an execution identity) | system: never held, unless an agent set it up: a schedule an agent created runs as the agent (`agentSession: "schedule:<id>"`), so its calls are agent-originated and held like the agent's own |
31
+
32
+ An **agent session** is a bearer credential the kernel issues for an agent acting for one person in one organisation (`issueAgentSession`; the daemon and external agents use one). It stays agent-originated on every surface, so calling the same action over RPC or HTTP with it is held the same way: switching surfaces does not bypass consent. No header changes origin or session: `x-eloxiv-origin`, `x-eloxiv-agent` or a header naming another session are ignored, so a client can neither make an agent's call look like the person's nor borrow another session's remembered permission. The handler sees the origin as `ctx.origin`.
33
+
34
+ Consent is a person's: an agent's call to a consent-marked action acting as anyone but a person (a **service principal's** credential an agent holds, the system actor, the kernel's own identities such as `$scheduler`) has no person to ask, so it is refused (`Forbidden`, audited `denied`), never held and never run.
35
+
36
+ The **session** a consent and a session-scoped permission are bound to is the credential's: `agent:<agent session id>`, or `person:<session id>` for the person's own session on the agent tools surface or MCP.
37
+
38
+ ## Operations
39
+
40
+ | Operation | Input | Output | Errors |
41
+ | --- | --- | --- | --- |
42
+ | `check` | the call (the consent stage of the invocation path) | `held` | `ConsentRequired` (with `consentId`) |
43
+ | `approve` | action `consent.approve`: `id`, optional `remember` (`once`, `session`, `always`) | `id`, `status`, `grantId` | the standard error set |
44
+ | `reject` | action `consent.reject`: `id` | `id`, `status`, `grantId` | the standard error set |
45
+ | `rejectPending` | action `consent.rejectPending`: `id` | `id`, `status`, `grantId` | the standard error set (`InvalidInput` when the request is not pending) |
46
+ | `get` | action `consent.get`: `id` | `id`, `status`, `action`, `conversationId` | the standard error set (`InvalidInput` when it is not the caller's request in the organisation) |
47
+ | `revoke` | action `consent.revoke`: `id` (a remembered permission) | `id` | the standard error set |
48
+ | `issueAgentSession` | `label`, optional `ttlMs` (for a member, in one organisation) | `AgentSession` with its `token` | `Forbidden` (not a member) |
49
+ | `revokeAgentSession` | `id` | nothing | none |
50
+
51
+ `rejectPending` rejects only a pending consent: an approved one (decided in chat or on another device) is refused with `InvalidInput` and stays approved. The status is read with the request's row locked (the invocation path locks an action's declared target before its handler), so an approval that commits first is seen and one that comes after waits and then finds the request rejected. A notification's Reject uses it ([Notifications](notifications.md#decisions-from-a-notification)); withdrawing an approval stays `reject`. It is a distinct action rather than an option of `reject` so that a kernel without it (an earlier revision during a rolling deploy) refuses the call as an unknown action, where an option it did not know would be dropped and the call would withdraw the approval. It is refused to agent-originated callers and not offered on the agent tools surface or MCP.
52
+
53
+ `get` is the person's read of one of their own consent requests in the organisation: its `status`, the `action` it holds, and `conversationId`, the conversation of the agent run waiting on it (null when no run waits on it now). It reads the request itself, not its work item, so a work item the person dismissed or that was reassigned does not hide a request that still waits for them. It is served by the kernel (the consent module's role cannot read the agent's runs), refused to agent-originated callers, and not offered on the agent tools surface or MCP.
54
+
55
+ `approve`, `reject` and `rejectPending` emit `consent.decided` (`id`, `status`) through the outbox. `approve`, `reject`, `rejectPending` and `revoke` are actions of the kernel-provided `consent` module, on every surface, audited, and **refused to agent-originated callers** (`Forbidden`): an agent can never decide consent for the person. In the kernel, `issueAgentSession` and `revokeAgentSession` are `Identity` methods; a surface for people to issue and list their agent sessions is not built yet.
56
+
57
+ ## What happens
58
+
59
+ 1. An agent-originated call to a consent-marked action passes if:
60
+ - the same call (idempotency key and input) already ran: its retry replays; or
61
+ - the person approved **this exact call**: a consent for the same person, organisation, action, session and input hash, which the call then uses up (`status: used`). It is used up by its first execution whatever it remembered, so a permission it also recorded never lets that approval run a second time; or
62
+ - the person remembered the permission: `always`, or `session` for the session the call came from, as it stands at the call (a revoked permission no longer applies from the moment its revocation commits).
63
+ 2. Otherwise it is held: a consent request (`pending`, the prepared input and its hash, the session), a work item for the person (source `consent.requests`) and a notification (category `consent.requested`, email template `consent.requested`), and `ConsentRequired` with the consent's id. The audit record's outcome is `approval-required` with error tag `ConsentRequired`. Retrying the same held call (any key, same input and session) returns the same consent; with an idempotency key, the consent's id derives from the key and input.
64
+ 3. The person approves (`remember: once` by default) or rejects. Approving closes the work item and, with `session` or `always`, records a remembered permission scoped to the person, organisation and action (and session). The agent's next attempt of the exact call runs once. A retry of a rejected call (same key and input) is `Forbidden`.
65
+ 4. `revoke` ends a remembered permission: the next agent call is held again. It also withdraws the person's approved calls in the permission's scope (the same action, and for a `session` permission the same session) that have not run yet (`status: revoked`): none of them runs, a retry under the approved call's key is `Forbidden`, and a new call asks again.
66
+
67
+ ## Records
68
+
69
+ - **`Consent`**: `id`, `orgId`, `userId`, `action`, `input`, `inputHash`, `session`, `status` (`pending`, `approved`, `rejected`, `used`, `revoked`), `createdAt`, `decidedAt`.
70
+ - **`ConsentGrant`** (a remembered permission): `id`, `orgId`, `userId`, `action`, `scope` (`session`, `always`), `session`, `createdAt`, `revokedAt`.
71
+ - **`AgentSession`**: `id`, `userId`, `orgId`, `label`, `token` (returned once; stored as its sha256), `expiresAt`.
72
+
73
+ The person syncs nothing of this by default; the `consent` module's entities are readable by their owner (add them to the app's sync schema to show them).
74
+
75
+ ## Guarantees
76
+
77
+ 1. A person's own calls are never held; an agent's call to a consent-marked action never runs without a remembered permission or the person's approval of that exact input and session.
78
+ 2. An approval is used once, by the exact prepared call it approved, whatever scope it remembered; revoking a permission withdraws the approvals in its scope that have not run.
79
+ 3. Origin and session come from the credential and the surface only; an agent session is agent-originated on every surface.
80
+ 4. Only the person decides: consent decisions by agent-originated callers are refused on every surface.
81
+ 5. A one-time approval is used up by the call it approved, as that call commits (a call that fails leaves it approved for the agent's retry; a replay uses nothing). Until then it can be withdrawn: `consent.reject` accepts an approved consent that has not been used, so an agent's call the person approved and that is now waiting for a business approval is refused when that approval executes ([`packages/testing/test/authority-chain.test.ts`](../../packages/testing/test/authority-chain.test.ts), "a one-time consent stands until the call it approved runs").
82
+ 6. Remembered permissions are scoped to person, organisation, action (and session), consulted on later calls, and revocable. Revoking one also withdraws an agent's call it (or the approval that remembered it) let through to a business approval that has not executed: that call is refused when approved ([Approvals](approvals.md), guarantee 4c). The consent a call runs under (the permission, or the one-time approval) is a link of its authority chain ([Invocation](invocation.md#authority)), asserted inside the call's transaction and recorded for the work it queues (a schedule, an approval request): a revocation either waits for a call that holds the permission, or commits first and refuses it, and work queued under a permission stops once it is revoked (`packages/testing/test/authority-chain.test.ts`).
83
+ 7. An agent's consent-marked call acting as anyone but a person (a service principal, the system actor) is refused, not held (`packages/testing/test/provenance.test.ts`, "refuses, never holds, an agent's consent-marked call made as the system actor"; `packages/testing/test/surfaces-property.test.ts`, "refuses, and never holds, an agent's consent-marked call made with a service principal's credential").
84
+
85
+ ## How an implementation is checked
86
+
87
+ `actionConsentConformance(start)` registers, against the inbox conformance app's `purchases.wire` (destructive, so consent-marked): a person's own calls on three surfaces run; an agent's call is held with its input hash, a work item, a notification and the audit record; the same held call asks once; an agent cannot approve (agent tools, MCP, agent session over RPC and HTTP); an approved call runs once on the agent's retry, replays after, and a new input is held again; `always` lets later calls through on agent tools, MCP and an agent session over RPC, an agent cannot revoke it, revoking restores the hold; an approval that remembered a session permission is used by its first execution, so after revoking the same input is held again; revoking withdraws approved, unexecuted calls in the permission's scope (and only there); an agent session is held on RPC and HTTP, and `session` covers only that session; spoofed origin and session headers change nothing; a rejected call never runs and its retry is refused; a revoked agent session no longer authenticates.
88
+
89
+ ## Not yet guaranteed
90
+
91
+ - **Approval of a held call needs the agent to retry it.** The kernel does not run the held call itself on approval (business approvals do). The kernel's agent runtime does the retry: approving or rejecting emits `consent.decided` (the consent's id and outcome), which resumes the run waiting on it, and the run re-issues the exact call once ([AgentRuntime](agent-runtime.md)). An agent outside the kernel (MCP, an agent session) retries itself.
92
+ - **People cannot list or end their agent sessions** through a surface yet; agent runtimes (the daemon, MachineIdentity's OAuth flow) will issue them.
@@ -0,0 +1,85 @@
1
+ # ActionRegistry
2
+
3
+ Kind: kernel service. Version 1.2.0 (1.0.1: the agent tool's input is object-rooted, as MCP's; 1.1.0: `exposure`, the surfaces that offer an action; 1.2.0: `title`, what people see an action called, and an agent session's credential on an API transport reaches only actions the agent surface offers too). Schema: [`packages/contracts/schema/contracts/ActionRegistry.json`](../../packages/contracts/schema/contracts/ActionRegistry.json). Source: [`packages/contracts/src/Projection.ts`](../../packages/contracts/src/Projection.ts), [`contracts/ActionRegistry.ts`](../../packages/contracts/src/contracts/ActionRegistry.ts); kernel implementation in [`packages/kernel/src/Registry.ts`](../../packages/kernel/src/Registry.ts).
4
+
5
+ ## Purpose
6
+
7
+ One action registry is the source of truth (decisions.md, Architecture). Every installed module's actions are listed and looked up here, and one action definition is projected into the schema each surface publishes: the typed client over Effect RPC, `POST /api/actions/<action>` with its OpenAPI document, MCP tools at `/mcp`, and agent tools. Because every surface is derived from the same definition, a caller sees the same input schema and the same result everywhere.
8
+
9
+ Every surface takes the action's input as raw JSON documented with the action's input schema (the invocation path decodes and audits it), and returns the result envelope `{ kind: "output", output }` or, for an idempotent replay, `{ kind: "replay", receipt }`.
10
+
11
+ ## Operations
12
+
13
+ ### `list`
14
+
15
+ Input `{}`. Output every registered action as an `ActionDescriptor`, sorted by name. Never fails.
16
+
17
+ ### `lookup`
18
+
19
+ Input `{ name }`. Output the action's `ActionDescriptor`. Fails with `UnknownAction` if no installed module declares it (the kernel's `Registry.lookup` returns `undefined`).
20
+
21
+ ### `project`
22
+
23
+ Input `{ name }`. Output a `SurfaceProjection`: what each surface publishes for the action. Fails with `UnknownAction` (the kernel returns `undefined`).
24
+
25
+ | Surface | Published | Value |
26
+ | --- | --- | --- |
27
+ | RPC | `tag`, `payload`, `success`, `error` | the action name, its input, its result envelope, the standard error set (`InvocationError`) |
28
+ | HTTP | `method`, `path`, `requestBody`, `response` | `POST`, `/api/actions/<action>`, its input, its result envelope (the 200 response) |
29
+ | MCP | `name`, `description`, `inputSchema`, `outputSchema` | the tool name (`hello.greet` becomes `hello_greet`), the action's description, its input (MCP requires an object root, so an input schema without one, such as `Schema.Struct({})`'s `{ not: { type: "null" } }`, is wrapped as `{ type: "object", allOf: [input] }`: `mcpToolInput`), its result envelope |
30
+ | Agent | `name`, `description`, `inputSchema` | the tool name, description and input, object-rooted as MCP's (model providers refuse a function whose parameters are not an object; OpenAI refused every request over `Schema.Struct({})` inputs) (agent tools return `{ ok, output }` with the envelope as `output`) |
31
+
32
+ ## Records
33
+
34
+ - `ActionDescriptor`: `name`, `module`, `title` (what people see it called: [ModuleManifest](module-manifest.md)), `description`, `cedarAction`, `toolName`, `writes`, `target`, `bestEffort`, `hints` (`readOnly`, `destructive`, `idempotent`), `consent`, `exposure` (`agent`, `mcp`, `api`; see below), and the JSON Schemas `input`, `output` and `result`.
35
+ - `SurfaceProjection`: as in the table above. Every schema is a JSON Schema (draft 2020-12) document.
36
+
37
+ ## Exposure
38
+
39
+ Each action says which surfaces offer it, each on its own (`defineAction({ exposure: { agent: false } })`; every surface by default):
40
+
41
+ | Field | Surfaces |
42
+ | --- | --- |
43
+ | `agent` | the app's own agent: its tools (the `agent` surface) |
44
+ | `mcp` | external agents over MCP (`/mcp`) |
45
+ | `api` | the typed client (RPC), HTTP, the CLI and sync's push |
46
+
47
+ A surface that does not offer an action neither lists it (MCP `tools/list`, the agent's tools, the OpenAPI document with or without a credential) nor runs a call to it: the invocation path refuses the call `Forbidden` right after the credential's scope, audited like any refusal ([Invocation](invocation.md#reach)). So an action can be an MCP tool and not one of the app's agent's (`{ agent: false }`), an agents' tool only (`{ api: false }`), or kept from MCP. Exposure is discovery, not authorisation: it does not replace the policy, which decides on every surface that offers the action, and it follows the surface, with one exception for agents: an agent session's credential (a browser agent's WebMCP bearer) calling over an API transport (RPC, HTTP, the CLI, sync) reaches only what both the API and the agent surface offer, so what the agent's tool list hides its credential cannot call through another route (refused `Forbidden` before consent and before an idempotent replay). A person's own session is on the API alone. Disabling an agent tool group closes an action to agents everywhere. The trusted in-process surfaces (workflow steps, scheduled runs, inbound webhooks' executions) always reach an action, so a schedule a person set up through the API may run an action the API does not offer; the policy still decides. MAKE modules' actions are offered everywhere.
48
+
49
+ **Person-only actions.** Actions that an agent can never run (their handlers refuse every agent-originated call, and MCP calls are always agent-originated) are omitted from surfaces where they would always be refused. The kernel's consent decisions and `consent.get`, `approvals.approve`, `proposals.decide`, `notifications.registerInstallation` and `unregisterInstallation`, actions that start, steer, checkpoint or rate agent runs (`agent.send`, `continue`, `cancel`, `cancelQueued`, `saveCheckpoint`, `restoreCheckpoint`, `updateConversation`, `feedback`), and setting the agent's budget and model (`agent.setBudget`, `configureModel`: a person who manages the agent decides these themselves, never through an agent or an MCP grant) declare `{ agent: false, mcp: false }`. `agent.recordTurn` and `directContext` are person-only in the app's agent, but their handlers do not refuse an MCP client acting for a person, so they declare `{ agent: false }` only (hidden from the app's agent and from browser agents over WebMCP, whose credential cannot call them over HTTP or RPC either). The kernel's list is `PERSON_ONLY_ACTIONS`. Direct calls by name are still refused (`Forbidden` on MCP and WebMCP's HTTP route; `ToolNotAllowed` in the app's agent). Actions an agent is permitted to call remain listed (`approvals.reject` executes nothing).
50
+
51
+ ## Errors
52
+
53
+ `UnknownAction { message, action }` from `lookup` and `project`.
54
+
55
+ ## Guarantees
56
+
57
+ - `list` holds each action exactly once, sorted by name; `lookup` returns exactly the listed descriptor.
58
+ - Every surface's input schema equals the descriptor's `input`; every declared result schema equals its `result`.
59
+ - The listing surfaces list a caller only what it can reach ([Invocation](invocation.md#reach)): MCP `tools/list`, the agent tools and the OpenAPI document asked for with a credential leave out an action the policy hides from that caller (constant false for it), one its credential's scope excludes, and, for an agent, one in an agent tool group the app disabled, and one the surface does not offer (exposure). Without a credential the OpenAPI document lists every action the API offers. Either way its `components` hold only what the listed paths reference (transitively): a withheld action's named schemas are not disclosed there either. What a surface lists, it lists exactly as projected.
60
+ - The running surfaces publish exactly the projection. The kernel's HTTP surface replaces the schemas Effect's OpenAPI generator would produce for each action (which close every object with `additionalProperties: false`) with the projected ones, so the OpenAPI document agrees with RPC, MCP and the agent tools.
61
+
62
+ ## MCP catalogs and discovery
63
+
64
+ Beside every action's tool, the MCP server has two of its own: `eloxiv_search_tools` (`{ query, limit? }`: the tools the caller reaches that match, best first, its organisation's MAKE actions at the version each runs now included (their descriptions marked as the module's own, untrusted text, as their tools' are), each with its description, input schema and read-only and destructive hints) and `eloxiv_call_tool` (`{ tool, arguments? }`: that tool's call, through the invocation path exactly as calling it directly, so its policy, scope, consent, idempotency and audit record are the same; an unknown tool is `UnknownAction`). A client that sends `x-eloxiv-mcp-catalog: compact` is listed only those two (a host with a small context finds tools as it needs them); `x-eloxiv-mcp-catalog: curated` lists the modules and actions the app curates (`KernelApp.mcp.curated`) that the caller reaches, and the two; the full catalog, the default, lists every tool the caller reaches and the two. A call through `eloxiv_call_tool` answers `{ result, links }`: the envelope, and a link to the view that shows the record the result names (a record of the entity the action writes, by its output's `id`), absolute on `KernelApp.mcp.appUrl` (a shell path without it), naming the organisation the call ran in (`?org=<id>`: the reference shell opens it there when the person belongs to it, not in the organisation the browser had chosen). With the agent installed, the app's skills are MCP prompts (`prompts/list`, `prompts/get`: an app skill by its name, a module's as `<module>.<skill>`) and its instructions MCP resources (`eloxiv://app/instructions/<path>`), app-wide text any caller of the server may read. There is no tool for asking the app's own agent: an MCP client is an agent, and an agent cannot start or steer the person's agent runs (`agent.send` refuses it; agent-to-agent is A2A, kept for later by the decisions). `GET /.well-known/mcp.json` (public) is the server's identity for external agents and connect flows: its canonical name, endpoint, OAuth resource and protected resource metadata ([ClientSDK](client-sdk.md), `mcpServerIdentity`). Tested in [`mcp-catalog.test.ts`](../../packages/testing/test/mcp-catalog.test.ts), [`mcp-library.test.ts`](../../packages/testing/test/mcp-library.test.ts) and [`mcp-identity.test.ts`](../../packages/testing/test/mcp-identity.test.ts).
65
+
66
+ ## Implementing it
67
+
68
+ An implementation derives every surface from one definition per action, as `projectAction` (`@eloxiv/contracts`) does, and serves those exact schemas. When a framework rewrites a schema on its way into a surface's document (as OpenAPI generators do), override it with the projection.
69
+
70
+ ## Running the conformance kit
71
+
72
+ ```ts
73
+ import { actionRegistryConformance } from "@eloxiv/testing/conformance/ActionRegistry"
74
+
75
+ actionRegistryConformance(() => ({
76
+ list: async () => registry.list(),
77
+ lookup: async (name) => registry.lookup(name),
78
+ project: async (name) => registry.project(name),
79
+ // What the running surfaces publish for `name`: the RPC group's schemas, the OpenAPI operation (and the
80
+ // document's component schemas), the MCP tools/list entry and the agent tool.
81
+ published: async (name) => ({ rpc, http, mcp, agent }),
82
+ }))
83
+ ```
84
+
85
+ The kit checks the registry's consistency, the projection, and that each running surface publishes the projection (`published` gives `mcp` and `agent` as `undefined` for an action hidden from the subject's caller; such an action must be hidden on both, and the caller must reach some), comparing schemas after resolving `$ref`s (to `$defs` or OpenAPI components) and dropping document-level keys. The kernel runs it against a started kernel, its OpenAPI document, a real MCP `tools/list` and its agent tools in [`packages/testing/test/conformance-action-registry.test.ts`](../../packages/testing/test/conformance-action-registry.test.ts).
@@ -0,0 +1,100 @@
1
+ # Actor
2
+
3
+ Kind: kernel service. Version 1.1.0 (1.1.0 adds `emailVerified`). Schema: [`packages/contracts/schema/contracts/Actor.json`](../../packages/contracts/schema/contracts/Actor.json). Source: [`packages/contracts/src/contracts/Actor.ts`](../../packages/contracts/src/contracts/Actor.ts); kernel implementation in [`packages/kernel/src/Identity.ts`](../../packages/kernel/src/Identity.ts) (`authenticate`) and [`packages/kernel/src/policy/Policy.ts`](../../packages/kernel/src/policy/Policy.ts) (`principalOf`).
4
+
5
+ ## Purpose
6
+
7
+ Every call, from every surface, starts by working out who is acting. The Actor contract turns request credentials into an `Actor`: a signed-in user acting in one organisation, with the roles, groups and permissions that organisation's [directory](directory.md) gives them there. It also turns an actor into the Cedar principal every policy is evaluated against.
8
+
9
+ ## Operations
10
+
11
+ ### `authenticate`
12
+
13
+ Input: the request headers. Output: the `Actor`.
14
+
15
+ - Credentials are a person's session from the app's auth provider ([AuthProvider](auth-provider.md); Better Auth by default): `Authorization: Bearer <token>` or the provider's session cookie.
16
+ - `x-eloxiv-org` names the organisation to act in; without it, the user's first membership is used.
17
+ - Roles, groups and permissions are read from the directory on every call, so a directory change applies to the caller's next call.
18
+
19
+ Errors: `Unauthenticated` without a valid session; `Forbidden` if the user is not a member of the organisation (including one named in the header).
20
+
21
+ ### `principal`
22
+
23
+ Input: an `Actor`. Output: a `CedarPrincipal` (`uid` and `entities`):
24
+
25
+ - `Eloxiv::User::"<userId>"` with attributes `org` (`Eloxiv::Org`), `email` (the **verified** address only: `""` while it is unverified, as for a service principal), `roles` and `permissions` (sets of strings), whose parents are `Eloxiv::Org::"<orgId>"` and each `Eloxiv::Group::"<groupId>"`;
26
+ - the organisation and group entities.
27
+
28
+ Sets and parents are sorted and deduplicated, so equal actors give equal principals (the policy cache is keyed on them). Never fails.
29
+
30
+ ## Records
31
+
32
+ - `Actor`: `userId`, `orgId`, `email`, `emailVerified`, `roles`, `groups`, `permissions`. Roles and groups are ids in `orgId`; permissions are the union of what those roles grant. `emailVerified` is true only when the sign-in email is verified (Better Auth's record, read afresh with every call); absent or false for an unverified address and for a service principal, which has none. Anything that treats the email as identity (linking a person record to an account, say) must require it: anyone can sign up with an address they do not receive mail at.
33
+ - `CedarEntityUid`, `CedarEntity`, `CedarPrincipal`.
34
+
35
+ ## Using the principal in policy
36
+
37
+ Policies may test, besides `principal` and `principal.org`:
38
+
39
+ | Cedar | Meaning |
40
+ | --- | --- |
41
+ | `principal in Eloxiv::Group::"reviewers"` (in the scope or a condition) | the actor is in group `reviewers` of the organisation they act in |
42
+ | `principal.roles.contains("admin")` | the actor's membership holds role `admin` |
43
+ | `principal.permissions.contains("hello.moderate")` | a role of the actor grants permission `hello.moderate` (it must be declared in a permission vocabulary) |
44
+ | `principal in Eloxiv::Org::"acme"` | the actor acts in organisation `acme` |
45
+
46
+ For the checks before a handler runs, the kernel compiles policies for the known actor, so these resolve to true or false. Row-level security compiles them without a principal, into `eloxiv_ctx.in_group(...)`, `eloxiv_ctx.has_role(...)` and `eloxiv_ctx.has_permission(...)`: functions that answer from the live directory tables, only for the acting user in the acting organisation of the transaction's invocation context, and answer false without one. Sync filters compile them the same way and evaluate them live against the replicated directory facts (see [Sync](sync.md)). `principal in resource.<attribute>` compiles for an entity-typed column (a group column through the same live group test). So does a named user on the left (`Eloxiv::User::"alice" in resource.team`), answered from the same store as for a known actor: only the acting user has organisation and group ancestors, so it holds only while Alice is the actor (and then from her live directory); a named group or organisation is `in` only itself. Any other test of a named entity's membership or attributes (`Eloxiv::User::"alice" in Eloxiv::Group::"g"`, `... has org`) is refused when compiling without a principal, because Cedar would decide it against an empty entity store and a `forbid` on it would vanish. Anything else on the principal (other attributes, `containsAny`) is not compiled: the action is denied (fail closed). Groups are flat: a group cannot contain another group.
47
+
48
+ ## Signing in
49
+
50
+ The app's auth provider signs people in behind the kernel (`/auth/*`): the seam, what the kernel owns and what a provider must do, is [AuthProvider](auth-provider.md). The default provider, Better Auth, signs people in with email and password, and, as the deployment configures (`KernelConfig.identity`):
51
+
52
+ | Setting | Environment | What it does |
53
+ | --- | --- | --- |
54
+ | system email | `ELOXIV_SMTP_URL`, `ELOXIV_EMAIL_FROM` | Account mail (templates `account.verify-email`, `account.reset-password`, `account.confirm-email-change`, `account.invitation`; `accountEmailTemplates`), to the address alone, never queued behind an organisation's notifications. Without it, verification, password reset, change of address and mailed invitations are refused. |
55
+ | `requireEmailVerification` | `ELOXIV_AUTH_REQUIRE_EMAIL_VERIFICATION` | No session for an unverified address, by password or by an OAuth provider, and the verification mail sent at sign-up; the kernel refuses to start with it and no system email (default off: verification is sent on request, `sendVerificationEmail`, and required wherever the address is identity: invitations, domain joins, account linking). |
56
+ | `issuer` | `ELOXIV_AUTH_ISSUER` | The name authenticator apps show beside the two-factor code (default `Eloxiv`). |
57
+ | `magicLinks` | `ELOXIV_AUTH_MAGIC_LINKS` | Passwordless sign-in links (`/auth/sign-in/magic-link`, `/auth/magic-link/verify`): mailed, single use, five minutes, the token stored hashed, under the sign-in routes' stricter rate limit. A link that proves an unverified account's address first removes the account's password, provider links and sessions (someone who registered the address cannot keep it), and that removal is a change of password to the credential fence (kernel migration `0142_credential_removed`), so a sign-in that read the old password gets no session; a link the person may not sign in by (an account with two-factor authentication, or one no organisation of theirs admits it for) is refused before any of that cleanup runs, leaving the account as it was. Its mail is delivered within the link's five minutes, never after. Needs system email: the kernel refuses to start otherwise. |
58
+ | `desktopRedirectSchemes` | `ELOXIV_AUTH_DESKTOP_SCHEMES` | Custom URL schemes a desktop or native app receives its sign-in code on, besides loopback addresses. |
59
+ | `providers` | `ELOXIV_AUTH_PROVIDERS` (JSON) | OAuth / OpenID Connect sign-in providers (`{ id, clientId, clientSecret, discoveryUrl? \| authorizationUrl, tokenUrl, userInfoUrl, scopes?, subjectClaim? }`), served at `/auth/sign-in/social` and `/auth/callback/<id>` with PKCE. |
60
+
61
+ **Desktop sign-in** ([`DesktopSignIn.ts`](../../packages/kernel/src/DesktopSignIn.ts)): a desktop or native app gets a session of its own, never a copy of a browser's cookie. It keeps a PKCE verifier and opens the app's web sign-in page in the system browser with its S256 challenge, its redirect (a loopback address, `http://127.0.0.1:<port>/...` or `http://[::1]:<port>/...`, or a listed scheme) and a state; the signed-in page approves (`POST /api/desktop/approve`, the person's session, a trusted origin) and is sent to the redirect with a one-time code (a minute, stored hashed). The app redeems it (`POST /api/desktop/token { code, verifier, redirectUri }`): only with the verifier whose challenge was approved, for the same redirect, once (a wrong verifier spends it), while the approving session is still in force; the answer is a new session signed in by the approving session's method, issued while the approving session holds (a browser sign-out waits for the issuance, or committed first and refuses it; one past its bound revokes the approving session and the desktop's session is ended). The approving page is the app's; the reference web shell serves one at `/desktop/sign-in` ([shell-foldkit](../registry/shell-foldkit.md)): it signs the person in first if needed, shows who signs in, where the app receives the code (the redirect's loopback host and port, or its scheme) and the challenge's fingerprint, refuses a malformed request or a web redirect without offering to approve, approves only on the person's click (as the session, a bearer token, so no cookie is involved) and follows only a redirect to the address the request named. A native host's daemon opens it by default (`<ELOXIV_SHELL_URL>/desktop/sign-in`, [LocalClient](local-client.md)).
62
+
63
+ **Sign-in methods.** Every person's session records how it was signed in (`password`, `magic-link`, `oauth:<provider>`; a session rotated by a password or two-factor change, or made by the desktop exchange, inherits its origin's); an organisation can admit only some (Directory `setSignInMethods`), checked on every call in the organisation, at OAuth consent and device approval for it, in its sync facts (kernel migration `0144_sign_in_method_facts`: a connected replica of a session it no longer admits stops at once) and at sign-in (the kernel's step after Better Auth answers, on its own connections: a session made by a method the person may not use is ended, and the answer refused, before any credential leaves). A person's session is in force only once the kernel has admitted it (recorded its method; kernel migration `0143_session_admission` admits the sessions that existed before as `unknown`), so a session Better Auth made for a sign-in that is then refused is never usable, not even by a request racing the answer.
64
+
65
+ Always on: account mail (verification, reset, change of address) is queued off the response path, so a reset or verification request answers alike whether or not the address has an account, even while the queue or SMTP is slow or down; it is kept until sent (kernel migration `0203_account_mail`): its link sealed at rest (AES-256-GCM under a key derived from the auth secret) and erased once sent, given up or expired, sent by whichever kernel process is up, tried again 30 s after a temporary failure with the wait doubling (six attempts, never past the link's hour), given up at a permanent refusal (a 5xx), and sent once (a process claims each message for two minutes just before sending it and records the outcome only under that claim; one sent but not yet marked when its process died goes again with the same `Message-ID`); a failure is recorded and logged as a classification and the SMTP reply code, never the server's text, which may quote the link; a process that dies in the moment between the answer and the queue's commit loses that message, and the person asks again ([`account-mail.test.ts`](../../packages/testing/test/account-mail.test.ts)); **a sign-in never issues a session against a password that changed while it ran** (the credential fence, kernel migration `0200_credential_fence`): a change of password or a reset first records the change under a lock on the account's credentials, and a session or two-factor challenge Better Auth makes for a request (a sign-in, by any method, whether or not it presented another session) is checked at its commit against the snapshot taken when the request reached Better Auth, refused (`401`) if the account's password changed since by another request; so a sign-in that read the old password either committed its session or challenge before the reset (which then ends it) or gets none; a change or reset (not the cleanup of an expired reset token) also voids the account's pending two-factor challenges, each earned with the old password (proven in [`account-security.test.ts`](../../packages/testing/test/account-security.test.ts)); a **change of address** acts only in the session that asked for it: its links (the current address's confirmation, the new address's verification) are refused unless opened signed in with that session while it is in force, each is used once, and none mints a session, so a reset (which ends every session) voids every link a former holder of the account was sent (kernel migration `0088_email_changes`, [`email-change-takeover.test.ts`](../../packages/testing/test/email-change-takeover.test.ts)); a provider's address counts as verified only when it says so with a literal `true`; TOTP two-factor authentication with backup codes (a password sign-in of an account with it answers a challenge and no credential); a password reset ends every session of the account; an OAuth sign-in joins an existing account only when the provider verified the same address **and** the account's address is verified (no provider is trusted without its own verification), so an account registered with someone else's address is never handed to that person's provider sign-in; every callback, redirect and error URL must be on a trusted origin (Better Auth's check pinned on in every environment); the password sign-in's stricter rate limit also covers the two-factor, reset (`/request-password-reset`, `/reset-password`), verification (`/send-verification-email`, `/verify-email`), change-of-address and change-of-password routes. Proven in [`packages/testing/test/account-security.test.ts`](../../packages/testing/test/account-security.test.ts); the client functions are in the [ClientSDK](client-sdk.md#account-profile-and-session).
66
+
67
+ ## Guarantees
68
+
69
+ - **An address counts in policy only once verified** (threat model ID-13): anyone can sign up with an address they do not receive mail at, so `principal.email` is `""` until Better Auth's record says the address is verified, in the check before a handler (`principalOf`), in row-level security (`eloxiv_ctx.current_email()`) and in sync filters (the live `email` fact; kernel migration `0087_verified_email_policy`). Verifying an address, or changing it, applies to the next call and to connected replicas as soon as zero-cache replicates it. Invitations and domain joins (Directory) require a verified address too. Proven in [`packages/testing/test/verified-email-policy.test.ts`](../../packages/testing/test/verified-email-policy.test.ts).
70
+
71
+ - A removed member is refused on their next call; a changed role, group or permission applies to the next call, in sync filters, in the pre-handler checks and in row-level security.
72
+ - A group, role or permission of one organisation never counts while the user acts in another.
73
+
74
+ ## Limits
75
+
76
+ - **An OAuth sign-in does not ask for the account's second factor.** Better Auth's two-factor step follows a password sign-in only, so an account with two-factor authentication that is linked to a provider relies on the provider's own sign-in security there. A magic link is refused for such an account. An organisation that needs the second factor everywhere admits only `password` (`setSignInMethods`).
77
+
78
+ - **A session's token outlives a sign-in only as its digest** (threat model ID-14, backlog 44): `auth.session.token` holds `sha256:<hex>` of the token, never the token (Better Auth's statements are rewritten to store and match digests: `auth/SessionTokens.ts`; another provider stores `storedToken(token)`), and a digest presented as a credential names no session (Better Auth's provider refuses one before Better Auth reads it; the trusted proxy digests every token it is given), so someone who reads the database or a backup cannot act as a signed-in person. Kernel migration `0246_hashed_session_tokens` digested the sessions stored before in place; a kernel of an earlier build still running during that deployment looks tokens up as issued, so its people sign in again. Proven in [`session-tokens.test.ts`](../../packages/testing/test/session-tokens.test.ts).
79
+
80
+ ## Implementing it
81
+
82
+ Resolve the session, the organisation and the membership, then read the membership's roles, the permissions those roles grant and the user's groups in that organisation. Build the principal exactly as above.
83
+
84
+ ## Running the conformance kit
85
+
86
+ ```ts
87
+ import { actorConformance } from "@eloxiv/testing/conformance/Actor"
88
+
89
+ actorConformance(() => ({
90
+ ...directorySubject, // newUser, createOrganization, call, audit, modulePermission (see the Directory kit)
91
+ authenticate: async (headers) => /* { ok: true, value: actor } or { ok: false, tag } */,
92
+ principal: (actor) => /* the Cedar principal */,
93
+ // Optional: people's sessions (the kit then proves sign-out, revocation and an organisation's methods).
94
+ sessions: { method, signIn: async (user) => /* headers(orgId) */, signOut, end, admitOnly },
95
+ }))
96
+ ```
97
+
98
+ An auth provider is checked by this kit with `sessions` ([AuthProvider](auth-provider.md#running-the-conformance)): the kernel runs it against Better Auth in `conformance-directory.test.ts` and against the trusted proxy in [`auth-provider.test.ts`](../../packages/testing/test/auth-provider.test.ts).
99
+
100
+ The kernel runs it in [`packages/testing/test/conformance-directory.test.ts`](../../packages/testing/test/conformance-directory.test.ts). The behaviour in policy (group, role and permission grants through sync and row-level security, revocation on the next call) is proven in [`packages/testing/test/directory-policy.test.ts`](../../packages/testing/test/directory-policy.test.ts), and differentially against Cedar in [`packages/kernel/test/policy-compiler.test.ts`](../../packages/kernel/test/policy-compiler.test.ts) and [`packages/testing/test/policy-sql.test.ts`](../../packages/testing/test/policy-sql.test.ts).