@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.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/AgentSkills.d.ts +51 -0
- package/dist/AgentSkills.d.ts.map +1 -0
- package/dist/AgentSkills.js +264 -0
- package/dist/AgentSkills.js.map +1 -0
- package/dist/AgentWeb.d.ts +83 -0
- package/dist/AgentWeb.d.ts.map +1 -0
- package/dist/AgentWeb.js +436 -0
- package/dist/AgentWeb.js.map +1 -0
- package/dist/App.d.ts +213 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +357 -0
- package/dist/App.js.map +1 -0
- package/dist/Blueprint.d.ts +47 -0
- package/dist/Blueprint.d.ts.map +1 -0
- package/dist/Blueprint.js +241 -0
- package/dist/Blueprint.js.map +1 -0
- package/dist/Brand.d.ts +42 -0
- package/dist/Brand.d.ts.map +1 -0
- package/dist/Brand.js +370 -0
- package/dist/Brand.js.map +1 -0
- package/dist/Changelog.d.ts +22 -0
- package/dist/Changelog.d.ts.map +1 -0
- package/dist/Changelog.js +117 -0
- package/dist/Changelog.js.map +1 -0
- package/dist/Cli.d.ts +17 -0
- package/dist/Cli.d.ts.map +1 -0
- package/dist/Cli.js +810 -0
- package/dist/Cli.js.map +1 -0
- package/dist/DbAdmin.d.ts +18 -0
- package/dist/DbAdmin.d.ts.map +1 -0
- package/dist/DbAdmin.js +91 -0
- package/dist/DbAdmin.js.map +1 -0
- package/dist/Dependencies.d.ts +53 -0
- package/dist/Dependencies.d.ts.map +1 -0
- package/dist/Dependencies.js +132 -0
- package/dist/Dependencies.js.map +1 -0
- package/dist/Deploy.d.ts +39 -0
- package/dist/Deploy.d.ts.map +1 -0
- package/dist/Deploy.js +458 -0
- package/dist/Deploy.js.map +1 -0
- package/dist/Docs.d.ts +71 -0
- package/dist/Docs.d.ts.map +1 -0
- package/dist/Docs.js +240 -0
- package/dist/Docs.js.map +1 -0
- package/dist/Doctor.d.ts +56 -0
- package/dist/Doctor.d.ts.map +1 -0
- package/dist/Doctor.js +368 -0
- package/dist/Doctor.js.map +1 -0
- package/dist/Dossier.d.ts +23 -0
- package/dist/Dossier.d.ts.map +1 -0
- package/dist/Dossier.js +92 -0
- package/dist/Dossier.js.map +1 -0
- package/dist/Emit.d.ts +26 -0
- package/dist/Emit.d.ts.map +1 -0
- package/dist/Emit.js +51 -0
- package/dist/Emit.js.map +1 -0
- package/dist/Errors.d.ts +26 -0
- package/dist/Errors.d.ts.map +1 -0
- package/dist/Errors.js +17 -0
- package/dist/Errors.js.map +1 -0
- package/dist/Evals.d.ts +52 -0
- package/dist/Evals.d.ts.map +1 -0
- package/dist/Evals.js +126 -0
- package/dist/Evals.js.map +1 -0
- package/dist/Files.d.ts +47 -0
- package/dist/Files.d.ts.map +1 -0
- package/dist/Files.js +145 -0
- package/dist/Files.js.map +1 -0
- package/dist/Generate.d.ts +80 -0
- package/dist/Generate.d.ts.map +1 -0
- package/dist/Generate.js +310 -0
- package/dist/Generate.js.map +1 -0
- package/dist/Guards.d.ts +45 -0
- package/dist/Guards.d.ts.map +1 -0
- package/dist/Guards.js +530 -0
- package/dist/Guards.js.map +1 -0
- package/dist/Inspect.d.ts +125 -0
- package/dist/Inspect.d.ts.map +1 -0
- package/dist/Inspect.js +270 -0
- package/dist/Inspect.js.map +1 -0
- package/dist/Keychain.d.ts +57 -0
- package/dist/Keychain.d.ts.map +1 -0
- package/dist/Keychain.js +73 -0
- package/dist/Keychain.js.map +1 -0
- package/dist/Lock.d.ts +13 -0
- package/dist/Lock.d.ts.map +1 -0
- package/dist/Lock.js +145 -0
- package/dist/Lock.js.map +1 -0
- package/dist/Mcp.d.ts +91 -0
- package/dist/Mcp.d.ts.map +1 -0
- package/dist/Mcp.js +128 -0
- package/dist/Mcp.js.map +1 -0
- package/dist/Merge.d.ts +18 -0
- package/dist/Merge.d.ts.map +1 -0
- package/dist/Merge.js +43 -0
- package/dist/Merge.js.map +1 -0
- package/dist/Migrate.d.ts +78 -0
- package/dist/Migrate.d.ts.map +1 -0
- package/dist/Migrate.js +288 -0
- package/dist/Migrate.js.map +1 -0
- package/dist/Plugins.d.ts +36 -0
- package/dist/Plugins.d.ts.map +1 -0
- package/dist/Plugins.js +304 -0
- package/dist/Plugins.js.map +1 -0
- package/dist/Postgres.d.ts +73 -0
- package/dist/Postgres.d.ts.map +1 -0
- package/dist/Postgres.js +294 -0
- package/dist/Postgres.js.map +1 -0
- package/dist/Publish.d.ts +23 -0
- package/dist/Publish.d.ts.map +1 -0
- package/dist/Publish.js +59 -0
- package/dist/Publish.js.map +1 -0
- package/dist/Registry.d.ts +539 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/Registry.js +340 -0
- package/dist/Registry.js.map +1 -0
- package/dist/Remote.d.ts +90 -0
- package/dist/Remote.d.ts.map +1 -0
- package/dist/Remote.js +1006 -0
- package/dist/Remote.js.map +1 -0
- package/dist/Run.d.ts +120 -0
- package/dist/Run.d.ts.map +1 -0
- package/dist/Run.js +477 -0
- package/dist/Run.js.map +1 -0
- package/dist/SyncGen.d.ts +118 -0
- package/dist/SyncGen.d.ts.map +1 -0
- package/dist/SyncGen.js +392 -0
- package/dist/SyncGen.js.map +1 -0
- package/dist/Update.d.ts +301 -0
- package/dist/Update.d.ts.map +1 -0
- package/dist/Update.js +627 -0
- package/dist/Update.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +42 -0
- package/dist/bin.js.map +1 -0
- package/dist/docs/backlog.md +56 -0
- package/dist/docs/ci.md +277 -0
- package/dist/docs/cli.md +696 -0
- package/dist/docs/connectors/google.md +115 -0
- package/dist/docs/connectors/http-openapi.md +7 -0
- package/dist/docs/connectors/mcp.md +8 -0
- package/dist/docs/connectors/microsoft-graph.md +75 -0
- package/dist/docs/connectors/openai.md +25 -0
- package/dist/docs/connectors/slack.md +162 -0
- package/dist/docs/connectors/workos.md +39 -0
- package/dist/docs/contracts/README.md +173 -0
- package/dist/docs/contracts/action-consent.md +92 -0
- package/dist/docs/contracts/action-registry.md +85 -0
- package/dist/docs/contracts/actor.md +100 -0
- package/dist/docs/contracts/agent-resources.md +90 -0
- package/dist/docs/contracts/agent-runtime.md +257 -0
- package/dist/docs/contracts/approvals.md +126 -0
- package/dist/docs/contracts/audit.md +75 -0
- package/dist/docs/contracts/auth-provider.md +74 -0
- package/dist/docs/contracts/calendar-provider.md +46 -0
- package/dist/docs/contracts/client-sdk.md +245 -0
- package/dist/docs/contracts/collab-document.md +151 -0
- package/dist/docs/contracts/command.md +44 -0
- package/dist/docs/contracts/connections.md +235 -0
- package/dist/docs/contracts/context-accounting.md +50 -0
- package/dist/docs/contracts/daemon.md +243 -0
- package/dist/docs/contracts/db-tx.md +53 -0
- package/dist/docs/contracts/delegation.md +68 -0
- package/dist/docs/contracts/device-control.md +103 -0
- package/dist/docs/contracts/directory-provider.md +36 -0
- package/dist/docs/contracts/directory.md +161 -0
- package/dist/docs/contracts/document-source.md +33 -0
- package/dist/docs/contracts/files.md +115 -0
- package/dist/docs/contracts/flags.md +83 -0
- package/dist/docs/contracts/host.md +68 -0
- package/dist/docs/contracts/http-api.md +43 -0
- package/dist/docs/contracts/ingestion.md +130 -0
- package/dist/docs/contracts/ingress.md +141 -0
- package/dist/docs/contracts/invocation.md +260 -0
- package/dist/docs/contracts/local-client.md +108 -0
- package/dist/docs/contracts/locale.md +56 -0
- package/dist/docs/contracts/machine-identity.md +117 -0
- package/dist/docs/contracts/mail-provider.md +49 -0
- package/dist/docs/contracts/memory.md +53 -0
- package/dist/docs/contracts/messaging.md +40 -0
- package/dist/docs/contracts/metering.md +139 -0
- package/dist/docs/contracts/model-provider.md +84 -0
- package/dist/docs/contracts/module-manifest.md +213 -0
- package/dist/docs/contracts/notification-channel.md +90 -0
- package/dist/docs/contracts/notifications.md +123 -0
- package/dist/docs/contracts/outbox.md +80 -0
- package/dist/docs/contracts/privacy.md +110 -0
- package/dist/docs/contracts/progress.md +52 -0
- package/dist/docs/contracts/query-surface.md +108 -0
- package/dist/docs/contracts/readiness.md +63 -0
- package/dist/docs/contracts/release.md +142 -0
- package/dist/docs/contracts/result-rendering.md +61 -0
- package/dist/docs/contracts/sandbox.md +186 -0
- package/dist/docs/contracts/scheduler.md +148 -0
- package/dist/docs/contracts/screen-context.md +81 -0
- package/dist/docs/contracts/search.md +120 -0
- package/dist/docs/contracts/secrets.md +74 -0
- package/dist/docs/contracts/settings.md +109 -0
- package/dist/docs/contracts/sharing.md +77 -0
- package/dist/docs/contracts/slot.md +48 -0
- package/dist/docs/contracts/space.md +67 -0
- package/dist/docs/contracts/storage-adapter.md +45 -0
- package/dist/docs/contracts/storage-backend.md +56 -0
- package/dist/docs/contracts/sync.md +213 -0
- package/dist/docs/contracts/telemetry.md +80 -0
- package/dist/docs/contracts/theme-tokens.md +50 -0
- package/dist/docs/contracts/tool-source.md +58 -0
- package/dist/docs/contracts/versioning.md +99 -0
- package/dist/docs/contracts/view.md +65 -0
- package/dist/docs/contracts/work-items.md +99 -0
- package/dist/docs/contracts/workflow.md +82 -0
- package/dist/docs/decisions.md +163 -0
- package/dist/docs/example-app.md +192 -0
- package/dist/docs/getting-started.md +927 -0
- package/dist/docs/goal.md +54 -0
- package/dist/docs/parity.md +29 -0
- package/dist/docs/performance.md +129 -0
- package/dist/docs/registry/README.md +74 -0
- package/dist/docs/registry/app.md +38 -0
- package/dist/docs/registry/approvals-ui-foldkit.md +28 -0
- package/dist/docs/registry/calendar-ui-foldkit.md +27 -0
- package/dist/docs/registry/calendar.md +35 -0
- package/dist/docs/registry/chat-ui-foldkit.md +30 -0
- package/dist/docs/registry/desktop-rune.md +49 -0
- package/dist/docs/registry/desktop.md +32 -0
- package/dist/docs/registry/eloxiv-action.md +25 -0
- package/dist/docs/registry/eloxiv-connector.md +25 -0
- package/dist/docs/registry/eloxiv-module.md +25 -0
- package/dist/docs/registry/eloxiv-policy.md +25 -0
- package/dist/docs/registry/eloxiv-view.md +25 -0
- package/dist/docs/registry/hello-ui-foldkit.md +29 -0
- package/dist/docs/registry/hello.md +39 -0
- package/dist/docs/registry/home-ui-foldkit.md +27 -0
- package/dist/docs/registry/home.md +29 -0
- package/dist/docs/registry/inbox-ui-foldkit.md +27 -0
- package/dist/docs/registry/mail-ui-foldkit.md +27 -0
- package/dist/docs/registry/mail.md +34 -0
- package/dist/docs/registry/meeting-prep.md +26 -0
- package/dist/docs/registry/members-ui-foldkit.md +28 -0
- package/dist/docs/registry/mobile.md +37 -0
- package/dist/docs/registry/notes-ui-foldkit.md +27 -0
- package/dist/docs/registry/notes.md +26 -0
- package/dist/docs/registry/people-ui-foldkit.md +28 -0
- package/dist/docs/registry/people.md +38 -0
- package/dist/docs/registry/shell-foldkit.md +34 -0
- package/dist/docs/registry/theme.md +25 -0
- package/dist/docs/registry/ui-conformance.md +30 -0
- package/dist/docs/release.md +100 -0
- package/dist/docs/scaffold.md +826 -0
- package/dist/docs/security/threat-model.md +299 -0
- package/dist/docs/upstream/zero-cache-socket-handoff.md +105 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -3
- package/src/AgentSkills.ts +329 -0
- package/src/AgentWeb.ts +507 -0
- package/src/App.ts +435 -0
- package/src/Blueprint.ts +276 -0
- package/src/Brand.ts +415 -0
- package/src/Changelog.ts +136 -0
- package/src/Cli.ts +1458 -0
- package/src/DbAdmin.ts +115 -0
- package/src/Dependencies.ts +170 -0
- package/src/Deploy.ts +563 -0
- package/src/Docs.ts +309 -0
- package/src/Doctor.ts +424 -0
- package/src/Dossier.ts +148 -0
- package/src/Emit.ts +68 -0
- package/src/Errors.ts +18 -0
- package/src/Evals.ts +153 -0
- package/src/Files.ts +152 -0
- package/src/Generate.ts +402 -0
- package/src/Guards.ts +541 -0
- package/src/Inspect.ts +358 -0
- package/src/Keychain.ts +107 -0
- package/src/Lock.ts +174 -0
- package/src/Mcp.ts +159 -0
- package/src/Merge.ts +70 -0
- package/src/Migrate.ts +331 -0
- package/src/Plugins.ts +347 -0
- package/src/Postgres.ts +353 -0
- package/src/Publish.ts +64 -0
- package/src/Registry.ts +405 -0
- package/src/Remote.ts +1158 -0
- package/src/Run.ts +541 -0
- package/src/SyncGen.ts +570 -0
- package/src/Update.ts +873 -0
- package/src/bin.ts +46 -0
- package/src/index.ts +7 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# AgentResources
|
|
2
|
+
|
|
3
|
+
Instructions, skills and agent files in personal, team, organisation and app scopes, with precedence **personal > team > organisation > app** for the same kind and path. People manage their personal scope, organisation administrators the organisation's, and the app scope comes from the registry. Every change is an audited action.
|
|
4
|
+
|
|
5
|
+
- Kind: kernel service. Version 1.1.0 (1.1.0: a team's scope).
|
|
6
|
+
- Schema: [`packages/contracts/schema/contracts/AgentResources.json`](../../packages/contracts/schema/contracts/AgentResources.json) (source [`AgentResources.ts`](../../packages/contracts/src/contracts/AgentResources.ts)).
|
|
7
|
+
- Implementation: [`packages/kernel/src/agent/Resources.ts`](../../packages/kernel/src/agent/Resources.ts); the `agent` module's `resource` records and actions ([`module.ts`](../../packages/kernel/src/agent/module.ts)).
|
|
8
|
+
- Kit: `@eloxiv/testing/conformance/AgentResources` ([source](../../packages/testing/src/conformance/AgentResources.ts)), run by [`packages/testing/test/agent-resources.test.ts`](../../packages/testing/test/agent-resources.test.ts).
|
|
9
|
+
|
|
10
|
+
## Scopes
|
|
11
|
+
|
|
12
|
+
| Scope | Where it comes from | Who changes it |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| `app` | every installed module's manifest `skills` (documents read from the module's directory at startup; `kind: skill`, `path` = the skill's id), the app's own skills (`KernelApp.skills`: registry `skill` items, each `defineAppSkill({ name, description, directory: import.meta.url, content })`, its document read from its directory at startup; `path` = its kebab-case name) and `KernelApp.agent.instructions` | the app's developers, through the registry and the app |
|
|
15
|
+
| `org` | the `agent` module's `resource` records | members with `eloxiv.agent.manage` |
|
|
16
|
+
| `team` | the same records, of a [Directory](directory.md) team (`team`): read by its members, in a member's context when it is their active team or the conversation is bound to it (`agent.updateConversation`'s `team`) | the team's leads (and members with `eloxiv.agent.manage`), while they are in the team |
|
|
17
|
+
| `personal` | the same records, owned by one person | that person |
|
|
18
|
+
|
|
19
|
+
## Operations
|
|
20
|
+
|
|
21
|
+
| Operation | Input | Output | Errors |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `put` | action `agent.putResource`: `scope` (`personal`, `org`), `kind` (`instructions`, `skill`, `file`), `path`, `description`, `content` | `id` | the standard error set |
|
|
24
|
+
| `remove` | action `agent.removeResource`: `id` | `id` | the standard error set |
|
|
25
|
+
| `effective` | optional `kind` (`GET /agent/resources?kind=`) | one `AgentResource` per (kind, path), from the nearest scope | `Unauthenticated` |
|
|
26
|
+
| `list` | `scope` (`GET /agent/resources?scope=`) | every resource of that scope the caller may read | `Unauthenticated` |
|
|
27
|
+
| `moveFolder` | action `agent.moveResources`: `scope`, `from`, `to` | `{ moved: [{ kind, from, to }] }` | the standard error set |
|
|
28
|
+
| `removeMany` | action `agent.removeResources`: `ids` (1 to 500) | `{ removed: [{ kind, path }] }` | the standard error set |
|
|
29
|
+
| `exportPack` | action `agent.exportResources` (read-only): `scope` (`personal`, `org`) | a `ResourcePack` | the standard error set |
|
|
30
|
+
| `importPack` | action `agent.importResources`: `scope`, `pack`, `onConflict?` (`fail`, the default; `skip`; `replace`) | `{ created, replaced, unchanged, skipped }`, each a list of `{ kind, path }` | the standard error set |
|
|
31
|
+
|
|
32
|
+
A skill's document (a module's or the app's) is read once, at startup, and only if it is a file inside the skill's directory once both are resolved: a document that is a symbolic link, or sits under a linked directory, leading out of the directory refuses the kernel at startup (`readSkillDocument`). The same `path` in a nearer scope overrides the farther one; removing it falls back. Effective instructions are sent to every model call; effective skills appear as an index (or whole, when pinned; [ContextAccounting](context-accounting.md)) and the agent reads one with `load_skill`. Files are stored and listed; they are not sent to the model.
|
|
33
|
+
|
|
34
|
+
**Calling on a skill.** A person's message that starts with `/<skill>` (a slash command) or mentions `@<skill>` anywhere, naming a skill in effect for them, gives the agent that skill's whole document for that turn's model calls, as a pinned skill is given (its context item says `invoked`); the index line alone is sent otherwise. A name that is not a skill in effect for the person (another person's, a development skill, a typo) calls on nothing and stays plain text. A skill read with `load_skill` stays in the conversation's transcript for later turns.
|
|
35
|
+
|
|
36
|
+
**Lab skills.** A skill may require a flag (`requires: { flag: "<module>.<flag>" }`, usually a [lab](flags.md#labs)): the app's agent is given it, in the index and through `load_skill`, only while that flag is on for the person, evaluated exactly as the Flags contract does, for the person as they are now: their roles and groups read live in the organisation they act in (so a role's off rule wins over the organisation's on rule), their own opt-in (`flags.optIn`), the organisation's targeting and rollouts. Off, when it cannot be evaluated, or when the app does not install the Flags module (`flagsModule`), it is not given (fail closed), even if the flag is on by default. Startup refuses a skill that requires a flag no module declares.
|
|
37
|
+
|
|
38
|
+
**Who a skill is for.** A module's skill (or an app skill, `defineAppSkill({ ..., audience })`) may say it is for the app's agent at run time (`runtime`), for coding agents and tooling that build the app (`development`), or both (the default). A development skill is never given to the app's agent: it is not among the app's resources (`effective`, `list`), not in the skill index, and `load_skill` does not find it; the kernel keeps it apart (`AgentResources.developmentSkills`) for tooling. Startup refuses any other audience.
|
|
39
|
+
|
|
40
|
+
## Folders and files
|
|
41
|
+
|
|
42
|
+
Paths are folders: `brand/logo.png` sits in `brand/`. The calls that put paths into a scope (`put`, `importPack`, `moveFolder`) take that scope's lock (the organisation's, or the person's own) for their transaction before they look for what is there, so two of them never leave two resources at one kind and path. **`agent.moveResources`** renames a folder (the resource at `from` and everything under `from/`, never a sibling such as `from-old/`) of one scope, all or nothing: any new path already taken (or longer than 300 characters) refuses the whole move. **`agent.removeResources`** removes resources by id, all or nothing: the kernel locks and authorises every id (the action's declared targets) before it runs, so one the caller may not remove refuses them all. A folder is removed by naming every resource in it; `@eloxiv/client/resources`' `removeFolder` does that from what the person sees. Both follow `put`'s rule: a person's own personal scope, the organisation's for members with `eloxiv.agent.manage` (anyone else is refused, `Forbidden`); an agent's move waits for its person's consent, and a removal is destructive, so it waits too.
|
|
43
|
+
|
|
44
|
+
**Binary files** (an image, a PDF, a spreadsheet) are a `file` resource with the bytes attached through the [Files](files.md) contract: the resource entity accepts files (25 MiB each), attached (`files.beginUpload` with `attachTo: { entity: "Agent::Resource", id }`) by whoever may write the resource's scope (its `attach` policy is the write rule), read and downloaded by whoever may read the resource (a person's own, or the organisation's by every member), and deleted with the resource. Files and their bytes are never sent to the model.
|
|
45
|
+
|
|
46
|
+
## Resource packs
|
|
47
|
+
|
|
48
|
+
A resource pack moves one scope's resources between scopes or installations as JSON. `eloxiv call` prints the result envelope (`{ "kind": "output", "output": ... }`), so take the pack out of it, then wrap it in the import's input:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
eloxiv call agent.exportResources --input '{"scope":"org"}' | jq -e '.output' > pack.json
|
|
52
|
+
# elsewhere (another organisation or installation):
|
|
53
|
+
jq -n --slurpfile pack pack.json '{ scope: "org", pack: $pack[0], onConflict: "skip" }' > import.json
|
|
54
|
+
eloxiv call agent.importResources --input @import.json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
A pack looks like this:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{ "format": "eloxiv.agent-resources", "version": 1,
|
|
61
|
+
"source": { "scope": "org", "kernelVersion": "0.1.0", "exportedAt": "2026-11-11T09:00:00.000Z" },
|
|
62
|
+
"resources": [{ "kind": "instructions", "path": "house/style", "description": "House style", "content": "..." }] }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- **Export** holds the resources the caller reads in that scope: their own personal ones, or the organisation's (every member reads those). It keeps each resource's kind, path, description and content, and where the pack came from; never an id, an owner, another person's resources or another scope's.
|
|
66
|
+
- **Import** writes into the caller's personal scope, or the organisation's (which needs `eloxiv.agent.manage`, as `put` does: row-level security refuses anyone else, and nothing of the pack lands). It is one action, all or nothing. A pack that is not one (another format or version), names a kind and path twice, holds more than 500 resources or resources whose JSON comes to more than 3 MiB (`RESOURCE_PACK_MAX_BYTES`, `resourcePackBytes`), or has a resource `put` would refuse, is refused; so is one the database will not store (a NUL character in text), and nothing of it lands. Export refuses a scope past the same limits, so a pack the kernel exports can always be imported back; 3 MiB leaves room for the envelope and the import's input within the kernel's default request body limit of 4 MiB (`ELOXIV_HTTP_MAX_BODY_BYTES`; a deployment that lowers it below that cannot import the largest packs). A resource already there with the same description and content is `unchanged`; one there with other content is a **conflict**: the whole import is refused (`fail`), or that resource is kept (`skip`) or replaced (`replace`), as asked. An agent's import waits for its person's consent (what the agent is told comes from these resources). Audited like every action, refusals too.
|
|
67
|
+
|
|
68
|
+
## Clients
|
|
69
|
+
|
|
70
|
+
`@eloxiv/client/resources` ([ClientSDK](client-sdk.md#agent-resources)): the layered view, each scope as a folder tree, memory, and every change above through the actions.
|
|
71
|
+
|
|
72
|
+
## Records
|
|
73
|
+
|
|
74
|
+
**`AgentResource`**: `scope`, `kind`, `path`, `description`, `content`, `id` (null for app resources).
|
|
75
|
+
|
|
76
|
+
## Guarantees
|
|
77
|
+
|
|
78
|
+
1. Precedence personal > organisation > app, per person: one person's personal resources never affect another's.
|
|
79
|
+
2. Only administrators write the organisation scope; only the owner changes a personal resource.
|
|
80
|
+
3. Every change is an action: policy-checked and audited (refusals too).
|
|
81
|
+
4. What is in effect is what the agent is given.
|
|
82
|
+
|
|
83
|
+
## How an implementation is checked
|
|
84
|
+
|
|
85
|
+
`agentResourcesConformance(start)`: a folder moved all or nothing (refused while a new path is taken, a sibling with the same start untouched), removed by its ids, a member refused the organisation's folders and someone else's resource (nothing removed); a lab skill given only once the person opts in, never to another, gone when they opt out; a pack exported from a person's scope and imported into the organisation's (refused for a member, nothing landing), a conflict refused with nothing written, then skipped and replaced as asked, a malformed or duplicated pack refused; a pack just under the size limit exported and imported back, one past it refused by export and by import; an import that fails after a resource was written leaving nothing; an agent's import waiting for its person's consent with nothing written, then applied once approved; a development skill absent from the app scope, the effective resources and `load_skill`, its text never reaching the model; the app scope holds the fixture module's skill, the app's own skill (`KernelApp.skills`, which `load_skill` reads like a module's) and the app's instruction; an administrator's organisation instruction overrides the app's, a person's own overrides both for them alone (and reaches their agent's model calls, not the overridden texts), and removing it falls back; a member cannot write the organisation scope nor remove another's resource; changes and refusals are audited; `load_skill` returns a skill's document.
|
|
86
|
+
|
|
87
|
+
## Not yet guaranteed
|
|
88
|
+
|
|
89
|
+
- **Workspace-wide resources** (a scope above one organisation) and **custom agents as resources** (owned and edited at runtime by a person, an organisation or a workspace) are not built, deferred by the user (owner decision, 2026-11-16): Eloxiv has no workspace or owner model for them. Custom agents an app declares in its code, `KernelApp.agent.profiles`, are built ([delegation.md](delegation.md)). Packs move resources between organisations and installations meanwhile.
|
|
90
|
+
- Files are text; binary files wait for the Files contract.
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# AgentRuntime
|
|
2
|
+
|
|
3
|
+
One agent per person per organisation (and an organisation agent for jobs), over the whole registry: every action is a tool, the query surface is a tool, and a person's message starts a **durable run** whose model calls and tool calls are journalled steps. There is no agent per module and no agent-to-agent protocol between modules (decisions.md, "One agent over the whole registry").
|
|
4
|
+
|
|
5
|
+
- Kind: kernel service. Version 1.9.0 (1.1.0: `send` takes `device`; 1.2.0: `complete`'s `ModelUnavailable` carries a `reason`, [ModelProvider](model-provider.md); 1.3.0: a run whose cancellation committed ends `cancelled` whatever a model call in flight returns, its reply recorded as `reply-discarded`, and `cancel` refuses a run that already finished; 1.4.0, made on two branches at once: the organisation's loop and tool policies, plan mode, tool discovery by search, write receipts and the final-answer check, processors, `active` and a run's `activity` (build/agent-runtime), and each run's stored trace and people's feedback on their runs as data (build/telemetry-search); 1.5.0: both together; 1.4.0 on a third branch (build/runtime-composition): `readiness`; 1.6.0: 1.5.0 and that together; 1.8.0: interrupted turns continue (`continue`, automatic continuations, reconciliation, late answers); 1.7.0: shared conversations, threads on a record (`send`'s `resource`), checkpoints, turns recorded from elsewhere, attachments' content, and `send` refused when the agent is not ready; 1.9.0: `consent-required` carries `title`, what people see the held call's action called, and a held call whose action was removed while it waited (a MAKE rollback) is rejected without its definition (its `tool-result` has no label) or, approved, answered `ToolUnavailable` without running; the app's agent lists no action its surface does not offer and no person-only action; `agent.setBudget` and `agent.configureModel` are refused to every agent-originated call, MCP's included; `tool-result`, and a device turn's `tool-call`, carry `action` and `title` too).
|
|
6
|
+
- Schema: [`packages/contracts/schema/contracts/AgentRuntime.json`](../../packages/contracts/schema/contracts/AgentRuntime.json) (source [`AgentRuntime.ts`](../../packages/contracts/src/contracts/AgentRuntime.ts); records in [`Agent.ts`](../../packages/contracts/src/Agent.ts)).
|
|
7
|
+
- Implementation: the run workflow [`packages/kernel/src/agent/Run.ts`](../../packages/kernel/src/agent/Run.ts), the read side [`Runtime.ts`](../../packages/kernel/src/agent/Runtime.ts), HTTP [`Http.ts`](../../packages/kernel/src/agent/Http.ts), the kernel-provided `agent` module [`module.ts`](../../packages/kernel/src/agent/module.ts); the client SDK's [`agentClient`](../../packages/client/src/Agent.ts) and sync tables [`AgentSync.ts`](../../packages/client/src/AgentSync.ts).
|
|
8
|
+
- Kit: `@eloxiv/testing/conformance/AgentRuntime` ([source](../../packages/testing/src/conformance/AgentRuntime.ts)), run by [`packages/testing/test/agent-runtime.test.ts`](../../packages/testing/test/agent-runtime.test.ts). Restart and fencing: [`agent-restart.test.ts`](../../packages/testing/test/agent-restart.test.ts).
|
|
9
|
+
|
|
10
|
+
## Installing the agent
|
|
11
|
+
|
|
12
|
+
An app installs the kernel's `agentModule` (and `inboxModules`, which consent needs) and configures its model providers:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { agentModule, inboxModules, type KernelApp } from "@eloxiv/kernel"
|
|
16
|
+
|
|
17
|
+
export const app: KernelApp = {
|
|
18
|
+
name: "my-app",
|
|
19
|
+
modules: [...myModules, agentModule, ...inboxModules],
|
|
20
|
+
agent: {
|
|
21
|
+
providers: [openaiProvider()], // a ModelProviderImpl from a registry connector (`eloxiv add openai`)
|
|
22
|
+
defaultModel: { provider: "openai", model: "gpt-5-mini" },
|
|
23
|
+
limits: { maxSteps: 16, maxTokens: 200_000, maxWallMs: 600_000 },
|
|
24
|
+
budgets: { messages: 24_000 }, // ContextAccounting
|
|
25
|
+
keepRecentMessages: 6, // Memory: compaction keeps these verbatim
|
|
26
|
+
instructions: [{ path: "app/house-style", description: "...", content: "..." }],
|
|
27
|
+
},
|
|
28
|
+
sync: { schema, queries: { ...agentQueries } },
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The kernel refuses an app that configures `agent` without installing `agentModule`. Add `agentTables` and `agentQueries` from `@eloxiv/client/sync` to sync conversations to people's replicas.
|
|
33
|
+
|
|
34
|
+
## Operations
|
|
35
|
+
|
|
36
|
+
| Operation | Input | Output | Errors |
|
|
37
|
+
| --- | --- | --- | --- |
|
|
38
|
+
| `send` | action `agent.send`: `text`, optional `conversationId`, `attachments`, `device` (the run executes on one of the person's paired devices: [Daemon](daemon.md#integrating-with-the-agent-runtime)), `mode` (`act`, the default, or `plan`: see [Plan mode](#plan-mode)), `queue` and `queueTtlMs` ([Queued messages](#queued-messages)) | `SentMessage`: `conversationId`, `messageId`, `runId`, and `queued.submissionId` when it was queued | `Unauthenticated`, `Forbidden` (an agent-originated caller), `InvalidInput` (not your conversation, or a run of it is still active and the message was not queued) |
|
|
39
|
+
| `cancelQueued` | action `agent.cancelQueued`: `id` (a queued message's) | `id` | the standard error set; `InvalidInput` for a message that already started (cancel its run) |
|
|
40
|
+
| `events` | `runId`, optional `after` (a sequence number) | the run's `RunEvent`s after it | `Unauthenticated`, `UnknownRun` |
|
|
41
|
+
| `status` | `runId` | `Run` (with its `mode`, `verification` and, while active, `activity`) | `Unauthenticated`, `UnknownRun` |
|
|
42
|
+
| `active` | | the person's active runs (queued, running, waiting; their sub-agents' too), oldest first, each with its `activity` | `Unauthenticated` |
|
|
43
|
+
| `continue` | action `agent.continue`: `runId` (the conversation's latest turn, stopped, failed or cancelled) | `id` (the new run), `conversationId` | the standard error set; `InvalidInput` for a run that succeeded or is not the latest turn, while a run is active, or a device run |
|
|
44
|
+
| `cancel` | action `agent.cancel`: `runId` | `runId` | the standard error set; `InvalidInput` ("already finished (<status>)") for a run that finished before the cancellation could commit (a run that ended `cancelled` is cancelled again, which changes nothing) |
|
|
45
|
+
| `complete` | `messages`, optional `schema` (JSON Schema), `maxOutputTokens` | `text`, `object` (with a schema), `usage` | `BudgetExceeded`, `ModelUnavailable`, `Forbidden` |
|
|
46
|
+
| `trace` | `runId` | `RunTrace`: the run's `status`, its `spans` in order (each model call, `model`, named `provider:model`, with its tokens; each tool call, `tool`, named by its tool, from the model step that asked for it to its result; with `startedAt`, `finishedAt`, `durationMs`, `ok` and an `errorTag`) and the owner's `feedback` | `Unauthenticated`, `UnknownRun` (not the caller's run) |
|
|
47
|
+
| `feedback` | action `agent.feedback`: `runId`, `rating` (`up`, `down`), optional `comment` (at most 2,000 characters), `tags` (at most 10 lower-case labels) | `id` | `Unauthenticated`, `Forbidden` (an agent-originated caller), `InvalidInput` (not your run) |
|
|
48
|
+
| `feedbackList` | `scope` (`user`, `org`), `period` | `FeedbackList`: entries newest first (at most 200) with the counts rated `up` and `down` | `Unauthenticated`, `Forbidden` (the organisation's needs `eloxiv.agent.manage`) |
|
|
49
|
+
| `readiness` | none | `EngineReadiness`: `state`, `provider`, `model`, `detail` (see below) | `Unauthenticated`, `Forbidden` (a scoped credential, as every agent route) |
|
|
50
|
+
|
|
51
|
+
**Readiness.** Whether the caller's agent can answer on the organisation's model, decided by the kernel without calling the provider: `configured` (its model, the organisation's choice or the deployment's default, is installed and the provider builds it with the organisation's credentials); `missing` (no model is chosen, or the provider has no credentials for the organisation: someone must set it up); `unavailable` (a provider or model the deployment does not have, or credentials the provider refuses to build a model with). Why the provider refused is logged, redacted, never answered. `configured` is not a promise that a call succeeds: that failure is a run's typed `ModelUnavailable`. `unknown` is never the kernel's answer: a client that could not ask says it, so a failed probe is never taken for a missing setup (the client SDK's `readiness` and the chat SDK's `withEngine`, [ClientSDK](client-sdk.md#the-chat-sdk)). It covers the deployment's model; a send with `device` runs on the person's own harness instead. The deployment's default alone is also [Readiness](readiness.md)'s `model-provider` check.
|
|
52
|
+
|
|
53
|
+
Over HTTP (`AGENT_PATHS` in `@eloxiv/contracts`), with the person's credential:
|
|
54
|
+
|
|
55
|
+
| Route | What |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `POST /agent/messages` | `send` (through the invocation path, surface `http`; honours `idempotency-key`) |
|
|
58
|
+
| `GET /agent/messages/<idempotency-key>` | `{ receipt }`: the caller's `send` under that key, its receipt from the receipt store if it committed, else `null` (none has committed yet; a send in flight commits its receipt with it), under the caller's asserted chain like every agent route; for a client whose answer was lost |
|
|
59
|
+
| `GET /agent/runs` | `active` |
|
|
60
|
+
| `GET /agent/conversations?q=&limit=&before=&archived=&hidden=&pinned=` | a page of the caller's conversations (`ConversationPage`: `conversations`, `next`), newest first; arguments checked (`ConversationQuery`) before anything is read: `InvalidInput` (400) for a limit outside 1 to 100, a cursor this list did not give, a flag that is not `true` or `false`, an unknown argument |
|
|
61
|
+
| `GET /agent/runs/<id>` | `status` |
|
|
62
|
+
| `GET /agent/runs/<id>/events?after=<seq>` | `events` as server-sent events (`Last-Event-ID` works too): every stored event in order, live `text-delta` events while the run executes in this process (`{ type, data: { delta, step, attempt } }`: the model step it is part of, and that step's model call, so text of a call made again after a restart is told apart from the first's; no sequence number or run id, which the client SDK fills in from the stream), closed after `run-finished`. Nothing is written to the stream except inside an assertion of the caller's chain that began after it was read or arrived: each poll's events inside the poll's assertion, live text held until the next assertion (deliveries one at a time, in order). A sign-out or revocation either waits for a delivery or commits first and ends the stream with nothing more delivered. It opens with an SSE comment of over 2 KB and is sent `x-content-type-options: nosniff`, so a client that holds back a response's first 512 bytes to sniff its type (WebKit: Safari, and the desktop host's webview on Linux and macOS) hands over the first events at once; a quiet stream gets a comment every 15 s |
|
|
63
|
+
| `GET /agent/runs/<id>/context?step=<n>` | the context x-ray ([ContextAccounting](context-accounting.md)) |
|
|
64
|
+
| `GET /agent/runs/<id>/children` | sub-agent runs ([Delegation](delegation.md)) |
|
|
65
|
+
| `GET /agent/runs/<id>/trace` | `trace` |
|
|
66
|
+
| `GET /agent/runs/<id>/usage` | the run's usage per metered call ([Metering](metering.md)) |
|
|
67
|
+
| `GET /agent/feedback?scope=&period=` | `feedbackList` |
|
|
68
|
+
| `POST /agent/complete` | `complete` |
|
|
69
|
+
| `GET /agent/readiness` | `readiness` |
|
|
70
|
+
| `GET /agent/resources`, `/agent/memory`, `/agent/budgets`, `/agent/usage`, `/agent/usage/insights` | [AgentResources](agent-resources.md), [Memory](memory.md), [Metering](metering.md) |
|
|
71
|
+
|
|
72
|
+
The client SDK: `agentClient({ baseUrl, token, orgId })` with `send` (its `device` option runs the run on one of the person's paired devices, as `agent.send`'s `device` does), `events(runId, { after })` (an async iterator over the stream), `follow(runId)` (to the end), `run`, `active`, `context`, `children`, `cancel`, `complete`, `trace`, `feedback`, `feedbackList`, `usage`, `insights`, `runUsage`, `budgets` and `readiness` (`unknown` when the request gets no answer or an answer that is not the kernel's; a refused caller throws). In process, `AgentRuntime` has `status`, `events`, `inventory`, `children`, `active`, `conversations`, `compact`, `complete`, `trace` and `feedback`; module workflows can call `complete` through the kernel's `AgentRuntime` service.
|
|
73
|
+
|
|
74
|
+
## The durable run
|
|
75
|
+
|
|
76
|
+
A run is the kernel workflow `eloxiv.agent-run` ([Workflow](workflow.md)), one execution per run keyed by the run id, acting as the person (or the organisation's system actor for a job's run). `agent.send` stores the person's message and the run (`queued`) and emits `agent.runRequested` in one transaction; a kernel reaction starts the execution from the outbox, so a message is never lost between the two.
|
|
77
|
+
|
|
78
|
+
| Step | What it does |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `start` | The run's spec: limits, its tools, and the conversation's **agent session** (issued once per conversation, 30 days, renewed when near expiry) |
|
|
81
|
+
| `model/<i>` | Checks cancellation and wall time, meters any call of this step whose answer was lost to a crash (see below), assembles the context (compacting the conversation first when it is over budget and the compaction fits the run's limits), checks the token limit and **reserves the call's worst case** against the budgets ([Metering](metering.md)), which records the call as started, calls the model (streaming, with `maxOutputTokens`), and in one transaction, holding the run's row, settles the call's usage and persists the assistant message and the context inventory; if the run's cancellation committed while the call was in flight, that transaction settles the usage and records `reply-discarded` instead (see Cancellation). The message's id is the step's (`<run>:m:<i>`): a step re-run after its response was stored finds it and returns it, and only one response is ever applied to a step. Tool-call ids repeated within one response are made unique (`id#2`) |
|
|
82
|
+
| `tool/<run>/<i>/<call>` | Invokes the tool's action through the invocation path, **agent-originated through the agent session**, with the step's idempotency key `<execution id>:tool/<run>/<i>/<call>`. A step re-run after the action committed gets the replay receipt (`{ kind: "replay", receipt }`), never a second effect. Persists the tool result once (its message id is the step's) |
|
|
83
|
+
| (consent) | A call held for consent (`ConsentRequired`) records what the run waits on and suspends it (`waiting`), unless the run was cancelled meanwhile (then it ends). When the person decides, the consent module emits `consent.decided` and a kernel reaction signals the run; `tool/<run>/<i>/<call>/decided` then records the decision (`consent-decided`) and runs the call once (or gives the model `ConsentRejected`). A decision made before the run recorded its wait is read back, so none is missed; a decision that finds the run cancelled is recorded with `ran: false` and runs nothing | A call whose action was removed while it waited (a MAKE rollback) is still decided: a rejection records `ConsentRejected` (the result names no title), an approval records `ToolUnavailable`, and nothing runs.
|
|
84
|
+
| `delegate/<i>/<call>` | Starts a child run ([Delegation](delegation.md)), with limits carved from what the run has left, and waits, durably, for its answer; the answer's step records what the child spent |
|
|
85
|
+
| `finish` | Records the outcome (`succeeded`, `stopped`, `failed`, `cancelled` with a `stopReason`), appends `run-finished`, and tells a parent run. The statement that records it holds the run's row and reads the cancellation flag (and a sub-agent's parent's): a run whose cancellation committed is recorded `cancelled` (`stopReason: cancelled`), whatever outcome its execution reached. If the execution itself fails (a failure outside a step's handling, such as its `start`), the workflow's failure handler does the same with `failed` and `stopReason: error`, so a run never stays `running` with its stream open |
|
|
86
|
+
|
|
87
|
+
Every step is journalled before the next starts. A run killed at any point resumes on whichever kernel takes its shard: completed steps return their journalled results, the interrupted one runs again under the fences above. Two kernels never advance one run at the same time: each execution belongs to one shard and a kernel runs a shard only while it holds its PostgreSQL advisory lock; the step-derived message ids are a second fence in the database.
|
|
88
|
+
|
|
89
|
+
**Loop limits.** A run's limits are the deployment's (`KernelApp.agent.limits`), replaced, limit by limit, by the organisation's loop policy as it stood when the run was queued (the setting `agent.loop`, below), each capped at the deployment's ceiling (`KernelApp.agent.maxLimits`, default the deployment's limits, so an organisation may only lower them unless the operator raises the ceiling). `maxSteps` model calls and `maxTokens` input and output tokens, counting **every** model call the run causes: its own, its compactions, attempts lost to a crash, and its sub-agents' (whose limits are carved from what the run has left). A call is made only if its worst case fits: the tokens used so far, plus its assembled context, plus `maxOutputTokens` (`KernelApp.agent.maxOutputTokens`, default 8,192, sent to the provider as the call's limit), within `maxTokens`. `maxWallMs` from the run's start. A run's `steps` and `usage` are its own model calls (compaction and lost attempts included); its sub-agents report theirs. A step that fails after its retries ends the run as `failed` (`stopReason: error`; `model-error` when the model call failed). **A run carries its initiating authority.** The run records the scope and the credential of the `agent.send` call that started it (an API token, an OAuth grant, an agent session; a person's own session records none). Every tool call of the run, its consent-approved retries, its delegates and the device turns it queues stay within that scope (beside the run's own tool rules) and re-validate the credential inside each call's transaction: a run whose initiating token is revoked can do nothing more. A delegate inherits its parent's agent session, scope and credential and never gets a session of its own: if the parent's session or credential no longer holds, the delegation is refused (`Unauthenticated`), and so is every call the delegate would make ([`deferred-authority.test.ts`](../../packages/testing/test/deferred-authority.test.ts)). A failure of the kernel's own (a defect) is logged with its cause under a reference, and the run's `error`, which its owner reads, names only that reference: never the defect's message or trace ([`agent-errors.test.ts`](../../packages/testing/test/agent-errors.test.ts)).
|
|
90
|
+
|
|
91
|
+
**Cancellation is durable state.** `agent.cancel` commits the run's `cancel_requested_at`; the run reads that flag, rather than relying on being told: before every model step and tool step, in the statement that records a wait for consent (a cancellation committed first ends the run instead of waiting), in the transaction that starts a sub-agent (with the parent's row locked), in the transaction that applies a consent decision, and **inside the transaction of every tool call** (the invocation path's `guard`, which reads the flag and holds the run's row until the call commits). So no call runs after a cancellation commits: either the cancellation committed first and the call is refused (audited as `denied`), or the call committed first. A waiting run is also signalled, which ends it at once and cancels its sub-agents; a signal that is lost (nothing was waiting yet) loses nothing.
|
|
92
|
+
|
|
93
|
+
**A cancelled run ends `cancelled`.** A model call already in flight when the cancellation commits cannot be recalled, and the provider's answer still arrives. The transaction that would apply it holds the run's row, as `agent.cancel` does, so exactly one of two orderings happens:
|
|
94
|
+
|
|
95
|
+
- **The cancellation committed first.** The reply is discarded. The call's usage is settled and metered at the provider's count (the tokens were spent), and the run's stream records `reply-discarded` (`step`, `attempt`, `reason: cancelled`, `usage`, and the number of tool calls it asked for). The reply is not stored in the conversation and none of its tool calls is made. The run ends `cancelled` with `stopReason: cancelled`, and `result` is the last text the run had applied before (`null` if none).
|
|
96
|
+
- **The reply was applied first.** It stays in the conversation, as the answer it was when it was applied. The run starts nothing more, and `finish` records it `cancelled`.
|
|
97
|
+
|
|
98
|
+
A device turn's reply follows the same rule: a settled turn taken after the run's cancellation committed is recorded as `reply-discarded` (with `turnId` and `device: true`), its usage is recorded as subscription usage, and the run ends `cancelled`. A model call lost to a crash after the cancellation committed is metered as abandoned (see below) and is not made again. The only run a cancellation leaves alone is one whose outcome committed first. `agent.cancel` locks the run's row, so a cancellation that waited for the run's finish finds the run finished and is refused (`InvalidInput`: "already finished (<status>)"), and the run keeps its outcome.
|
|
99
|
+
|
|
100
|
+
A sub-agent is cancelled with its parent, from the moment the parent's cancellation commits. Wherever a sub-agent reads its own flag while holding its row (applying a reply, a tool call's guard, a consent decision, its finish), it first reads its parent's flag while holding the parent's row. A kernel reaction then records the flag on the sub-agent too and wakes it. The stream of a run whose cancellation committed always ends with `run-finished` carrying `status: cancelled`, never `succeeded`.
|
|
101
|
+
|
|
102
|
+
**Model calls and crashes.** A remote model call cannot be made exactly once across a crash: if the process dies after the provider answered and before the answer was stored, that answer is gone. So:
|
|
103
|
+
|
|
104
|
+
- Every model call is recorded as started (`eloxiv_agent.model_call`, with its reservation) before the provider is asked, and settled with its usage record in the same transaction that stores its response.
|
|
105
|
+
- When the step runs again after such a crash, **the model is called again**. The lost attempt is first marked `abandoned` and metered at what it reserved (its counted input and `maxOutputTokens`, a usage record marked `estimated`), and counted in the run's steps, tokens and limits. Every attempt is metered; usage is never undercounted, and never counted twice.
|
|
106
|
+
- Only one response is applied per step (its message id is the step's), and the tool calls it asks for run exactly once (their idempotency keys); the lost answer had no effects.
|
|
107
|
+
- A call outside a run (`complete`, a person's compaction) lost the same way is metered as abandoned once it has been open for `modelCallTimeoutMs` (default 10 minutes; calls are cut off at it) plus five minutes. No provider in the kernel recovers a lost answer by idempotency key or response retrieval; a provider that can would let the step recover it instead of calling again.
|
|
108
|
+
|
|
109
|
+
**Events** (`RunEvent`, numbered from 0 per run, durable): `run-started`, `model-step` (text, tool calls, usage, context tokens), `tool-result` (with the call's `action` and its `title` when the tool is an action, as `consent-required` has them), `consent-required`, `consent-decided`, `compacted`, `delegated`, `seat-spawned` and `team-message` (a team's seat started, a message sent to a member of the run's team: [Delegation](delegation.md#teams)), `reply-discarded` (a reply that arrived after the run's cancellation committed: metered, not applied; a client drops the step's streamed text), `answer-checked` (the final-answer check challenged or annotated the answer), `processor-tripped` (a processor's guard stopped the run; a client drops the step's streamed text when `at` is `chunk`), `run-finished`; `text-delta` is live only.
|
|
110
|
+
|
|
111
|
+
**Active runs and stalls.** `active` lists the person's runs still queued, running or waiting. Each active run carries `activity`: when its stream last recorded an event, and `stalled`, true when it is queued or running, waits on nobody (a person's consent, a device, a sub-agent) and has recorded nothing for `KernelApp.agent.stallAfterMs` (default `modelCallTimeoutMs` plus five minutes, so a model call still within its time is not taken for a stall). A stalled run is one whose kernel died with no other taking its shard over, or that its outbox never started; a client shows it and offers `cancel`. Streamed text is not an event: a model call writing for longer than the threshold counts as quiet.
|
|
112
|
+
|
|
113
|
+
## Tools and identity
|
|
114
|
+
|
|
115
|
+
The agent's tools are every action in the registry its agent can reach now ([Invocation](invocation.md#reach): not one the policy hides from the person, nor one in an agent tool group the app disabled; as the agent tool projection names them, `hello_greet`, with the action's JSON Schema) except people's own (`agent.send`, `agent.cancel`, `agent.directContext`, `agent.setBudget`, `agent.configureModel`, `consent.*`), plus:
|
|
116
|
+
|
|
117
|
+
- `query`: reads a published query view as the person (read-only, filtered by the view's read policy), audited as `eloxiv.queryView` on the `agent` surface. When the app has the query surface's action `eloxiv.query`, that action is the tool instead (found in the registry by name; no compile-time dependency).
|
|
118
|
+
- `load_skill`: a skill's document from the effective resources ([AgentResources](agent-resources.md)).
|
|
119
|
+
- `delegate` ([Delegation](delegation.md)).
|
|
120
|
+
- `no_op` (`{ reason }`), only in a run a job or schedule started (kind `job`): the run ends `succeeded` with stop reason `noop` and the reason as its result, and its execution ends a typed no-op ([Scheduler](scheduler.md#agent-runs-a-job-starts)).
|
|
121
|
+
- Memory and resources are actions of the `agent` module (`agent_remember`, `agent_forget`, `agent_putResource`, `agent_removeResource`), so they go through the same path.
|
|
122
|
+
|
|
123
|
+
Every tool call is the person's call made by their agent: the invocation path resolves the agent session to the person's actor afresh (still a member, the session valid), decides the origin `agent`, applies policy, **consent** (destructive actions are held), idempotency, audit (surface `agent`, the step's key naming the run) and the outbox. Revoking the agent session stops the run's tools. An organisation job's run acts as the system actor (origin `system`).
|
|
124
|
+
|
|
125
|
+
**The run's authority.** Every agent HTTP route asserts the caller's chain (a revoked credential, or a session whose chain no longer holds, gets 401 on runs, their context, children and events, completions, resources, memory, budgets and usage; the events stream ends). The routes take only a credential not narrowed to some actions: a session, an unscoped API token or an OAuth grant with the `actions` scope (`eloxiv login`'s default); a narrower one is `403`. Everything the run reads or writes of the person's (its context, its replies, tool results and device replies) needs the capability an assertion of its authority gives ([Invocation](invocation.md#authority)): the person's membership is part of it, so a member removed mid-run reads nothing more, and its scope covers what the run reads (its context, memory and skills are `agent.send`'s; a query fallback read is the query surface's, `eloxiv.query`, so a token scoped to `agent.send` reads no view). A run records the scope and chain of authorities of the call that started it (`agent.send` with an API token, an OAuth grant, an agent session; [Invocation](invocation.md#authority)); its chain is that, plus the conversation's agent session. Every tool call asserts it in its transaction, and so do the run's own reads and writes of the person's data outside actions: its context (conversation, memory, resources), its compaction (the transcript read and the summary written; a compaction refused is not written), skills and the query fallback (refused results, audited). Work the run queues keeps the whole chain: a schedule or approval request it creates records the run's agent session too, and a delegate records its parent's chain and uses its parent's session (never a new one). A run queued before chains were recorded (migration `agent/0003_authority`) fails without acting.
|
|
126
|
+
|
|
127
|
+
## Interrupted turns
|
|
128
|
+
|
|
129
|
+
A turn whose run stopped (a loop limit), failed or was cancelled can go on, on the **same logical turn**: no new message from the person, a new run whose `continuation` names the turn's first run (`of`), the run it continues (`previous`), which continuation it is (`attempt`, from 1) and whether the kernel started it (`automatic`).
|
|
130
|
+
|
|
131
|
+
- **Continue.** `agent.continue` (`runId`; the client SDK's `continueTurn`) by the person, for the conversation's latest turn while nothing runs in it; never a device run (its turn runs whole on the device: send it again). The continuation runs under the authority of that call.
|
|
132
|
+
- **Automatic continuations.** A run whose model call failed transiently (the provider rate-limited or timed it out: `ModelUnavailable` reasons `rate-limited` and `timeout`) is continued by the kernel, in the transaction that recorded the failure, at most `automaticContinuations` times per logical turn (default 3, at most 3), the n-th after `continuationBackoffMs` times 2^(n-1) (default 2 s, a durable sleep), under the failed run's own authority. Any other failure (a refused or invalid request, a missing model) is left failed.
|
|
133
|
+
- **Reconciliation.** A continuation's first journalled step (`reconcile`) accounts for every tool call the run it continues asked for but never recorded a result of (a crash between a call's commit and its record, then a cancellation while no kernel ran, leaves exactly that): from the receipt store, the call `completed` (its replay receipt is recorded as its result), is `unknown` (it committed and scheduled external effects the provider has not confirmed) or is `not-run` (no receipt: it never committed, and the run that could have made it has ended); a sub-agent it started answers with its outcome. The results are recorded in the conversation as those calls' results, so the model never takes a call that ran for one that did not. The run's stream records it (`reconciled`: each call's outcome, and how many late answers).
|
|
134
|
+
- **Late answers.** A reply that arrived after the run's cancellation committed (`reply-discarded`, a model's or a device's) keeps its text, never applied: a continuation is shown it as an answer that arrived after the interruption and was not acted on (none of its tool calls was made).
|
|
135
|
+
- The continuation's instructions say it continues the person's request, that every call is accounted for, and not to repeat a call that ran.
|
|
136
|
+
|
|
137
|
+
## Organisation policies
|
|
138
|
+
|
|
139
|
+
The `agent` module declares two organisation-scope settings ([Settings](settings.md)); the app installs the kernel's `settingsModule` for organisations to set them. Members with `eloxiv.settings.manage` (the built-in `admin` role; the person who created a solo organisation) write them with `settings.set`, every member reads them (`settings.get`, and their replica's `settings.value` query, so every surface sees a change), and a deployment sets a default for every organisation with `KernelApp.settings.app`. `agent.send` reads both when it queues a run and records them on it (`run.options`, `run.limits`), so a change applies to the next run, never to one in flight.
|
|
140
|
+
|
|
141
|
+
| Setting | Value | Default |
|
|
142
|
+
| --- | --- | --- |
|
|
143
|
+
| `agent.loop` | `{ maxSteps?, maxTokens?, maxWallMs? }` (positive whole numbers): each given replaces the deployment's limit for the organisation's runs, capped at the deployment's ceiling | `{}` |
|
|
144
|
+
| `agent.tools` | `{ discovery: "all" \| "search", eager?: [tool names] }`: how the agent is offered its tools ([Tool discovery](#tool-discovery)) | `{ discovery: "all" }` |
|
|
145
|
+
|
|
146
|
+
## Plan mode
|
|
147
|
+
|
|
148
|
+
`agent.send` with `mode: "plan"` starts a run that reads and plans but changes nothing. It is offered only read-only actions (`hints.readOnly`) and its own read tools (`query`, `load_skill`, `tool_search`, `delegate`); its instructions say it is in plan mode; and a call to any other action, which the model can still make, is refused by the run before it reaches the invocation path (the model gets `PlanMode`; nothing is invoked, so nothing is audited or held). An action the registry does not declare (a MAKE module's) counts as one that changes data. A plan-mode run's sub-agents are in plan mode too. A run on a paired device cannot be in plan mode (the device's harness runs its own tools): `agent.send` refuses `mode: plan` with `device` (`InvalidInput`). The run's `mode` is on its record.
|
|
149
|
+
|
|
150
|
+
## Tool discovery
|
|
151
|
+
|
|
152
|
+
With `agent.tools` set to `discovery: "search"`, a run is not sent every tool's schema on every call. Its first call gets its own tools (`query`, `load_skill`, `delegate`, `tool_search`), the policy's `eager` tools, and in its instructions a **tool index**: the names of every other tool it may load, grouped by module. `tool_search` (`query`, `names`, `limit`) searches exactly the action tools the run could be offered now (allowed to it, reachable for the person, read-only in plan mode), so it never finds or loads a tool the run could not call:
|
|
153
|
+
|
|
154
|
+
- a `query` ranks tools by name and description (an exact name first, then words of the query in the name, then in the description) and returns at most `limit` (default 8, at most 10) with short descriptions; `names` load exact names;
|
|
155
|
+
- what it returns is **loaded**: offered with its schema on the run's next model call and every one after (not the current one, so the model asks for everything it needs at once);
|
|
156
|
+
- `unknown` lists names it asked for that are not tools it may use; `removed` lists tools the run loaded that are no longer available (a MAKE module rolled back, a policy change, a disabled tool group): they are no longer offered;
|
|
157
|
+
- without `query` or `names`, it lists up to 30 tools alphabetically and loads nothing.
|
|
158
|
+
|
|
159
|
+
The tools a run loaded are part of its journalled tool results, so a run resumed after a crash is offered the same tools. A sub-agent is offered its few tools directly. A call to a tool the run may use but has not loaded still goes through the invocation path, which checks it as any call.
|
|
160
|
+
|
|
161
|
+
## Write receipts and the final-answer check
|
|
162
|
+
|
|
163
|
+
Every successful call of an action that is not read-only carries a compact **receipt** on its tool result (`receipt`, a `WriteReceipt`): `changed`, `verified` (`true`, `false` or `unverified`), a `summary`, the `subject` it changed, and `checks` and `warnings`. The kernel derives it from what it observed ([`Receipts.ts`](../../packages/kernel/src/agent/Receipts.ts)): an exact action with a declared target or written row is changed and verified (the invocation path authorised exactly that record in the call's transaction, or the call failed); a best-effort action is changed when it affected any target and verified only when it affected all of them; an action without a declared target is `unverified` (row-level security may have filtered it); a call that scheduled external effects is `unverified` until the provider confirms them; a replay (the call ran before and its result was lost to a restart) is `unverified` at best, keeping only the durable facts of its replay receipt (a best-effort action's completion, scheduled effects), since what the first execution observed, its own `_receipt` among it, is not kept. An action may add its own receipt as an output field `_receipt` (the `WriteReceipt` schema, declared in its output): it can say nothing changed, or that a check failed, and it decides an untargeted write's verdict, but it never raises a verdict the kernel saw fail. MAKE actions carry none.
|
|
164
|
+
|
|
165
|
+
When the run answers (a model step with no tool calls) after writes, or the app has final-answer processors, a journalled `check/<step>` step weighs the answer against the receipts:
|
|
166
|
+
|
|
167
|
+
- receipts that are not a verified change are **flagged**, unless a later verified change from the same tool to the same subject corrected them;
|
|
168
|
+
- a flagged receipt that says nothing changed or a check failed (or a processor's challenge) **challenges** the answer once per run, if the run has a model call left: the receipts join the conversation as the run's next user turn (a message with `content.check`, which a client shows as the kernel's, not the person's), and the model answers again;
|
|
169
|
+
- receipts still flagged then (or only `unverified` ones) **annotate** the answer: the run's `result` ends with `Write check:` and one line per receipt;
|
|
170
|
+
- what the check found is persisted on the run (`verification`: `outcome` `passed`, `retried` or `annotated`, every write's receipt, and which processors challenged) and, when it challenged or annotated, on its stream (`answer-checked`).
|
|
171
|
+
|
|
172
|
+
The answer the model wrote stays in the conversation as it was; the run's `result` is what was checked.
|
|
173
|
+
|
|
174
|
+
## Processors
|
|
175
|
+
|
|
176
|
+
`KernelApp.agent.processors` are app code the runtime calls on every run, however it was started (over HTTP, by a job, as a sub-agent): every run is the same workflow ([`Processors.ts`](../../packages/kernel/src/agent/Processors.ts)).
|
|
177
|
+
|
|
178
|
+
| Hook | Sees | May |
|
|
179
|
+
| --- | --- | --- |
|
|
180
|
+
| `onChunk` (synchronous) | each piece of streamed text, and the step's text so far | trip: nothing more is streamed to clients; the reply is metered and not applied (no message, none of its tool calls); the run ends `stopped`, `stopReason: processor` |
|
|
181
|
+
| `onToolResult` | each tool call and its stored result | trip: the run ends `stopped` before its next model call (the call already ran; its effect stands) |
|
|
182
|
+
| `onFinal` | the final answer, the run's write receipts, and whether it was challenged already | trip (the run ends `stopped`, its answer kept as the `result`), or `challenge` once with a message the model is shown (shared with the receipt check) |
|
|
183
|
+
|
|
184
|
+
A run on a paired device takes its answer from the device's whole turn: once it is taken, its text goes through `onChunk` (as one piece) and `onFinal` (a challenge cannot be acted on there), and a trip ends the run `stopped`. A processor that throws or rejects trips its guard with the failure as the reason: a broken guard fails closed. A trip is recorded as `processor-tripped` (`processor`, `at`: `chunk`, `tool-result` or `final`, `reason`) and named in the run's `error`. Verdicts are taken inside the run's journalled steps, so a resumed run does not ask again about a step it recorded (a step cut off before its record asks again).
|
|
185
|
+
|
|
186
|
+
## Conversations
|
|
187
|
+
|
|
188
|
+
Conversations, messages, runs and their events are records of the `agent` module, readable by their owner in the organisation they act in (and a conversation by the people it is shared with, below), so a person's replica syncs only those (`agent.conversations`, `agent.messages`, `agent.runs`, `agent.checkpoints`; add `agentTables`, `agentRelationships` and `agentQueries` to the sync schema, as `eloxiv generate` does). A conversation has one active run at a time.
|
|
189
|
+
|
|
190
|
+
**Readiness.** `agent.send` is refused before anything is stored, on every surface (an invocation precheck), with `InvalidInput` whose message starts with "The agent is not ready", when no model is set up (neither the organisation nor the deployment chose one: `readiness` is `missing` with no provider; not for a send with `device`, which runs on the person's harness), or when it carries attachments and the app has no file storage (the Files contract's `files` module). The person keeps their prompt. A model that is chosen but cannot serve (no credentials for the organisation, a provider or model the deployment does not have) is not refused at the send: its run fails with the [ModelProvider](model-provider.md) contract's fixed public error, as before (a person may hold a key of their own that the organisation's readiness does not see); a client asks `readiness` first to tell the person.
|
|
191
|
+
|
|
192
|
+
**Attachments.** A send's attachments (`{ kind: "file", fileId, name, mediaType }`) are read when its run starts, in a journalled `attachments` step: each file's text with `files.readText`, called as the person's agent through the invocation path, so only a file the person may read now (the file's record's read policy, or their own staged upload), within the run's authority and the agent's reach, audited; a file they may not read is named to the model with the refusal, never its content. At most five files (each file once, however often it is attached), 8,000 characters each and 24,000 in all, and at most twenty attachments named (`ATTACHMENT_LIMITS`, enforced again when the message is rendered); the text is recorded on the message (`content.attachmentText`) and shown to the model with it, marked as the file's (`<attachment-content>`), a cut-off file said to be. The recorded text is a copy of the file as it was then (a transcript quoting a record, as tool results do).
|
|
193
|
+
|
|
194
|
+
**Turns finished elsewhere.** `agent.recordTurn` (`conversationId` or a new conversation, `prompt`, `answer`, `source: { kind: device | external, name }`, optional `resource`) records a turn one of the person's devices or an external agent finished (MCP: an external agent may call it for its person; the kernel's own agent is never offered it) in one of their conversations, between runs: the prompt and the answer join it as messages marked `content.external` (who finished it, and the surface that recorded it), and the agent sees them in its next turns. Nothing runs.
|
|
195
|
+
|
|
196
|
+
**Threads on a record.** `agent.send` with `resource: { module, entity, id }` starts a conversation about that record: the model is told which record it is about (and reads it with its tools, under policy: the reference is never trusted for authorisation), and `GET /agent/conversations?about=<module>.<entity>:<id>` lists the person's threads on it.
|
|
197
|
+
|
|
198
|
+
**Checkpoints.** `agent.saveCheckpoint` (`conversationId`, `label`) saves the point a conversation of the person's has reached (synced as `agent.checkpoints`); `agent.restoreCheckpoint` (`id`) takes it back there, refused while a run is active: every message after the point leaves the conversation, kept and marked (`covered_by` `restore:<checkpoint>:...`), and a summary written after the point gives back the earlier messages it covered; the agent's context and the chat transcript continue from the point. Both are a person's own (an agent cannot call them).
|
|
199
|
+
|
|
200
|
+
**Shared conversations.** The conversation entity is shareable through the [Sharing](sharing.md) contract: its owner (only) grants `read` or `reply` to named people, a group or the organisation (`sharing.grant` with `entity: "Agent::Conversation"`), revocable and expiring like every grant, and the grantees' replicas follow live. Readers and repliers read the conversation and the people's words and the agents' answers in it, never another person's tool results or compaction summaries (what that person's agent read with their permissions; the message read policy excludes them, and a run's context leaves them out: tool calls, results and summaries are each person's own). Repliers send to it (`agent.send` with its `conversationId`): the run is their own, as themselves (their permissions, consent and memory), on an agent session of their own, never the owner's. A reader cannot send to it.
|
|
201
|
+
|
|
202
|
+
- **What is shared is a message's public form**: its `text` (a person's words, an agent's answer). A message's `content` (its attachments' text, its agent's tool calls and their input, tool results) never syncs, to anyone (its owner reads a run's detail through its events), and another participant's run is given only the public form of the others' messages.
|
|
203
|
+
- **Answers are published verbatim.** A participant's agent answers with what it read under that participant's permissions: the answer, shared as it is written, can state facts its agent derived from tool results or files the other participants may not read. Share a conversation only with people who may see what its participants' agents answer.
|
|
204
|
+
- **Reply access is checked at every act.** A replier's run checks, inside the transaction of every read and write of the conversation's transcript, that they still hold `reply` on it (the conversation's `send` policy evaluated as them); a reply queued behind another run starts only if its sender still may (else it is marked `refused`, and never reads the conversation). A revoked grant stops a reply's run at its next read or write.
|
|
205
|
+
- **Compaction is per participant.** A run compacts only its own person's messages (only the owner's runs compact at all); another participant's messages are never summarised into it, and stay as they are.
|
|
206
|
+
|
|
207
|
+
### Queued messages
|
|
208
|
+
|
|
209
|
+
A message sent with `queue: true` while its conversation's run is still active is not refused: it is **queued** (`eloxiv_agent.submission`), with everything the send carried (its text, attachments, screen, device and mode, the organisation's policies as they stood, and the authority of the call), under the message and run ids it will have, which the send returns (with `queued.submissionId`). The transaction that records a top-level run's end promotes the conversation's oldest queued message: it becomes the conversation's next message (placed in the transcript when it starts, after the answer of the run before it; the queue keeps the order they were sent in) and run, started from the outbox like any run; the next one waits for that run in turn. That transaction locks the conversation's row, as a send that queues a message does, so a message is never left queued behind a run that ended while it was being queued. A queued message can be cancelled by its owner (`agent.cancelQueued`, holding its row, so it is either cancelled or started), and expires if its turn has not come within `queueTtlMs` (default an hour, at most a day); neither ever starts. Queued messages sync to their owner (`agent.submissions`: status `queued`, `promoted`, `cancelled`, `expired` or `refused` (a reply whose sender may no longer reply in the conversation), with the run id), so every one of their clients, after a reload too, sees the same queue. A send under an idempotency key that is retried gets the same answer, queued or not ([Invocation](invocation.md)).
|
|
210
|
+
|
|
211
|
+
A person marks their own conversations with the action `agent.updateConversation` (`conversationId`, and any of `title`, `pinned`, `archived`, `hidden`; a person's own, so an agent cannot call it): the marks sync with the conversation. `GET /agent/conversations` (the client SDK's `conversations(query)`) lists them a page at a time, newest first: `q` matches the title or any message's text (literally, case-insensitively), `archived` and `hidden` (default false) select those, `pinned=true` only pinned ones, and `before` takes the previous page's `next` cursor. Sub-agents' conversations are not listed. Attachments are references to files (`{ kind: "file", fileId, name, mediaType }`): the Files contract will resolve them; until then the model is told of each attachment by name.
|
|
212
|
+
|
|
213
|
+
## Guarantees
|
|
214
|
+
|
|
215
|
+
1. A run's tool calls are the person's calls through the one invocation path, agent-originated: policy, consent, idempotency, audit and the outbox apply, on the `agent` surface.
|
|
216
|
+
2. A run killed at any point resumes without repeating a tool's side effect (the replay receipt) or applying a second model response to a step, and without losing the conversation. A model call whose answer was lost to the crash is made again, and both attempts are metered.
|
|
217
|
+
3. One kernel advances a run at a time.
|
|
218
|
+
4. A held call runs only after the person approves it, once; a rejected call never runs and the model is told.
|
|
219
|
+
5. Loop limits stop a run before a call that could pass them, counting its compaction, lost attempts and sub-agents; a budget stops it before the model call ([Metering](metering.md)). After a cancellation commits, the run (and its sub-agents) starts no call, no tool call of it commits, and it ends `cancelled`: a reply that arrives from a call already in flight (a model's or a device's) is metered and recorded as discarded, never added to the conversation, and the stream ends with `run-finished` saying `cancelled`. The run's row decides the order: a run whose outcome committed before the cancellation keeps it, and the cancellation is refused ("already finished").
|
|
220
|
+
8. One conversation has one active run: `agent.send` locks the conversation before it checks, and the database refuses a second active run.
|
|
221
|
+
6. Conversations, messages and runs are their owner's alone, on every read path and in sync.
|
|
222
|
+
7. Agents cannot start or steer runs (no agent-to-agent protocol).
|
|
223
|
+
9. A plan-mode run (and its sub-agents) invokes no action that is not read-only, and is offered none.
|
|
224
|
+
10. Tool discovery never offers, finds or loads a tool the run could not call.
|
|
225
|
+
11. A run's limits never exceed the deployment's ceiling, whatever the organisation's policy says; only members who manage settings change the policy.
|
|
226
|
+
12. A run whose writes are not all verified does not end with an unqualified answer: it is challenged once when a write changed nothing or failed a check, and its result carries the unverified receipts.
|
|
227
|
+
13. A processor's trip stops the run as described, and a processor that fails trips.
|
|
228
|
+
14. **Traces and feedback are data, each its owner's.** A run's trace (timings, tokens and outcomes of its model and tool calls, never prompts, replies or tool inputs and outputs) is read only by the run's owner; a person rates only their own runs, once per run (the next rating replaces it), never through their agent; the organisation's feedback is listed only for members who manage the agent. Feedback is erased with the person ([Privacy](privacy.md)). ([`agent-trace-feedback.test.ts`](../../packages/testing/test/agent-trace-feedback.test.ts))
|
|
229
|
+
|
|
230
|
+
## Evals
|
|
231
|
+
|
|
232
|
+
Each module skill declares eval cases (`skills.<id>.evals`, a `SkillEvals` JSON file: prompt, expected tool calls in order, forbidden tools, answer text, state assertions on query views, and the turns a scripted model plays). The harness ([`packages/testing/src/Evals.ts`](../../packages/testing/src/Evals.ts)) runs every case through the real runtime on a real kernel, as a new member per case, and scores each skill against its threshold. An answer check passes only when the answer says it: `answerIncludes` phrases are matched whole and case-insensitively ("not" is not found in "noted"), `answerMatches` and `answerExcludes` are regular expressions (case-insensitive, Unicode) the answer must and must not match. A run in which no case ran fails. An expected call counts only if it succeeded (an action's result is its `output` envelope, not an error or a replay), so a refused call with a confident answer fails its case; a case that expects an action that changes data must assert the state it leaves (`state`), or it fails. From an app, `eloxiv eval` runs its modules' cases and `eloxiv eval promote` turns a finished run into a case, keeping only a reviewed prompt and the tools, views and input fields the reviewer allows ([cli.md](../cli.md#eval)).
|
|
233
|
+
|
|
234
|
+
- **CI, every run** (`registry/test/evals.test.ts`, `packages/testing/test/evals.test.ts`): the scripted provider plays each case's script: a regression test of the harness, the runtime and the declared skills.
|
|
235
|
+
- **A real model**: `mise run evals` with `ELOXIV_EVAL_MODEL` set:
|
|
236
|
+
- `ELOXIV_EVAL_MODEL=openai:gpt-5-mini ELOXIV_MODEL_OPENAI_API_KEY=... mise run evals`: the registry's [`openai` connector](../connectors/openai.md), with the key the kernel resolves for it;
|
|
237
|
+
- `ELOXIV_EVAL_MODEL=gateway:anthropic/claude-sonnet-4.5 AI_GATEWAY_API_KEY=... mise run evals` (the Vercel AI Gateway, built into `ai`), or `<provider>:<model>` for any `@ai-sdk/<provider>` package installed in the workspace whose default instance is named `<provider>`.
|
|
238
|
+
It prints a score per skill against its threshold, and for each failing case the tools the agent called and its answer, and exits 1 when a skill is below its threshold. `ELOXIV_EVAL_REPEAT=<n>` runs the suite n times on fresh databases (fails if any run does; anything but a whole number from 1 to 1000 is an error) and ends with each skill's cases passed and runs that met its threshold, over all the runs; `ELOXIV_EVAL_MODULES=<module>,...` runs only those modules' skills (a module with no evals is an error); `ELOXIV_EVAL_DATABASE` picks the database (default `eloxiv_evals`). In CI, the `model live` workflow (`.github/workflows/model-live.yml`, on pushes to main and build/** only, never on pull requests) runs it once on Bun and once on Node (two lanes of one run) with `openai:gpt-5-mini`, with the repository secret `ELOXIV_MODEL_OPENAI_API_KEY`.
|
|
239
|
+
- **Scores** (thresholds are each skill's own, never lowered to pass; the skills' documents are improved instead): see [progress.md](../progress.md), "build/agent-evals", for the measured scores per module before and after.
|
|
240
|
+
|
|
241
|
+
## A real model
|
|
242
|
+
|
|
243
|
+
[`registry/test/agent-real-model.test.ts`](../../registry/test/agent-real-model.test.ts) runs the runtime on a real model (the `openai` connector, `ELOXIV_REAL_MODEL`, default `gpt-5-mini`; skipped without `ELOXIV_MODEL_OPENAI_API_KEY`), on the agent conformance app with an app approval rule, and checks what the kernel did with the model's choices, never the model's wording: the provider kit (text, a tool call returned unexecuted, streaming, an object); a two-tool run whose calls are audited as the person on the `agent` surface, whose live `text-delta`s join to exactly the steps' text, whose every step's context x-ray adds up and is within a factor of the provider's own input count, and whose every model call is settled and metered with the provider's real token counts and the model's price; a metered one-shot completion; a destructive call held for consent, run once when approved, and reported `ConsentRejected` when declined; a call sent to business approval (`ApprovalRequired` to the model), refused to the requester's own vote, approved by an administrator and run once; a run cancelled mid-flight after its first tool result, with no tool call or model call after the cancellation; memory written by the model's own `agent_remember` call and given to a new conversation, not to another person; and a delegation the model makes on its own.
|
|
244
|
+
|
|
245
|
+
## How an implementation is checked
|
|
246
|
+
|
|
247
|
+
`agentRuntimeConformance(start)` on the agent conformance app ([`notebook/app.ts`](../../packages/testing/src/conformance/notebook/app.ts)): a multi-turn run calls two actions and a query, each agent-originated in the audit; the tools offered (every action the agent can reach but people's own, plus `query`, `load_skill`, `delegate`; an action the policy hides from the person is not offered) and the module skill and app instructions in context; the event stream over HTTP in order and the owner check; conversations continue and are refused to others; conversations, messages and runs sync only to their owner; a destructive call is held, approved and run once, or rejected and reported; the step limit; cancelling a waiting run; a run cancelled while its model call is held in flight (the scripted model answers after the cancellation committed) ends `cancelled`, its plain-text reply metered and recorded as `reply-discarded`, not in the conversation, and a reply asking for a tool call makes none; a cancellation of a run that already finished is refused and the run keeps its outcome; an agent's `agent_send` refused; metered one-shot completions. `agent-sync.test.ts` follows a run with the client SDK over server-sent events (resuming from a sequence number) and checks people's zero-cache replicas; `agent-restart.test.ts` kills the kernel (SIGKILL) between a tool's commit and its step's record, after a model call's result was stored, and between the provider's answer and its record (the call is made again, both attempts metered, one response applied), and runs twelve runs over two kernels, and kills it after a cancellation committed while a model call was in flight (the run ends `cancelled`, the lost call metered as abandoned and not made again). [`agent-policies.test.ts`](../../packages/testing/test/agent-policies.test.ts) proves the organisation's loop policy and its ceiling, plan mode (also in a sub-agent), tool discovery by search (the index, ranking and loading for the next call, nothing the run could not call), receipts and the final-answer check (annotated, challenged once, passed), delegation depth and profiles, and active and stalled runs; [`agent-attachments.test.ts`](../../packages/testing/test/agent-attachments.test.ts) proves attachments read into context, bounded and only when readable, and a send refused when no model is ready; [`agent-threads.test.ts`](../../packages/testing/test/agent-threads.test.ts) recorded turns, threads on a record, checkpoints restored, and a conversation shared to read with a person and to reply with a group (another person's tool results kept out, the replier's run their own, revocation); [`agent-processors.test.ts`](../../packages/testing/test/agent-processors.test.ts) each processor hook, failing closed, and a job's run; [`agent-receipts-search.test.ts`](../../packages/kernel/test/agent-receipts-search.test.ts) the receipt rules and the search ranking. `agent-cancel.test.ts` commits a cancellation at the three points a run could miss it, and checks that the run's row decides between a reply and a cancellation, and between a finish and a cancellation, both ways: a reply waiting for a committing cancellation is discarded; a reply applied before the cancellation stays and the run still ends `cancelled`; a cancellation waiting for the run's finish is refused; and a sub-agent's reply waiting for its parent's cancellation is discarded. `agent-device.test.ts` checks a device turn taken after the cancellation (discarded, its usage recorded); `agent-limits.test.ts` checks that compaction and sub-agents count against a run's limits; `agent-concurrency.test.ts` sends to one conversation twice at once; `workflow-encoding.test.ts` fails a run's execution outside its loop.
|
|
248
|
+
|
|
249
|
+
## Not yet guaranteed
|
|
250
|
+
|
|
251
|
+
- **Text deltas** reach only clients connected to the kernel executing the run; the stored events are complete.
|
|
252
|
+
- **Attachments** are read as text (`files.readText`); images and other binary content are named, not shown to the model.
|
|
253
|
+
- **Listing conversations shared with one** over HTTP: they reach the person's replica (sync); `GET /agent/conversations` lists their own.
|
|
254
|
+
- **An approval used up by a call that then crashed** before committing is spent: the re-run is held again (ActionConsent's limit).
|
|
255
|
+
- **Organisation agent runs for jobs** run as the system actor, without consent; scheduling them is the Scheduler's (a job invoking `agent.send`).
|
|
256
|
+
- **Final-answer checks read receipts, not prose**: a challenge or an annotation follows from what the receipts say, whatever the answer claims; an answer that claims nothing about a flagged write is still challenged or annotated.
|
|
257
|
+
- **Trace review, experiments and evals promoted from traces** are deferred products (decision 12): the kernel keeps the traces and the feedback they would build on.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Approvals
|
|
2
|
+
|
|
3
|
+
Business approval: a call that an approval rule matches is not run. The kernel records the prepared call, notifies the approvers, waits durably for their decision, and on approval runs exactly that call, once, as the person who asked. Separate from [ActionConsent](action-consent.md), which is a person's consent to what an agent does for them.
|
|
4
|
+
|
|
5
|
+
- Kind: kernel service. Version 1.4.0 (1.1.0 adds `withdraw`, the `withdrawn` status and the seven-day default expiry; 1.2.0 the execution's `effect`; 1.3.0 proposals; 1.4.0: each request records `title`, what people see the action called as it was when held, synced with `approvalRequest` and used in approvers' work items, notifications and email; 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 row, and a title is one line of at most 80 characters wherever a subject uses it; `approve` is offered on no agent surface, `reject` still is).
|
|
6
|
+
- Schema: [`packages/contracts/schema/contracts/Approvals.json`](../../packages/contracts/schema/contracts/Approvals.json) (source [`Approvals.ts`](../../packages/contracts/src/contracts/Approvals.ts); rules in [`Approval.ts`](../../packages/contracts/src/Approval.ts)).
|
|
7
|
+
- Implementation: the approval stage in [`packages/kernel/src/Approvals.ts`](../../packages/kernel/src/Approvals.ts); the kernel-provided `approvals` module ([`inbox/approvals.ts`](../../packages/kernel/src/inbox/approvals.ts)); the workflow, expiry timer and kernel reactions in [`inbox/Flow.ts`](../../packages/kernel/src/inbox/Flow.ts).
|
|
8
|
+
- Kit: `@eloxiv/testing/conformance/Approvals` ([source](../../packages/testing/src/conformance/Approvals.ts)), run by [`packages/testing/test/approvals.test.ts`](../../packages/testing/test/approvals.test.ts).
|
|
9
|
+
- Process proofs: [`approvals-restart.test.ts`](../../packages/testing/test/approvals-restart.test.ts) (SIGKILL, two kernels) and [`inbox-sync.test.ts`](../../packages/testing/test/inbox-sync.test.ts) (replicas through zero-cache).
|
|
10
|
+
|
|
11
|
+
## Installing it
|
|
12
|
+
|
|
13
|
+
An app that has approval rules installs the kernel's inbox modules beside its own:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { inboxModules, type KernelApp } from "@eloxiv/kernel"
|
|
17
|
+
|
|
18
|
+
export const app: KernelApp = { name: "shop", modules: [purchasesModule, ...inboxModules], sync }
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`inboxModules` is `inbox` (work items), `notifications`, `approvals` and `consent`. Each owns a schema (`eloxiv_inbox`, `eloxiv_notifications`, `eloxiv_approvals`, `eloxiv_consent`), roles and a Cedar policy like any module. The kernel refuses to start an app with approval rules but without `approvals`, `inbox` and `notifications`.
|
|
22
|
+
|
|
23
|
+
## Rules
|
|
24
|
+
|
|
25
|
+
Rules are declarative data: in a module manifest (`approvalRules`, ids namespaced `<module>.<name>`), or in the app's configuration (`KernelApp.approvalRules`, ids as given). The app's rules are tried first, then the modules' in declaration order; **the first rule that matches a call applies**.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
approvalRules: {
|
|
29
|
+
"purchases.large": {
|
|
30
|
+
description: "Orders above 1,000 need an approver",
|
|
31
|
+
action: "purchases.order",
|
|
32
|
+
when: [{ field: "amount", op: "gt", value: 1_000 }],
|
|
33
|
+
approvers: { permission: "purchases.approve" },
|
|
34
|
+
quorum: 1, // n of the m eligible approvers (default 1)
|
|
35
|
+
allowSelfApproval: false, // default false
|
|
36
|
+
expiresAfterMs: 86_400_000, // default: seven days
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
| Field | Meaning |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `action` | The action the rule applies to. A rule may not apply to the decisions themselves (`approvals.*`, `consent.*`). |
|
|
44
|
+
| `when` | Comparisons that must all hold, on the action's **decoded-then-encoded input** (the same JSON whose hash the approval binds). `field` is a dot path (`vendor.country`). Operators: `eq`, `ne`, `gt`, `gte`, `lt`, `lte` (numbers only), `in` (a list), `exists` (`value: true` or `false`). A missing field fails every test except `ne` and `exists: false`; values of different JSON types are never equal. For "or", declare two rules. |
|
|
45
|
+
| `approvers` | `{ permission }`, `{ role }` or `{ group }`: members of the acting organisation who hold it **when they decide**. |
|
|
46
|
+
| `quorum` | How many distinct approvers must approve. One rejection rejects. |
|
|
47
|
+
| `allowSelfApproval` | Whether the requester may decide their own request. |
|
|
48
|
+
| `expiresAfterMs` | The request expires this long after it was made (a durable timer). Default: seven days (`DEFAULT_APPROVAL_EXPIRY_MS`), so no request stays open for ever. |
|
|
49
|
+
|
|
50
|
+
`manifestProblems` checks every rule (unknown action, operators against the wrong kind of value, ids not namespaced); the kernel also checks the app's own rules and refuses rules on decisions.
|
|
51
|
+
|
|
52
|
+
## Operations
|
|
53
|
+
|
|
54
|
+
| Operation | Input | Output | Errors |
|
|
55
|
+
| --- | --- | --- | --- |
|
|
56
|
+
| `request` | the call (the approval stage of the invocation path) | `required` | `ApprovalRequired` (with `approvalId`) |
|
|
57
|
+
| `approve` | action `approvals.approve`: `id`, optional `comment` | `id`, `status` | the standard error set |
|
|
58
|
+
| `reject` | action `approvals.reject`: `id`, optional `comment` | `id`, `status` | the standard error set |
|
|
59
|
+
| `withdraw` | action `approvals.withdraw`: `id` (the requester only, in the request's organisation; audited) | `id`, `status` (`withdrawn`) | the standard error set; `InvalidInput` for a request already decided |
|
|
60
|
+
| `get` | `id` | `ApprovalRequest` | `UnknownApproval` |
|
|
61
|
+
|
|
62
|
+
`approve` and `reject` are actions of the kernel-provided `approvals` module: on every surface (RPC, HTTP, MCP, agent tools), on the one invocation path, audited like every action; an agent's `approve` is refused (guarantee 5a). `get` is the request's record; a person reads it through sync (`approvals.requests`, below).
|
|
63
|
+
|
|
64
|
+
## What happens
|
|
65
|
+
|
|
66
|
+
1. **The approval stage** (after identity and policy, before idempotency): the first matching rule records the **prepared call** in `eloxiv_approvals.request` (requester, organisation, action, the decoded-then-encoded input and its sha256, the rule, approvers, quorum, expiry) and writes `approvals.requested` to the outbox **in the same transaction**. The caller gets `ApprovalRequired` with the request's id; the audit record's outcome is `approval-required`. Nothing else runs and no idempotency key is claimed. A call with an idempotency key always maps to the same request (its id is derived from the organisation, user, action, key and input hash), so a retry never asks twice; without a key every call is a new request.
|
|
67
|
+
2. **The workflow** (`eloxiv.approval`, keyed by the request id, acting as the requester) is started by a kernel reaction to `approvals.requested`, with an expiry timer (`eloxiv.approval-expiry`) when the rule has one. Its steps:
|
|
68
|
+
1. `record`: the prepared call, as recorded. The request is recorded in a transaction that first asserts the call's whole authority chain, the person's own session included ([Invocation](invocation.md#authority)), so a sign-out or revocation either waits for the request to commit or commits first and no request is recorded (`Unauthenticated` or `Forbidden`); what the request records never keeps the session. A pending consent request is recorded the same way.
|
|
69
|
+
2. `notify`: the members eligible now (holding the rule's permission, role or group; not the requester unless allowed) get a `decide` share of the request (what lets them read it and is a precondition of deciding), a work item each (source `approvals.requests`, see [WorkItems](work-items.md)) and a notification each (category `approvals.requested`, email template `approvals.requested`, see [Notifications](notifications.md)).
|
|
70
|
+
3. Waits durably for the `decision` signal (`waitForSignal`).
|
|
71
|
+
4. `outcome`: reads the request's status back from the record.
|
|
72
|
+
5. `execute` (approved only): invokes **exactly the recorded call** through the invocation path, **as the requester and as the call was made** (membership and policy are checked again then): the request records the call's provenance (its origin, the agent session or reference an agent's call was made under, its credential's scope, and its authority chain, with the consent that let an agent's call through: [Invocation](invocation.md#authority)), and the call executes with it. An agent's call executes as the agent's (a real agent session is validated again, so a revoked one is refused), so the tool groups the app disabled for agents and the agent's origin apply; a person's call as the person's (origin `person`); a scoped credential's within its scope; a system call as the system's. with the request's id, which the approval stage requires to name an approved request for this requester, action and **input hash**; and with the step's idempotency key `<execution id>:execute`, derived from the request id. It runs at most once: a step cut off by a crash runs again and gets the replay receipt.
|
|
73
|
+
6. `record-execution`: the execution's outcome on the request: `succeeded` (with the result envelope), `refused` (`Forbidden` or `Unauthenticated`: for example the requester left the organisation) or `failed` (any other error tag).
|
|
74
|
+
7. `notify-requester` (category `approvals.decided`: titled with the outcome first, `Approved and ran: <title>`, `Rejected: <title>`, and a sentence for its body; the error's tag stays on the execution's record, never in the words), then `close`: every work item of the request is done (or dismissed when it expired).
|
|
75
|
+
3. **Deciding**: `approvals.approve` locks the request, checks the rule against the approver's directory **now** (an approver who lost the role is refused, `Forbidden`), refuses the requester unless the rule allows it (`Forbidden`), records the vote (one per approver: approving again is idempotent), and when the quorum is reached sets the status and writes `approvals.decided` in the same transaction. A kernel reaction signals the workflow. `approvals.reject` rejects at the first rejection. Deciding a decided or expired request is `InvalidInput`. A decision may wait for the request's lock (another decision, the expiry timer); everything it depends on is read **after** the lock, in the same transaction: the approver's eligibility from the directory as it stands then (not the facts resolved when the call was authenticated), and the wall clock (`clock_timestamp()`, not the transaction's start time), so a role removed or an expiry passed while it waited is refused, and the vote and decision times it records are when it decided (an approval is never recorded after the expiry).
|
|
76
|
+
4. **Expiry**: the timer's step sets a still-pending request `expired` and writes `approvals.decided`; the call never runs.
|
|
77
|
+
|
|
78
|
+
## Records
|
|
79
|
+
|
|
80
|
+
- **`ApprovalRequest`**: `id`, `orgId`, `requesterId`, `action`, `input`, `inputHash`, `rule`, `approvers`, `quorum`, `allowSelfApproval`, `status` (`pending`, `approved`, `rejected`, `expired`), `approvals`, `expiresAt`, `createdAt`, `decidedAt`, `execution`.
|
|
81
|
+
- **`ApprovalExecution`**: `state` (`succeeded`, `refused`, `failed`), `invocationId`, `errorTag`, `effect` (an `ActionFailed`'s: whether the failed call may have acted, [Invocation](invocation.md#errors)), `result` (the envelope), `at`.
|
|
82
|
+
- **`ApprovalRule`**, **`ApproverSpec`**: above.
|
|
83
|
+
|
|
84
|
+
## Guarantees
|
|
85
|
+
|
|
86
|
+
1. **Nothing runs before approval.** A matching call fails with `ApprovalRequired` and writes nothing but the request and its event.
|
|
87
|
+
2. **Approval binds the prepared call.** The input is recorded decoded-then-encoded with its sha256; what runs is that input, checked against the hash. The input cannot be changed after the request: a different input is a different request.
|
|
88
|
+
3. **At most once.** The execution's idempotency key derives from the request id; a crash between the decision and the execution, or after the call ran but before the step was recorded, never runs it twice; neither do repeated or concurrent approvals in several kernel processes. Only the kernel's own workflows can name an approved request (a module workflow's call is approved afresh), and the first execution pins its idempotency key on the request: naming it again under another key is `Forbidden`.
|
|
89
|
+
4. **As the requester, checked again.** The call runs with the requester's identity resolved at execution time: a requester who left is refused, and that is recorded on the request and in the audit log (outcome `denied`, surface `workflow`, the requester named).
|
|
90
|
+
4b. **Nothing unknown runs.** A request whose provenance was never recorded (one made before migration `approvals/0001_provenance`) is refused when approved: recorded as `refused` (`Forbidden`) on the request and audited `denied` as the requester's call, never executed.
|
|
91
|
+
4c. **Consent still stands.** An agent's consent-marked call that consent let through to a business approval runs only if that consent still stands when it executes: the request records what let it through (the person's approval of the call, or a remembered permission), and if the person has since revoked the permission (or the permission their approval remembered), the call is refused (`Forbidden`) and recorded.
|
|
92
|
+
4d. **Withdrawn and expired requests never run.** The requester withdraws a pending request with `approvals.withdraw` (status `withdrawn`; the approvers' items are dismissed and the requester notified); every request expires, after seven days unless its rule says otherwise.
|
|
93
|
+
4a. **As the call was made.** The approved call keeps its provenance: an agent's call executes as the agent's (a disabled agent tool group stays closed; a schedule it sets up is the agent's), a scoped credential's within its scope, a person's as the person's. Approval never widens a call, and never outlives anything it was asked under: the execution asserts the recorded chain inside its transaction ([Invocation](invocation.md#authority)): the API token, OAuth grant, agent session or device the call was made with, and an agent's consent (a remembered permission revoked, or a one-time consent the person withdrew with `consent.reject` while the request was pending, refuses it; the one-time consent is used up only as the approved call commits). A link that no longer holds refuses the call (`Unauthenticated`, or `Forbidden` for consent), recorded as `refused` on the request and audited `denied`, never executed; a revocation that commits while the execution waits for its targets waits for it instead. A person's own session is not kept: their approved call stands while they are a member. The same call made another way (an agent's, a narrower credential's) under the same key is another request. Requests recorded before provenance was kept (migration `approvals/0001_provenance`) execute as the requester with origin `system`, as before. Proven by [`packages/testing/test/provenance.test.ts`](../../packages/testing/test/provenance.test.ts) and by the surfaces property, which approves every held call on every surface.
|
|
94
|
+
5. **Eligibility at decision time.** Approvers are checked against the live directory when they decide (after waiting for the request, if they did), never the requester unless the rule allows it, on every surface; refusals are audited as `denied`.
|
|
95
|
+
5a. **An approver decides, never their agent.** `approvals.approve` from an agent (agent tools, MCP, or an agent session on any surface; on the agent tools whatever identity the caller hands them) is `Forbidden` and audited, whoever the agent acts for, before the request is read: approving runs another person's call, so what an agent reads (a request's input, a record, a message) cannot talk it into approving. An agent may still reject, which runs nothing. Before 2026-11-14 an eligible approver's agent could approve.
|
|
96
|
+
6. **Audit trail.** The request (`approval-required`), every decision (`approvals.approve` or `approvals.reject`) and the execution (surface `workflow`, as the requester) are audit records.
|
|
97
|
+
7. **Sync.** The requester and the members the request was shared with for deciding sync it (`approvals.requests`): the requester sees the status and the execution's result.
|
|
98
|
+
|
|
99
|
+
## Proposals
|
|
100
|
+
|
|
101
|
+
Where a business approval holds one call a rule matched, a **proposal** groups edits someone proposes for others to review (ledger A-110): the kernel module `proposalsModule` (`@eloxiv/kernel`; its records are kernel tables, migration `0170_proposals`), with `@eloxiv/contracts`' `Proposals.ts` for its shapes. The screens that present proposals (comments, review) are not built (decision 12); the contract is headless.
|
|
102
|
+
|
|
103
|
+
| Action | Who | What |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| `proposals.create` (operation `propose`) | a member | `summary`, `items` (each `summary`, `action`, `input`: a call of an action that writes, its input checked against the action's input schema), optional `creationKey` (the same key from the same person gives back the first proposal) |
|
|
106
|
+
| `proposals.revise` | its author | a pending item's new `input` (checked again), optional `summary`; its `revision` goes up |
|
|
107
|
+
| `proposals.withdraw` | its author | the proposal and its pending items are withdrawn |
|
|
108
|
+
| `proposals.get` | a member | the proposal with its items, each with its `status` (`pending`, `accepted`, `rejected`, `applied`, `withdrawn`), `revision`, decider and `applyKey` |
|
|
109
|
+
| `proposals.decide` (operation `decideProposal`) | a person, never an agent | `decisions`: an exact set of items, each `accept` or `reject` with the `observedRevision` the decider saw. All are decided in one transaction, or none: an item no longer pending, or revised since, refuses the whole decision (`InvalidInput`) |
|
|
110
|
+
| `proposals.applied` (operation `applied`) | the item's decider | records an accepted item applied, once the kernel finds the committed receipt of the decider's call of the item's action with its input under the item's key; refused before |
|
|
111
|
+
|
|
112
|
+
**Applying an item** is the decider's own call of the proposed edit, `item.action` with `item.input` under `item.applyKey` (`proposal-item:<id>:<revision>`), through the invocation path, so their policy, consent and audit apply as to any call, and a retry replays it instead of running it twice. Then `proposals.applied` records it with the call's invocation id. `applyProposalItem(options, item)` (`@eloxiv/client`) does both. Each item is decided and applied on its own: rejecting one, or failing to apply one, changes nothing of another. A proposal is its organisation's only; the actions confine every record to the acting organisation. Tested in [`proposals.test.ts`](../../packages/testing/test/proposals.test.ts).
|
|
113
|
+
|
|
114
|
+
## How an implementation is checked
|
|
115
|
+
|
|
116
|
+
`approvalsConformance(start)` registers, against the inbox conformance app ([`purchases`](../../packages/testing/src/conformance/purchases) with the inbox modules; subject: [`InboxSubject`](../../packages/testing/src/conformance/InboxSubject.ts)): no rule runs at once; a matching call is recorded with its input hash and audited, nothing written; every eligible approver gets a work item and a notification, never the requester; the requester and non-approvers are refused on every surface (in process, RPC, HTTP, MCP, agent tools) and audited; an eligible approver's agent is refused on the agent surfaces, and the approver's own decision then counts; approval runs the call exactly once as the requester, records the result, closes the items and tells the requester; approving twice counts once; rejection; quorum; expiry; an approver who lost the permission; a requester who left (refused and recorded); (kernel runner `approvals-races.test.ts`) a decision that waited for the request while the approver lost the role, or past its expiry, is refused; a retried call maps to the same request and a changed input to another; self-approval only where the rule allows it.
|
|
117
|
+
|
|
118
|
+
This kernel's own checks ([`approvals-kernel.test.ts`](../../packages/testing/test/approvals-kernel.test.ts)): an approved request executed again under another key is refused; a module workflow naming an approved request is asked for approval again; a call by the system actor is approved and runs as the system actor. Its process proofs: SIGKILL after the approved call committed but before its step was recorded, and between the decision and the execution, then restart: one order, the execution audited `succeeded` (then `replayed`); three rounds of approvals made at once on two kernel processes: one order each.
|
|
119
|
+
|
|
120
|
+
## Not yet guaranteed
|
|
121
|
+
|
|
122
|
+
- **Upgrade the kernel before the clients.** A client whose synced inbox tables include `title` (version 1.4.0) cannot sync against a kernel that has not added the column yet: zero-cache refuses the client's whole schema, not only the approval rows ([Sync: version skew](sync.md#version-skew)). Migrate the kernel, check that zero-cache publishes the column, then distribute the clients.
|
|
123
|
+
|
|
124
|
+
- **Approvers are resolved when the request is made.** Members who gain the permission later get no work item and no `decide` share, so they cannot decide it (an approver who loses it is refused). A request with no eligible approver can only expire.
|
|
125
|
+
- **The result envelope is stored on the request** for the requester to read; there is no retention policy yet.
|
|
126
|
+
- **Escalation and delegation** (reassigning an approval, reminders) are not built; the inbox's `reassign` moves the work item but not the right to decide.
|