@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,142 @@
|
|
|
1
|
+
# Release
|
|
2
|
+
|
|
3
|
+
How one deployment's kernel is released and migrated: migration ownership under a lease, module migrations on their owner's own session with the hardening after them, schema snapshots, security drift, client/server version skew, and the deployment topologies the kernel supports.
|
|
4
|
+
|
|
5
|
+
- Kind: kernel service. Version 1.1.0 (1.1.0 adds `SetupReport.repaired` and `ReleaseStatus.insecure`).
|
|
6
|
+
- Schema: [`packages/contracts/schema/contracts/Release.json`](../../packages/contracts/schema/contracts/Release.json) (source [`Release.ts`](../../packages/contracts/src/contracts/Release.ts)); `ClientOutdated` is in the standard error set ([`Errors.ts`](../../packages/contracts/src/Errors.ts)).
|
|
7
|
+
- Implementation: [`packages/kernel/src/Release.ts`](../../packages/kernel/src/Release.ts) (lease, migrate-and-harden, snapshots, the `Release` service), `setup` in [`Server.ts`](../../packages/kernel/src/Server.ts), bootstrap, owner sessions (`connectOwner`), closing (`closeModule`), hardening, role hygiene and the security state in [`db/Bootstrap.ts`](../../packages/kernel/src/db/Bootstrap.ts), the migration preflight in [`db/MigrationCheck.ts`](../../packages/kernel/src/db/MigrationCheck.ts), the version check in [`Invocation.ts`](../../packages/kernel/src/Invocation.ts). Tables `eloxiv.module_migration`, `eloxiv.release_lease`, `eloxiv.release_history`, `eloxiv.schema_snapshot`, and `eloxiv.module_hardening` (each module's hardening fingerprint and security state, kernel migration `0026_hardening_state`); the function `eloxiv_setup.record_migration` (kernel migration `0025_owner_migrations`), through which an owner session records its module's migrations.
|
|
8
|
+
- Kit: `@eloxiv/testing/conformance/Release` ([source](../../packages/testing/src/conformance/Release.ts)), with its fixture modules `stage` and `drift` ([`fixture/release`](../../packages/testing/src/conformance/fixture/release)).
|
|
9
|
+
|
|
10
|
+
## Operations
|
|
11
|
+
|
|
12
|
+
| Operation | Input | Output | What it does |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| `setup` | `{ owner?, waitMs? }` | `SetupReport` | Bootstrap and restore the module roles, take the lease, migrate each module on a session logged in as its owner, then in one transaction apply Better Auth's and the kernel's migrations and harden every module, repairing security drift; record snapshots and history; release the lease (guarantee 2). `repaired` lists the modules whose security state or roles had drifted and were restored. Fails with `ReleaseLeaseHeld` or `MigrationFailed` |
|
|
15
|
+
| `status` | `{}` | `ReleaseStatus` | `pending` migrations this build ships that the database has not applied (`<module>/<migration>`), `drifted` modules (the live schema differs from the recorded snapshot), `unrecorded` modules (never set up), `insecure` modules (security drift: the security state differs from what their last hardening left, including a module left closed by a failed setup) |
|
|
16
|
+
| `snapshots` | `{}` | `SchemaSnapshotRecord[]` | The snapshot fingerprint setup recorded per module, with the migrations it covered |
|
|
17
|
+
| `info` | `{}` | `ReleaseInfo` | What `GET /release` advertises: `kernelVersion`, `appVersion`, `minClientVersion`, each module's contract version and recorded schema fingerprint |
|
|
18
|
+
| `lease` | `{}` | `ReleaseLease` or null | Who holds the migration lease now |
|
|
19
|
+
| `history` | `{}` | `ReleaseRecord[]` | Every finished setup: owner, start and finish (database time), outcome, error, migrations applied |
|
|
20
|
+
|
|
21
|
+
In the kernel, `setup(app, options)` (run by `server/main.ts setup` through `runSetup`) is the operation, and the `Release` service (`status`, `snapshots`, `info`, `lease`, `history`) runs inside every kernel. `GET /release` is unauthenticated: it reveals versions and fingerprints, nothing about data.
|
|
22
|
+
|
|
23
|
+
### Errors
|
|
24
|
+
|
|
25
|
+
- **`ReleaseLeaseHeld`** `{ message, owner, acquiredAt, expiresAt }`: another setup holds the lease and did not release it within `waitMs` (default 120 s), or its lease expired while its session still holds the lock (a stuck setup; the message gives its backend pid). Nothing was changed.
|
|
26
|
+
- **`MigrationFailed`** `{ message, module, migration }`: a migration failed (`migration` names it, `module` is `eloxiv` for the kernel's own and `auth` for Better Auth's), a migration is refused by the preflight or is not declared as it must be, the checks or the hardening refused what the migrations left (`migration` is null), security drift that hardening cannot restore (`migration` is null), or the lease was lost. What the failure leaves is in guarantee 2.
|
|
27
|
+
- **`ClientOutdated`** `{ message, action, clientVersion, minClientVersion }` (HTTP 426), on every surface: an invocation that writes, from a client older than the minimum.
|
|
28
|
+
|
|
29
|
+
## Guarantees
|
|
30
|
+
|
|
31
|
+
1. **One setup at a time, and its work never outlives its lease.** Setup holds a session-level PostgreSQL advisory lock on the app's database for its whole run, and records itself in `eloxiv.release_lease` (owner, backend pid, acquired, expires). Everything setup does in the database itself after taking the lock (bootstrap, Better Auth's, the kernel's and Effect cluster's migrations, hardening, snapshots, history) runs on that one session, which never reconnects: if it is lost (for example terminated as a stuck setup), its transaction ends with it, before another setup can take the lock, and every later statement of the first setup fails. Every transaction on it, and every non-transactional migration, first checks that the session still holds the lock and is the recorded holder. A module's migrations run on an owner session of their own (guarantee 2), which checks, just before it commits, that the lease session's backend (its pid, passed from the lease) still holds the lock; and a setup that takes the lock first ends every session left in the database that logged in as an owner role (an owner role logs in only while a setup connects it, so each is a setup's; matched by role, since a migration can change its application name) and waits for them to go, before it records itself. So an owner transaction commits only if the lease session held the lock just before (a commit already sent when the lease is lost is the one race, and what it commits is closed and recorded, so the next setup carries on from it), and once a second setup holds the lease, no migration transaction of the first is still running. The expiry is renewed every third of its time to live (30 s by default) from a second connection, only while the holder's session is alive and still recorded. A second setup waits, polling, up to `waitMs`, then fails with `ReleaseLeaseHeld` naming the holder. A lock whose recorded lease has expired belongs to a stuck setup: the waiter reports it at once instead of waiting. The lock is released with its session, so a setup that crashes never blocks the next. The cluster-wide steps before the lease (roles, `CREATE DATABASE`) are idempotent and serialised by their own advisory locks.
|
|
32
|
+
2. **Module migrations run as their owner, and never open a module unhardened.** A module's migrations are not trusted with more than its owner role (agent-made MAKE modules use the same manifest and migrations), so they never run on setup's own session (a superuser's, or the setup role's on a managed host: [Database hosts](#database-hosts)). Each module with pending migrations gets a connection that logs in as its owner role: under the cluster's role lock (and that role's own login lock, which `status` reads), setup checks the role is still plain, gives it LOGIN and a fresh random password held only in memory, connects, and removes both again before releasing the lock (a failure to remove them fails the setup; the next setup removes them before anything logs in), so nothing else can log in as it with a password and no credential is stored. The password never leaves the process: setup sends PostgreSQL a SCRAM-SHA-256 verifier it computes itself (`ALTER ROLE ... PASSWORD 'SCRAM-SHA-256$...'`), in a statement it does not trace (a host that takes only plaintext passwords gets the password itself: [Database hosts](#database-hosts)). On that session there is no more privileged role to return to: `RESET ROLE`, `set_config('role', 'none', ...)` (directly, in a `DO` block or in a function the migration creates) and `SET SESSION AUTHORIZATION` all end at the owner. Module roles may not create temporary objects (`TEMPORARY` is revoked from `PUBLIC` on the database), and before anything runs every migration is parsed with PostgreSQL's own grammar (libpg-query, PostgreSQL 17), refusing transaction control (`BEGIN`, `START TRANSACTION`, `COMMIT`, `END`, `ROLLBACK`, `ABORT`, `SAVEPOINT`, `RELEASE`, `ROLLBACK TO`, `PREPARE TRANSACTION`, `COMMIT`/`ROLLBACK PREPARED`, `SET TRANSACTION`), changes of role or session (`SET`/`RESET ROLE`, `SET SESSION AUTHORIZATION`, `RESET ALL`, `DISCARD`) and SQL that does not parse, naming the module and migration; after each migration the owner session must still be in the same transaction (`txid_current()`) as the owner role. Setup runs in these steps, under the lease:
|
|
33
|
+
0. on setup's session, committed, after checking the kernel's own schemas are as the last setup left them (guarantee 5): each module's schema (empty until its migrations run, owned by its owner role, closed to everyone else; a schema that exists already but belongs to anyone else is never taken over, setup fails instead), anything the module's roles were given outside it revoked (privileges in the kernel's and Better Auth's schemas, `CREATE` and `TEMPORARY` on the database, per-role settings), and the migration plan: each module's pending migrations, the only names its owner session may record (`eloxiv_setup.record_migration` records a name once, for the module whose owner the session logged in as, and refuses any other, such as a `9999_future` that would make a later version skip it, and records only the migration setup is applying now, which setup marks before each one, so a migration cannot record a later one of its own module either);
|
|
34
|
+
1. for each module with pending migrations, one after another, on its owner session, in that session's own transaction: its published views dropped, each pending migration, recorded in the same transaction, then the module **closed** (row-level security enabled and forced on every table with every policy dropped, every privilege on the schema itself and on its tables, views, sequences, functions and procedures revoked from everyone but the owner, the runtime role included, every trigger enabled), checked for unsafe objects (guarantee 5), its views created and checked, and the lease confirmed; anything refused rolls the module's whole transaction back;
|
|
35
|
+
2. on setup's session, in one transaction: Better Auth's pending migrations (read through Better Auth's own migration planner, applied as the kernel role), the kernel's migrations (as the kernel role) and Effect cluster's storage migrations, then the hardening of every module (unsafe objects checked again, on a connection no migration touched; privileges, generated row-level security policies, write-log and key-guard triggers; the security state compared, repaired and recorded; the module roles held to their fixed state), the published views (granted, and checked again for the modules just migrated, before each module's state is recorded), the sync publication, the schema snapshots and the kernel's security state.
|
|
36
|
+
|
|
37
|
+
Statements run one at a time (each migration file's statements split with PostgreSQL's grammar). In a database zero-cache replicates, its DDL event triggers would run as the owner or kernel role and fail on zero-cache's own schema, so setup disables them for its run and enables its own instead, `eloxiv_setup_announce_ddl` (`ddl_command_end`, the command tags zero-cache's trigger handles), whose function runs as the setup role (a superuser, or on a managed host its administrative role) and does what zero-cache's trigger would have done, at each command's real position: inside a `DO` block, a function or a trigger fired by a write too, so zero-cache learns of each new table and column before any row written under it. It takes zero-cache's DDL serialisation lock first, as zero-cache's trigger does, and refuses a shard schema, or `update_schemas` function, that a trusted owner (a superuser or the setup role) does not own (setup refuses such a database before anything runs). When setup ends, however it ends, it disables its trigger and enables zero-cache's again on a fresh connection (the lease session may be the one that was lost), logging any failure; the next setup does it too, and `status` reports zero-cache's triggers disabled while no setup holds the lease (`insecure` names `zero-cache`). See [`db/ZeroDdl.ts`](../../packages/kernel/src/db/ZeroDdl.ts) and the evidence in [spikes/sync-and-rpc.md](../spikes/sync-and-rpc.md).
|
|
38
|
+
|
|
39
|
+
Every check reads the catalogue by qualified names (`pg_catalog.pg_cast`) with `pg_temp` last on the search path, so nothing in a session can shadow what it reads.
|
|
40
|
+
|
|
41
|
+
**What holds when setup fails.** Step 1 cannot be part of step 2's transaction: it runs on other sessions, and step 2 must see what step 1 committed to check and harden it. So each module's step 1 commits before step 2, and step 2 does no DDL until every step 1 has committed: an event trigger that serialises DDL (zero-cache's takes a transaction-level advisory lock on every `CREATE` or `ALTER TABLE`) would otherwise make an owner session wait for setup's own open transaction. Precisely:
|
|
42
|
+
- a migration the preflight refuses, or a failure in step 0, changes nothing (step 0 changes nothing a runtime role can reach: an empty, closed schema);
|
|
43
|
+
- a failure in a module's step 1 leaves that module exactly as it was, and nothing of step 2 applied (Better Auth's and the kernel's migrations included, also on a fresh database). Modules whose step 1 committed earlier in the same setup stay migrated and closed until a setup succeeds;
|
|
44
|
+
- a failure in step 2 (a kernel or Better Auth migration, a recheck that disagrees, a hardening statement, a lost lease, a crash) rolls step 2 back and leaves every module migrated in this setup applied, recorded and closed: row-level security forced with no policy, no privilege for anyone but the owner role (which cannot log in), no published view. Its runtime role reads and writes nothing; `status` reports it `insecure` and Readiness not ready, until a setup succeeds and hardens it.
|
|
45
|
+
|
|
46
|
+
At no time can a module's runtime role reach a table that migrations changed but hardening has not covered: the owner transaction that changes it also closes it, and only step 2's hardening, committed atomically with the recheck, opens it. The price: between a module's step 1 commit and step 2's commit (normally well under a second) the module is closed to running kernels as well, so their calls into it fail rather than see unhardened data. When no module migration is pending, step 2 is the only transaction. Every failure is recorded in the history.
|
|
47
|
+
3. **Non-transactional migrations are declared.** A module migration whose first line is `-- eloxiv:no-transaction` runs outside the transaction: after the round holding every migration before it has committed (with its hardening), on its own, statement by statement on the module's owner session (after the same lease check), and is recorded once all its statements succeed; a further round then applies the migrations after it and hardens again. Such a migration may hold only `CREATE [UNIQUE] INDEX CONCURRENTLY`, `DROP INDEX CONCURRENTLY` and `REINDEX ... CONCURRENTLY`. An undeclared migration with a statement PostgreSQL refuses in a transaction (anything `CONCURRENTLY`, `VACUUM`, `ALTER SYSTEM`, database, tablespace or subscription DDL, `REINDEX SYSTEM`/`DATABASE`, `CLUSTER` without a table), or a declared one with anything else, fails setup before anything runs. Both are decided from the parse tree, not the text.
|
|
48
|
+
4. **Schema snapshots.** After hardening, setup describes each module's schema (and the kernel's: `eloxiv`, `eloxiv_ctx`, `eloxiv_setup`, `eloxiv_cluster`) from the catalogue: relations with columns, owners and sorted privileges, constraints, indexes, views, triggers, policies and functions, with no object ids, and records it with its sha256 fingerprint and the migrations it covers. The same migrations give the same snapshot whether a database was built from scratch or upgraded step by step. `status` reports a schema changed outside setup as drifted.
|
|
49
|
+
5. **Unsafe objects are refused, and security drift is repaired, never recorded.** On the owner session and again on setup's session, setup refuses what would escape row-level security in a module schema: deferred or constraint triggers, `BEFORE UPDATE` row triggers other than the kernel's key guard, `SECURITY DEFINER` functions, rules, materialised views, views that are not `security_invoker`, foreign tables, foreign keys whose referential actions rewrite rows, casts to or from the module's types or through its functions, base types with their own I/O; and beyond the schema, event triggers calling a function in the module's schema or owned by its roles, and default privileges in its schema or for its roles (other software's event triggers, zero-cache's, are not affected). With each module's hardening, setup records the module's security state from the catalogue: the schema's and every relation's owner and privileges (column privileges included), row-level security enabled and forced, every policy (roles, command, expressions), every trigger and whether it is enabled, every function's owner, privileges, `SECURITY DEFINER`, body (hashed) and settings (`proconfig`), what the runtime role may use of `eloxiv_ctx`, the module's two roles' attributes and memberships in both directions, and the event triggers and default privileges that touch the module's schema or roles. Every setup compares the live state with it, even when nothing else changed (one catalogue query per module; no DDL when nothing drifted). If the state drifted, setup hardens the module again (it also revokes every privilege held by anyone but the owner and the runtime role, and re-enables its triggers) and reports it in `repaired`; if hardening cannot restore the recorded state (an object it does not manage changed: an owner, a trigger, a function), setup fails with `MigrationFailed` and changes nothing. **Role hygiene:** the module's roles are held to fixed values on every setup, whatever was recorded: no `SUPERUSER`, `BYPASSRLS`, `CREATEROLE`, `CREATEDB` or `REPLICATION`, no password, no `LOGIN` (`MODULE_ROLE_LOGIN`: the runtime role never logs in; the owner role only for the moment setup connects its migration session, under the cluster's role lock), and exactly one membership, the kernel role's in the runtime role (`INHERIT FALSE, SET TRUE`). Before the lease, under the role lock, setup restores all of it (`ALTER ROLE`, `REVOKE ... GRANTED BY`, `GRANT`) before any session logs in as the owner, and again in step 2's transaction (all but the owner's `LOGIN`, which only the role lock may change, since another database's setup may be connecting the same owner role); repairs are reported in `repaired`. The owner role's `LOGIN` is therefore not part of the recorded state. The module's state also records what its roles may do outside its schema, all held to nothing: privileges in the kernel's and Better Auth's schemas beyond what setup gives (the runtime role's use of `eloxiv_ctx`, the owner role's of `record_migration` and `announce_schema`), `CREATE` and `TEMPORARY` on the database (a temporary object would shadow the catalogue in the owner's session), and per-role settings (`ALTER ROLE ... SET`); setup revokes or resets them before any owner session connects (step 0) and reports the module in `repaired`. Its published views are recorded with it, so a module with views is not re-hardened on every setup. `status` also reports a module whose owner role can log in while no setup is connecting it (it reads the role's login lock). **The kernel's own schemas** (`eloxiv`, `eloxiv_ctx`, `eloxiv_setup`, `eloxiv_cluster`, and Better Auth's `auth`) are checked the same way against the state the last setup recorded, kept in `eloxiv_release.kernel_state`, which only the setup role can write (the kernel role reads it), with the host's profile (which protections setup applied): owners and privileges of anyone but module roles on schemas, relations, columns and routines, row-level security, every view's definition, every routine's body (hashed), settings and `SECURITY DEFINER`, every trigger on their tables, default privileges in them or of the kernel role, and that PUBLIC still may not run the catalogue functions setup revokes (below). Nothing but setup changes them, so a difference is refused before setup changes anything, naming each object, and is never recorded as the expected state; `status` reports it as `insecure` module `eloxiv`. A database that was set up before but has no record, or one in another format, is refused the same way: an operator who has checked the kernel's schemas re-baselines (setup's `rebaselineKernelState`, or `ELOXIV_SETUP_REBASELINE=1`), and setup records them as they are, logging what differed. **Catalogue functions:** PostgreSQL lets every role run some functions that no module needs and that reach beyond the module; setup revokes them from PUBLIC in the app's database (`REVOKED_CATALOG_FUNCTIONS`): `pg_logical_emit_message` (both forms; a forged `<app>/<shard>/ddl` message made zero-cache drop a kernel table from every replica) and the large-object constructors `lo_create`, `lo_creat` and `lo_from_bytea` (data stored outside the module's schema escapes its row-level security, hardening and snapshot). `status` reports drifted security as `insecure`, and [Readiness](readiness.md) as not ready.
|
|
50
|
+
6. **Version skew.** The kernel advertises `kernelVersion`, the app's `appVersion` and `minClientVersion` at `GET /release`. A client sends its version as `x-eloxiv-client-version` (the client SDK's `clientVersion` option). On MCP, an Eloxiv client (its MCP `initialize` names it `clientInfo.name` `eloxiv:<app or package>`, `MCP_CLIENT_NAME_PREFIX`) may instead declare it as `clientInfo.version`: the kernel uses it for that session's calls that send no header (the header wins). Other MCP clients' `clientInfo.version` is their own product's version and is ignored. An invocation of an action that is not `readOnly`, from a client whose version is older than `minClientVersion` (or is not a version), is refused with `ClientOutdated` before anything else runs, and audited as `denied`. Reads keep working: sync queries and read-only actions are not gated. Versions compare numerically by dot-separated parts; a prerelease is older than its release.
|
|
51
|
+
|
|
52
|
+
`KernelApp.release` declares `{ version, minClientVersion }`; `ELOXIV_APP_VERSION` and `ELOXIV_MIN_CLIENT_VERSION` override them at deployment. Without a minimum, nothing is refused.
|
|
53
|
+
|
|
54
|
+
## Deployment topologies
|
|
55
|
+
|
|
56
|
+
| Topology | What it is | What Release guarantees |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| **Single process** | One kernel process (`server/main.ts`) with PostgreSQL; `setup` (or `prepare`) before it starts | Everything above. Run setup before starting the new version: a kernel started against a database with pending migrations reports not ready ([Readiness](readiness.md)) |
|
|
59
|
+
| **Several kernel processes, one PostgreSQL** | Any number of kernels behind a load balancer, each a cluster runner (unique `ELOXIV_RUNNER_HOST`/`ELOXIV_RUNNER_PORT`) and an outbox dispatcher, on one database | One setup at a time however many processes or deploy jobs run it (the lease). Running kernels see a module either with its old schema and hardening, or closed (while its migrations are committed and step 2 has not, guarantee 2), or with its new schema and hardening; never migrated and open. Rolling deploys: run setup once, then replace kernels; migrations must stay compatible with the previous kernel version until every process runs the new one, and raising `minClientVersion` refuses writes from tabs built for the old schema while their reads keep working. Outbox dispatchers share work (`FOR UPDATE SKIP LOCKED`); cluster shards are spread over runners |
|
|
60
|
+
| **zero-cache placement** | zero-cache (Node only) next to the kernel or as its own service, replicating from the same PostgreSQL through the `eloxiv_sync` publication, calling the kernel's `/zero/query` | Setup changes the publication only when the set of module schemas changes, in step 2's transaction, so zero-cache sees one publication change per release. zero-cache must reach the kernel's query endpoint (any kernel process) and PostgreSQL's replication; with several zero-cache replicas keep lag reporting on. Replicas follow the organisation each client acts in; clients older than the minimum still sync |
|
|
61
|
+
|
|
62
|
+
### Under a base path
|
|
63
|
+
|
|
64
|
+
A kernel can serve under a path of its host (`https://app.example/eloxiv`) rather than at its root ([`BasePath.ts`](../../packages/kernel/src/BasePath.ts), ledger A-001):
|
|
65
|
+
|
|
66
|
+
- **`ELOXIV_BASE_URL` carries the path.** It is the URL clients use, and every absolute URL the kernel hands out is built from it: OAuth's issuer, endpoints and resources (`<base>/mcp`, `<base>/api`), the MCP challenge's `resource_metadata`, file part and download URLs, unsubscribe links, Connection callbacks, device pairing links. Paths it returns to clients (`make.view`'s `url`) are relative to it.
|
|
67
|
+
- **`ELOXIV_MOUNT_PATH`** is where requests arrive: by default the base URL's path, so the kernel itself serves under `/eloxiv`, and a request outside it reaches no route (`404`). Behind a proxy that strips the prefix, set it to `/`. Every route, guard and inventory sees the path without it.
|
|
68
|
+
- **Better Auth** routes `<base>/auth/*` (its base URL is `<ELOXIV_BASE_URL>/auth`); its cookies stay host-wide.
|
|
69
|
+
- **OAuth discovery**: the documents are served at `<base>/.well-known/...`, and also at the RFC 8414 and RFC 9728 places, the path after the well-known segment at the origin's root (`/.well-known/oauth-authorization-server/eloxiv`, `/.well-known/oauth-protected-resource/eloxiv/mcp`), which MCP clients look for. When a proxy fronts the kernel, route those to it too. The kernel's sign-in, consent and device pages post to and redirect under the base path.
|
|
70
|
+
- **zero-cache** calls `<ELOXIV_BASE_URL>/zero/query` and `/zero/mutate`; configure its URLs with the path.
|
|
71
|
+
- **Clients**: the client SDK's `baseUrl`, the CLI's `--url` and the shell's `VITE_ELOXIV_URL` are the base URL with its path and no trailing slash. Serving the shell itself under a sub-path is Vite's `base`, independent of the kernel's.
|
|
72
|
+
|
|
73
|
+
At root (the default) nothing changes. `packages/testing/test/base-path.test.ts` runs every surface under `/eloxiv`, nothing outside it, and the edge's rewrite for root, mounted and proxy-stripped deployments.
|
|
74
|
+
|
|
75
|
+
Setup also connects to the app's database as each module's owner role, at the admin URL's host and port with a one-time password. **Requirement:** the host must accept password logins (`scram-sha-256`) for the `eloxiv_own_*` roles from where setup runs, and nothing may let them in by anything but their password (`trust`, `peer`, `ident`, `cert`, `gss`, `sspi`, `ldap`, `pam`, `radius`, `bsd`, anything else): while setup lets an owner role log in, such a rule would let any process that can connect that way log in as it. Where setup can read `pg_hba.conf`'s rules (`pg_hba_file_rules`, a superuser's cluster) it checks them before each login window: with `ELOXIV_ENV=production` it refuses such a rule, naming its line; otherwise (local clusters trust local connections) it warns; `md5` and `password` still need the password but are weaker: setup warns about them. Where it cannot (a managed host), it tests the window instead, over the live connection: while the owner role can log in, setup tries to log in as it with a wrong password, from where setup runs, and a login that succeeds is refused in production and warned about otherwise. That proves what it can: the rules that apply to setup's own address and method. Rules for other addresses (another network, a Unix socket) cannot be seen from there and remain the operator's to keep, as this requirement says. Where the host accepts a SCRAM verifier as a password, only the verifier reaches the server, so a server that logs every statement logs no password.
|
|
76
|
+
|
|
77
|
+
### Database hosts
|
|
78
|
+
|
|
79
|
+
Setup runs as the role in `ELOXIV_ADMIN_DATABASE_URL`, the **setup role**. On a cluster the operator controls it is a superuser and everything above applies as written. A managed host (Neon, among others) has no superuser for its customers: its most privileged role is an ordinary role. Setup works with that role, without weakening any guarantee for untrusted code ([`db/Host.ts`](../../packages/kernel/src/db/Host.ts)):
|
|
80
|
+
|
|
81
|
+
- **What setup requires** of a setup role that is no superuser, refusing to start without it, before it changes anything: `CREATEROLE`, `CREATEDB`, `BYPASSRLS`, and reading `pg_authid` (whether a role has a password; `pg_read_all_data` gives it). Neon's `neondb_owner` has all four.
|
|
82
|
+
- **What setup detects**, on the admin connection, before anything changes: whether the host lets it revoke catalogue functions from PUBLIC, create event triggers (tried in a rolled-back transaction), store a SCRAM verifier as a role's password (tried on a throwaway role, unless `ELOXIV_DATABASE_ROLE_PASSWORDS` says; see below), read `pg_hba.conf`'s rules, and create schema-wide publications (a superuser only). It keeps every protection the host allows and records which it applied with the kernel's security state (`host` in `eloxiv_release.kernel_state`). A later setup on a host that allows less than the one recorded, or that runs as another setup role, is refused like any other kernel drift, until an operator re-baselines knowingly (`ELOXIV_SETUP_REBASELINE=1`): a protection never goes away quietly, for example when a database moves to another host.
|
|
83
|
+
- **The trusted owner.** What a superuser owned before, the setup role owns: setup's `SECURITY DEFINER` functions in `eloxiv_setup` (zero-cache's announcements and sync's push bookkeeping), its event trigger, and the kernel's recorded state (`eloxiv_release`). Where setup checked that something was a superuser's, it now checks that it is a **trusted owner's**: a superuser or the setup role, which could run that code itself with the same privileges, so running it confers nothing. zero-cache's shard schema and its `update_schemas` functions must be a trusted owner's for setup to run them (so on a managed host zero-cache runs as the setup role, as on Neon where it runs as `neondb_owner`); setup's own objects above must be a trusted owner's, or setup refuses to start (even when re-baselined). The trust rests on two checks, under the role lock, before setup changes any role: none of the kernel, query, platform and module roles is a member of the setup role, directly or not; and the kernel role is not the setup role, has no `SUPERUSER`, `CREATEROLE`, `CREATEDB` or `REPLICATION`, and is a member of no privileged role (one with those attributes or `BYPASSRLS`, a predefined `pg_*` role, the setup role), directly or through another role. A role created in Neon's console is a member of `neon_superuser` and is refused as the kernel role: create the kernel role through SQL, or let setup create it.
|
|
84
|
+
- **How setup acts as the roles it created.** Without a superuser, PostgreSQL lets setup act on an object only as its owner. Setup's role is therefore made a member of the kernel, platform-read and modules' roles it creates (`INHERIT TRUE, SET TRUE`; PostgreSQL also makes it a member with `ADMIN OPTION`, which it cannot revoke). The membership goes one way: those roles gain nothing from it, role hygiene accepts it (and only it, besides the kernel's in the runtime role), and the check above forbids the other direction. Giving a view or function to the runtime or platform role, which PostgreSQL allows a non-superuser only while the new owner may create in the schema, grants `CREATE` for that statement and revokes it in the same transaction.
|
|
85
|
+
|
|
86
|
+
| Protection | Where the host allows it | Where it does not (Neon, as of PostgreSQL 17.11, 2026-11-09) |
|
|
87
|
+
| --- | --- | --- |
|
|
88
|
+
| Catalogue functions revoked from PUBLIC (`REVOKED_CATALOG_FUNCTIONS`) | Revoked, the revocation verified (PostgreSQL only warns when a `REVOKE` revokes nothing), held as kernel state | PUBLIC keeps `EXECUTE` (the bootstrap superuser owns them). The only SQL a module role runs that the app did not write is MAKE's, and MAKE's SQL guard (an allowlist of statements and functions) and migration rules (only `CREATE TABLE`, `ADD COLUMN`, `CREATE INDEX`, a five-function allowlist in defaults) admit none of them; registry modules are trusted app code |
|
|
89
|
+
| Setup's own event trigger, announcing its DDL to zero-cache at each command's position | As above | Neon allows event triggers, so this applies there. A host that allows none (the local emulation, vanilla PostgreSQL) gets no trigger from setup, and zero-cache installs none either: it resets its replica on a schema change (a full resync of the replica and its clients; `zero-upgrade.test.ts` proves it on the emulation: zero-cache gives up its replica on the migration and, started again, serves the upgraded schema). Availability degrades, not access. Setup refuses a database whose zero-cache triggers it could not pause |
|
|
90
|
+
| SCRAM verifier as the owner's one-time password and MAKE roles' passwords | Only the verifier reaches the server | Neon takes only plaintext passwords ("Neon only supports being given plaintext passwords"). **Setup refuses to start** on such a host until the operator chooses plaintext (`ELOXIV_DATABASE_ROLE_PASSWORDS=plaintext`), and records the choice with the host's profile. What the choice means, below the table |
|
|
91
|
+
| `pg_hba.conf`'s rules for owner roles checked | Checked before each login window | Not readable (Neon revokes `pg_hba_file_rules`): the window is tested live (a wrong password must be refused); the requirement above stands for what setup cannot see |
|
|
92
|
+
| Sync publication over the modules' schemas | `FOR TABLES IN SCHEMA` | Neon creates but does not alter a schema publication without a superuser: the publication lists every table of the synced modules' schemas, as each setup leaves them; a table a migration creates joins it where it is created, through setup's event trigger, before its rows are written, so zero-cache follows it in order as it would a schema publication (added only after its rows, zero-cache had to backfill it, and refused a client meanwhile: found on Neon) |
|
|
93
|
+
| Owner session with no stored credential, no more privileged role to return to, the module closed until hardened | Applies | Applies unchanged: the owner role is still plain, logs in only for the moment setup connects it, and its session has no other role to reach |
|
|
94
|
+
|
|
95
|
+
**Plaintext role passwords: what an operator accepts.** Two kinds of password reach the server as text, over the setup connection (TLS), and from there whatever records statements: the host's `pg_stat_statements` (Neon keeps the statement's text), statement logs, and anything those are exported to.
|
|
96
|
+
|
|
97
|
+
- **Each module owner role's one-time password**, sent whenever setup migrates the module. Setup removes the owner's login and password before it lets go of the role lock, so a password read afterwards lets no one in.
|
|
98
|
+
- **Each MAKE module's runtime-role password, which is persistent.** It is derived from `ELOXIV_MAKE_ROLE_KEY` and the role's name, and kernels log in with it for every MAKE call. Closing the owner's window does nothing to it: whoever reads it can log in as that runtime role until the password changes. That includes roles that may read statement statistics (`pg_read_all_stats`, through `pg_monitor`) without administering roles, and whoever can read exported logs. The role reaches only its module's own tables, under row-level security that reads an invocation context only the kernel writes, so a direct login sees none of its rows (`make-sandbox.test.ts`), but it is a login all the same. To limit the exposure, setup sends a MAKE password only when the role does not already log in with it (a first install, or a new key), not on every setup.
|
|
99
|
+
- **Rotating MAKE passwords:** set a new `ELOXIV_MAKE_ROLE_KEY`, run setup (it sets every MAKE role's new password), then restart the kernels with the new key. Then clear what recorded the old text where you can: `SELECT pg_stat_statements_reset()` (on Neon, a role with `neon_superuser`), and the retention of exported logs.
|
|
100
|
+
|
|
101
|
+
On a host that takes SCRAM verifiers none of this applies: only the verifier reaches the server.
|
|
102
|
+
|
|
103
|
+
**Neon, in practice:** enable logical replication on the project; set `ELOXIV_DATABASE_ROLE_PASSWORDS=plaintext` once you accept the plaintext row above; point `ELOXIV_ADMIN_DATABASE_URL` at `neondb_owner` on the **direct** (not pooled) endpoint, with an explicit port (`:5432`; clients otherwise take `PGPORT` from the environment), since setup's lease and owner sessions need sessions of their own; let setup create the kernel role (`ELOXIV_DATABASE_URL` names a role that does not exist yet, with a password Neon accepts); run zero-cache as `neondb_owner` on the direct endpoint too. Neon's proxy drops every startup parameter it does not know, silently, and keeps `options`: the kernel therefore starts sessions that need settings (Effect cluster's search path; a MAKE session's search path and time limits) with `options=-c ...` ([`db/Startup.ts`](../../packages/kernel/src/db/Startup.ts)), and refuses a MAKE session that did not get its settings. zero-cache's `TimeZone=UTC` in its URL is such a parameter and is dropped there; Neon's sessions are in GMT already. Neon's control plane records each role setup creates (owner roles, kernel and module roles appear in the console). On Neon, `CREATE EVENT TRIGGER` also updates the creating role's own `pg_authid` row (measured: no other event-trigger, role or publication statement does), so two transactions creating an event trigger as `neondb_owner`, in any two of the project's databases, collide: the later waits for the earlier and fails with `tuple concurrently updated` (SQLSTATE `XX000`) once it commits. zero-cache creates its DDL triggers as that role, and another app's setup creates its own; setup's event-trigger probe (always rolled back) and the transaction that installs its trigger (which replaces what it creates) therefore run again on exactly that failure, a few times (`retryConcurrentCatalogUpdate`, [`db/SqlState.ts`](../../packages/kernel/src/db/SqlState.ts)). The CI job `live postgres (neon)` runs `packages/testing/test/managed-postgres.test.ts`, `setup.test.ts`, zero-cache's upgrade test (`zero-upgrade.test.ts`, with Neon's event triggers) and MAKE's lifecycle (`make-lifecycle.test.ts`) against a fresh Neon branch.
|
|
104
|
+
|
|
105
|
+
Not supported: several databases per app, PostgreSQL connection poolers in transaction mode for setup's connections (session advisory locks need a session; point the admin URL at PostgreSQL directly), and hosts without long-running processes.
|
|
106
|
+
|
|
107
|
+
## How an implementation is checked
|
|
108
|
+
|
|
109
|
+
`releaseConformance(start)` registers, with a subject that sets up fresh databases and serves the conformance fixture app with a minimum client version:
|
|
110
|
+
|
|
111
|
+
- setup applies pending migrations with their hardening (a table added by an upgrade is hardened as it commits), records the snapshot, and changes nothing the second time;
|
|
112
|
+
- **a migration that fails halfway** (`stage.broken`: its first statement succeeds, its second fails) leaves the module's schema, its privileges, policies, triggers and functions, what is pending and the recorded snapshots exactly as before; the failure names the module and migration and is in the history; the database still upgrades afterwards;
|
|
113
|
+
- **hardening that refuses** what a migration left (`stage.rogue`, a `SECURITY DEFINER` function) leaves everything exactly as before;
|
|
114
|
+
- **a migration that would `COMMIT` setup's transaction** (`stage.escape`: `CREATE TABLE`, `COMMIT`, then a failing statement) is refused before anything runs, naming transaction control; no table is left behind;
|
|
115
|
+
- **module identity** (`module-identity.test.ts`, in the kernel's own tests): a schema of PostgreSQL, Better Auth or the kernel, a module name `eloxiv`/`eloxiv_*`/`pg_*` or too long for its roles, two modules sharing a schema, and an entity outside its module's schema are refused before setup runs; an existing schema owned by someone else is never taken over; an owner session cannot record a migration its module does not ship;
|
|
116
|
+
- **a failure after a module's migrations committed** (`stage.misnamed`: a migration renames the column the generated policies filter on, so the hardening in step 2 fails) leaves the migration applied and recorded and the module closed (forced row-level security, no policy, no grantee but the owner, no view): its runtime role is denied every read and write, holds nothing at all on the schema (not the `USAGE` and `CREATE` the migration granted it), on its relations or on its routines (not the procedure the migration granted it), and `status` reports it `insecure`; the next setup that succeeds (`stage.renamed`) reopens it under its policies, without that `CREATE` or procedure;
|
|
117
|
+
- an undeclared `CREATE INDEX CONCURRENTLY` fails before anything runs, naming the declaration; a declared one runs on its own between the transactions around it, and the index is valid;
|
|
118
|
+
- **two concurrent setups serialise**: both succeed, one applies the migrations, the other applies nothing, and the second started after the first finished;
|
|
119
|
+
- a setup waits for a held lease and then fails with `ReleaseLeaseHeld` naming the holder; a waiting setup proceeds once the lease is released; a stuck holder (expired lease, lock still held) is reported at once;
|
|
120
|
+
- a database built from scratch and one upgraded step by step record the same snapshot fingerprints (the module's and the kernel's); a schema changed outside setup is reported as drifted;
|
|
121
|
+
- **security drift** (row-level security disabled or no longer forced, a policy dropped or a permissive one added, a privilege granted, the write-log trigger disabled) is reported as `insecure`, and the next setup, with nothing else to do, repairs it (`repaired`), leaves the schema exactly as hardened and records the hardened snapshot; a setup with nothing drifted repairs nothing;
|
|
122
|
+
- **role drift** on the fixture module `drift` (its own roles, since role state is cluster-wide): `BYPASSRLS`, `CREATEROLE`/`CREATEDB` or `LOGIN` given to a module role, the runtime role made a member of the owner role or of `pg_read_all_data`, the owner made a member of the runtime role, a kernel table or function or a Better Auth table granted to a module role, `TEMPORARY` and `CREATE` on the database granted to the owner role, a setting on a module role (for every database, or this one), the owner role left able to log in with a password: reported as `insecure`, repaired by the next setup;
|
|
123
|
+
- **kernel drift**: a kernel function's body replaced (`eloxiv_ctx.has_role`) is reported as `insecure` module `eloxiv`, setup refuses it naming the function, and it stays reported;
|
|
124
|
+
- a module with published query views records them with its state: a second setup repairs nothing; a migration that tries to become the superuser in a `DO` block to give the runtime role `BYPASSRLS` and the owner's membership fails (its session has no superuser to become) and leaves neither behind;
|
|
125
|
+
- a module function's body or settings changed, an event trigger calling a function owned by a module role, and default privileges for the owner role are reported as `insecure`, and setup refuses them;
|
|
126
|
+
- `GET /release` advertises the minimum client version; **a stale client's write is refused** with `ClientOutdated` through the typed client (RPC) and HTTP (426), nothing is written, and each refusal is audited as denied, **while its sync query is answered**; current, newer and unversioned clients write; a client version that is not a version is refused.
|
|
127
|
+
|
|
128
|
+
The Eloxiv kernel runs it in `packages/testing/test/release.test.ts`, which also checks that a fresh database records exactly the committed kernel snapshot ([`packages/kernel/src/db/schema.snapshot.json`](../../packages/kernel/src/db/schema.snapshot.json)) and that kernel migrations 0024 to 0026 change nothing when they run again under other recorded names; `registry/test/schema-snapshots.test.ts` does the same for the registry's modules (`registry/test/__snapshots__/`). After adding a migration, regenerate them with `vitest -u` and review the diff. `packages/testing/test/release-atomic.test.ts` is the backlog 11 reproduction, which fails against the earlier setup; it also checks that Better Auth's tables roll back with a fresh database's failed first setup. `packages/testing/test/release-lease-loss.test.ts` terminates the backend the lease records while the first setup's migration is held open on its owner session (`stage.blocking`) and requires that, once a second setup holds the lease, the first one's migration transaction has already ended. `packages/testing/test/migration-session.test.ts` proves that a migration cannot leave its owner role (`RESET ROLE`, `set_config` in a `DO` block or a created function, `SET SESSION AUTHORIZATION`), that the owner role holds nothing privileged and cannot log in after setup, and that temporary shadows of the catalogue blind none of the checks. `packages/kernel/test/migration-check.test.ts` covers the preflight statement by statement. `packages/testing/test/zero-upgrade.test.ts` upgrades a module (a new column and a new table, filled in the same migration), a kernel migration and Better Auth's DDL in a database zero-cache replicates, with zero-cache running and stopped, and requires a syncing client to receive what the migration wrote. `packages/testing/test/zero-ddl.test.ts` checks, against a stand-in shard, that each DDL command (a `DO` block's too) is announced where it happens under zero-cache's DDL lock, that a shard schema a superuser does not own is refused before any of its code runs, and that a setup that lost its lease still enables zero-cache's triggers again (with `status` reporting them while they were left disabled); `zero-upgrade.test.ts` proves the `DO` block live. `catalog-privileges.test.ts` refuses a migration that forges a logical message and holds the revoked functions as kernel state; `kernel-state.test.ts` covers the record's place, a missing record and re-baselining, column and default privileges and view definitions. `packages/testing/test/owner-login.test.ts` requires that no traced statement carries a password, that the SCRAM verifier is PostgreSQL's, and that production refuses a `trust` rule for owner roles. `packages/testing/test/managed-postgres.test.ts` covers [Database hosts](#database-hosts) on every profile: the host's profile recorded and each protection applied exactly where allowed (catalogue functions, setup's event trigger, the publication's form), module roles plain and the owner's window closed; a host that allows less, or another setup role, refused unless re-baselined; a kernel role that is the setup role or a member of `pg_read_all_data` refused; setup's own function given to the kernel role refused even when re-baselined; sync's push refusing a shard the kernel role owns and accepting one the setup role owns; the live test of the owner's window (refused on the local cluster's `trust` rules, passing where passwords are required); MAKE's guard and migration rules refusing every function a host may leave to PUBLIC; a setup role without `CREATEDB`, `BYPASSRLS` and `pg_authid` refused before any database exists. **The managed-host profile:** `tools/scripts/neon-emulate.sh` gives a local PostgreSQL 17 cluster Neon's privilege model (`neondb_owner` with `CREATEROLE`, `CREATEDB`, `REPLICATION`, `BYPASSRLS` and `neon_superuser`'s grants, SCRAM passwords for every role but the bootstrap superuser), and `ELOXIV_TEST_ADMIN_URL` runs the tests, setup and zero-cache as that role, never a superuser; the CI job `managed postgres (emulated)` runs the setup, release, sync, MAKE and privacy suites there on Bun and Node, and `live postgres (neon)` runs against a fresh branch of a real Neon project. What the emulation cannot reproduce (Neon's event triggers for its administrative role, its refusal of SCRAM verifiers) is covered by the real run; tests that stage a scenario only a superuser can (an event trigger, `pg_hba.conf`'s `trust` rules) skip on the emulation, saying why.
|
|
129
|
+
|
|
130
|
+
## Not yet guaranteed
|
|
131
|
+
|
|
132
|
+
- **Atomicity across a module's migrations and step 2**: they commit in separate transactions (guarantee 2); a failure in between leaves the module closed, not open, until a setup succeeds. Across modules, one module's committed step 1 stays (closed) when a later module's step 1 fails.
|
|
133
|
+
- **Compatibility of a migration with the previous kernel version** during a rolling deploy is the migration author's responsibility; setup does not check it.
|
|
134
|
+
- **Snapshots of the `auth` schema** (Better Auth's) are not recorded.
|
|
135
|
+
- **A failed non-transactional migration** may leave an invalid index behind (PostgreSQL's `CONCURRENTLY` semantics); it is not recorded, so the next setup runs it again, which is why it should start with `DROP INDEX CONCURRENTLY IF EXISTS`.
|
|
136
|
+
- **Clients that send no version** are not gated: an app that wants every client gated must send `clientVersion` from all of them (on MCP, the header or an `eloxiv:` `clientInfo`). An MCP client that is not an Eloxiv client and sends no header is not gated.
|
|
137
|
+
- **Security drift in the kernel's own schemas** (`eloxiv`, `eloxiv_ctx`, `eloxiv_setup`, `eloxiv_cluster`) shows as schema drift only; only module schemas are checked and repaired as security state.
|
|
138
|
+
- **Drift in objects hardening does not manage** (an owner, an extra trigger or function, a function's body or settings, an event trigger, default privileges) is refused, not repaired: an operator undoes it, then runs setup again.
|
|
139
|
+
- **A password given to an owner role outside setup without `LOGIN`** is not reported by `status` (the kernel role cannot read passwords; without `LOGIN` it lets no one in); the next setup removes it before anything logs in as the role, and reports the module in `repaired`. A `LOGIN` is reported.
|
|
140
|
+
- **zero-cache's DDL triggers while setup runs:** they are disabled for setup's run, and setup's own trigger announces all DDL in the database in that time, whoever runs it; DDL by anything but setup is not expected. If setup's process dies before it could enable them again (and the fresh connection that does it with it), they stay disabled until the next setup, and `status` reports `zero-cache`.
|
|
141
|
+
- **What every role may still do in the database:** `NOTIFY` (a statement, not a privilege: any session can notify any channel; the outbox dispatcher's channel only wakes it to look for work, so a spurious notification costs a poll), advisory locks (a migration or handler could take the lease's or the directory's lock and stall setup or directory writes for as long as it runs, no more than a `pg_sleep` could; handlers use them legitimately), `pg_terminate_backend` and `pg_cancel_backend` (only sessions of the same login role: an owner session's own), `set_config` (its own session), and catalogue functions guarded by their own checks (replication slots and origins need `REPLICATION` or superuser; `binary_upgrade_*` only work in binary-upgrade mode).
|
|
142
|
+
- **Module roles are cluster-wide**: a module role serves one kernel role per cluster (setup revokes any other role's membership in it), and two apps on one cluster with a module of the same name share its roles.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# ResultRendering
|
|
2
|
+
|
|
3
|
+
How action results and query-view rows are shown to people and to agents, with no UI in the kernel (decisions.md "Kernel contracts"; the ledger's A-114, B-035).
|
|
4
|
+
|
|
5
|
+
- Kind: kernel service. Version 1.1.0 (1.1.0 adds chart, metric, change and file renderers).
|
|
6
|
+
- Schema: [`packages/contracts/schema/contracts/ResultRendering.json`](../../packages/contracts/schema/contracts/ResultRendering.json) (source [`ResultRendering.ts`](../../packages/contracts/src/contracts/ResultRendering.ts); the declarations and pure functions in [`Render.ts`](../../packages/contracts/src/Render.ts)).
|
|
7
|
+
- Implementation: the manifest checks (`renderProblems` in `manifestProblems`), `moduleToJson`, and the agent surface's compact text ([`surfaces/Agent.ts`](../../packages/kernel/src/surfaces/Agent.ts)).
|
|
8
|
+
- Kit: `@eloxiv/testing/conformance/ResultRendering` ([source](../../packages/testing/src/conformance/ResultRendering.ts)).
|
|
9
|
+
|
|
10
|
+
## Declaring a renderer
|
|
11
|
+
|
|
12
|
+
A module declares a renderer per output schema: `render` on an action (its output) or on a published query view (its rows):
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
defineAction({
|
|
16
|
+
name: "journal.find",
|
|
17
|
+
output: Schema.Struct({ entries: Schema.Array(Entry), total: Schema.Number }),
|
|
18
|
+
render: { kind: "table", title: "Journal", rows: "entries", columns: [{ field: "title" }, { field: "id", label: "Entry", format: "id" }] },
|
|
19
|
+
...
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| Kind | Fields | Shows |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `table` | `rows` (the output's list field; omitted: the output is the list), `columns` (`{ field, label?, format? }`), `title?` | one row per record, the named columns only |
|
|
26
|
+
| `card` | `title`, `subtitle?`, `fields` | one record |
|
|
27
|
+
| `list` | `items?`, `title`, `subtitle?` | one line per item |
|
|
28
|
+
| `markdown` | `field` | the field's text |
|
|
29
|
+
| `chart` | `chart` (`bar`, `line`, `pie`), `rows?`, `x` (`{ field, label? }`), `series` (1 to 10 numeric fields), `title?` | one point per record: its `x` as text, each series as a number (null when the value is not one) |
|
|
30
|
+
| `metric` | `label`, `value`, `delta?`, `unit?` | one number that matters (an insight) and how it moved |
|
|
31
|
+
| `change` | `before`, `after`, `title?` | what changed |
|
|
32
|
+
| `file` | `file` (the field holding a Files id), `name?`, `mediaType?` | a file by reference: a UI shows or downloads it only through Files, under its read policy; an `image/*` one (but SVG) as an image |
|
|
33
|
+
| `progress` | `task` (the field holding a Progress task id), `label?` | work in progress: the UI follows the task through the [Progress](progress.md) contract |
|
|
34
|
+
|
|
35
|
+
Formats: `text`, `number`, `date`, `datetime`, `boolean`, `id`, `json`. The kernel checks every renderer against its schema at startup (`renderProblems`): a field the output (or each row) does not have, `rows` or `items` that is not a list of records, or an unknown kind refuses the app. Declared renderers are published in the module's manifest JSON (`render` on the action or query view).
|
|
36
|
+
|
|
37
|
+
## The headless view
|
|
38
|
+
|
|
39
|
+
`renderResult(declaration, encodedOutput, { maxRows? })` turns an output (as every surface returns it, inside the result envelope) into a `ResultView`: `table` (`columns` with labels and formats, `rows` with only the named fields, `totalRows`, `truncated`), `card`, `list`, `markdown` (`text`, `truncated`), `chart` (`x`, `series`, `points`, `totalPoints`, `truncated`), `metric`, `change`, `file` (`fileId`, `name`), or `json` when no renderer is declared or the output has another shape. A view only selects and labels what the output already holds, so rendering can neither show a caller more than the output nor fail a call. The shell and the chat UI draw views with their own components (registry UI); the kernel has none. The function is in `@eloxiv/contracts`, so the kernel, the client SDK and any UI share it.
|
|
40
|
+
|
|
41
|
+
## For agents
|
|
42
|
+
|
|
43
|
+
`compactResult(view, { maxChars?, maxRows? })` gives compact text: a markdown table, `Title — subtitle` lines, a card's `label: value` lines, or the markdown, never longer than `maxChars` (default 2,000) and at most `maxRows` rows (default 20), saying how much it left out (`(10 more rows not shown; 30 in all)`, `(cut at 2000 characters of …)`). The kernel's agent tools return it as `rendered` beside the full envelope for every action with a renderer, so the model reads the compact form first.
|
|
44
|
+
|
|
45
|
+
## Operations
|
|
46
|
+
|
|
47
|
+
| Operation | Where | Input | Output |
|
|
48
|
+
| --- | --- | --- | --- |
|
|
49
|
+
| `describe` | the module's manifest JSON (`render`) | an action or query view | its `RenderDeclaration`, or none |
|
|
50
|
+
| `render` | `renderResult` | a declaration and an encoded output | `ResultView` |
|
|
51
|
+
| `compact` | `compactResult`; the agent tool result's `rendered` | a view and a budget | text |
|
|
52
|
+
|
|
53
|
+
## How an implementation is checked
|
|
54
|
+
|
|
55
|
+
`resultRenderingConformance(start)` takes a `ServicesSubject` (see [Progress](progress.md#how-an-implementation-is-checked)); `journal.find` declares a table, `journal.summary` markdown, `journal.write` a card. The kit checks: renderers that do not fit (unknown column, a non-list `rows`, an unknown card field, an unknown kind) refused at startup and a fitting one accepted; renderers published in the manifest; the same view from the in-process, HTTP, RPC and MCP envelopes, with only the named fields (the entries' bodies never in it), bounded rows and the total; an output of another shape shown as JSON; the agent tool's compact text with its header, rows, the count of what was left out and no undeclared field, the envelope complete beside it, none for an action without a renderer, and the character budget held. The Eloxiv kernel runs it in [`packages/testing/test/result-rendering.test.ts`](../../packages/testing/test/result-rendering.test.ts).
|
|
56
|
+
|
|
57
|
+
## Not yet guaranteed
|
|
58
|
+
|
|
59
|
+
- **Extension results** are not a renderer kind (extensions are deferred). Chart, metric, change and file kinds are checked in [`result-rendering-kinds.test.ts`](../../packages/testing/test/result-rendering-kinds.test.ts).
|
|
60
|
+
- **MCP** clients get the structured result and the manifest's declaration, not the compact text.
|
|
61
|
+
- **The registry renderers** (shell and chat components drawing views) are registry UI, not built here.
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Sandbox
|
|
2
|
+
|
|
3
|
+
Running untrusted code: the handlers and views of MAKE modules, made by a person or the agent at runtime. Sandboxed code has no ambient authority. It computes with the language's built-ins and reaches the rest of the app only through the host functions its caller grants, each checked against the code's **capability profile**. This page also documents MAKE itself: the module source the sandbox runs, its lifecycle (draft, preview, approve, install, version, roll back), and the view runtime.
|
|
4
|
+
|
|
5
|
+
- Kind: kernel service. Version 2.3.0 (1.1.0: `CapabilityProfile.subscribe`, subscribers delivered, the view call's `key`, the MAKE RPCs; 1.2.0: a view's `slots`, and `make.slots`; 2.0.0: a view is code, not markup (`MakeCodeView`: an ES module run in the sandbox whose `render(state)` returns a view tree the shell draws in a frame where nothing runs or loads, `make.renderView`); an HTML view (`MakeHtmlView`) still loads but is no longer accepted in a draft nor rendered; 2.1.0, made on two branches at once: a source may leave out `manifest.events` and the profile's `emit`, `call`, `settings` and `view` when it has none, decoded as empty (build/make-authoring), and read programs, the kernel's `data` module's `data.run` and `data.status` (build/sandbox-data); 2.2.0: both together; 2.3.0: a MAKE action may declare `title`, what people see it called, one line of at most 80 characters, never shown where a person decides on a call).
|
|
6
|
+
- Schema: [`packages/contracts/schema/contracts/Sandbox.json`](../../packages/contracts/schema/contracts/Sandbox.json) (source [`Sandbox.ts`](../../packages/contracts/src/contracts/Sandbox.ts)).
|
|
7
|
+
- Implementation: the engine in [`packages/kernel/src/sandbox/Sandbox.ts`](../../packages/kernel/src/sandbox/Sandbox.ts) (QuickJS compiled to WebAssembly: `quickjs-emscripten-core` 0.32.0 with `@jitl/quickjs-wasmfile-release-sync` 0.32.0, exact-pinned; the same build runs on Bun and Node); MAKE in [`packages/kernel/src/make/`](../../packages/kernel/src/make): the source checks (`Manifest.ts`, `Validate.ts`), the SQL guard (`SqlGuard.ts`), a call (`Execute.ts`), the runtime (`Runtime.ts`), the lifecycle (`Lifecycle.ts`, the kernel's `make` module in `module.ts`) and the HTTP route (`Http.ts`); the shell's view host in the registry's shell item ([`shell-foldkit/src/makeView.ts`](../../registry/app/shell-foldkit/src/makeView.ts)) and its MAKE screen ([`src/make.ts`](../../registry/app/shell-foldkit/src/make.ts)).
|
|
8
|
+
- Kit: `@eloxiv/testing/conformance/Sandbox` ([source](../../packages/testing/src/conformance/Sandbox.ts)).
|
|
9
|
+
|
|
10
|
+
## Operations
|
|
11
|
+
|
|
12
|
+
| Operation | Input | Output | Errors | What it does |
|
|
13
|
+
| --- | --- | --- | --- | --- |
|
|
14
|
+
| `run` | `SandboxRun`: `code` (an ES module), `entry` (an export, or a dotted path into one: `actions.add`), `args` (JSON), `capabilities` (host function names), `limits` | `SandboxResult`: `value` (JSON; `null` for `undefined`) and `usage` (`wallMs`, `steps`, `hostCalls`) | `SandboxLimitExceeded`, `SandboxCodeFailed`, `SandboxCapabilityRefused` | Evaluates the module in a fresh interpreter and calls the entry; the granted host functions are `eloxiv.<name>(...args)` |
|
|
15
|
+
| `check` | `{ code }` | `{ exports }`: export names and, for exported objects, their function members | `SandboxLimitExceeded`, `SandboxCodeFailed` | Compiles and evaluates the module with nothing granted |
|
|
16
|
+
|
|
17
|
+
The kernel's engine (`runSandboxed`, `checkSandboxed`, the `Sandbox` service) runs each interpreter **off the kernel's event loop**, in a worker thread of a small pool ([`worker.ts`](../../packages/kernel/src/sandbox/worker.ts)): each worker has its own stack and, on Node, its own heap limits (`resourceLimits`; Bun does not enforce them, so there the host-call caps below are what bound a worker's heap), and a wall-clock kill (a run still going a second past its deadline has its worker terminated). A worker is discarded after any run that does not succeed and replaced as needed. The caller's host functions are Effects (run in the kernel) that answer JSON, refuse with `SandboxCapabilityRefused`, or fail with the caller's own error.
|
|
18
|
+
|
|
19
|
+
## Records and limits
|
|
20
|
+
|
|
21
|
+
- **`SandboxLimits`** (each a ceiling the run is stopped at): `timeMs` (wall time of the whole run, host calls included; default 2 s, at most 10 s), `memoryBytes` (the interpreter's heap; 16 MiB, at most 64 MiB: each run's interpreter is its own WebAssembly instance whose memory cannot grow past the build's 16 MiB base plus this, since QuickJS's own accounting cannot see allocation sizes under WebAssembly and once let a 2 MiB run reach 600 MiB of 4 KiB strings), `stackBytes` (256 KiB, also the ceiling: a deeper interpreter stack can overflow Node's own under WebAssembly), `steps` (the interpreter's interrupt checks, about one per few thousand bytecode operations, which bound computation whatever the clock does; 20 000, at most 200 000), `hostCalls` (200, at most 1 000), `outputBytes` (the JSON of the arguments, the result and each host call's arguments and answer, in UTF-8 bytes; 1 MiB, at most 4 MiB). `SANDBOX_DEFAULT_LIMITS` and `SANDBOX_MAX_LIMITS` publish them.
|
|
22
|
+
- **`SandboxLimitExceeded`** `{ limit: time | memory | stack | steps | hostCalls | output, message }`; **`SandboxCodeFailed`** `{ message }` (does not compile, threw, rejected, no such entry, never settled, a result that is not JSON); **`SandboxCapabilityRefused`** `{ capability, message }`; **`SandboxBusy`** `{ message }` (every interpreter stayed busy as long as the run could wait).
|
|
23
|
+
|
|
24
|
+
## Guarantees
|
|
25
|
+
|
|
26
|
+
1. **No ambient authority.** The interpreter has the ECMAScript built-ins and nothing else: no `fetch`, `XMLHttpRequest`, `WebSocket`, timers, `require`, `process`, file system or module loader (an `import` cannot resolve), and the native bridge is removed from the global object before the code runs. Its only way out is the frozen `eloxiv` object, whose functions are exactly the granted ones.
|
|
27
|
+
2. **Values cross only as JSON**, parsed on the other side, so no object of either side is shared; prototype pollution and globals stay in the run.
|
|
28
|
+
3. **Every run is fresh**: its runtime and context are created for it and disposed after it, so nothing passes between calls or callers.
|
|
29
|
+
4. **Every limit stops the run** at the first one reached, including a host call that outlives the time limit and code that awaits something that never settles.
|
|
30
|
+
5. **A refusal fails the run, even if the code caught it.** The first refusal (or caller error) of any host call is the run's outcome; nothing the code does afterwards turns it into a success. So does a run that returns while host calls it made still wait: none of them runs.
|
|
31
|
+
6. **A hostile run stops only itself, and never blocks its host.** Host calls are refused where the code makes them, before anything of them reaches the host, when the function was not granted, when more than 16 would wait, when their bytes would pass `outputBytes`, or when their arguments nest deeper than 64. Deep native recursion (`JSON.parse`, `JSON.stringify`, regular expressions), memory exhaustion and anything else that stops the interpreter end only that run, whose worker is replaced; the next run is unaffected, and the host answers throughout.
|
|
32
|
+
|
|
33
|
+
## Read programs (the kernel's `data` module)
|
|
34
|
+
|
|
35
|
+
A person, or their agent, runs JavaScript of their own in the sandbox to orchestrate reads: call module actions, read providers over their Connections, and keep what they found as bounded datasets to query again later. Install `dataModule` in `KernelApp.modules`; its actions are on every surface through the one invocation path, each audited. Implementation: [`data/Programs.ts`](../../packages/kernel/src/data/Programs.ts) and [`data/module.ts`](../../packages/kernel/src/data/module.ts); schemas in [`Data.ts`](../../packages/contracts/src/Data.ts).
|
|
36
|
+
|
|
37
|
+
| Operation | Input | Output | What it does |
|
|
38
|
+
| --- | --- | --- | --- |
|
|
39
|
+
| `runProgram`: `data.run` | `RunProgram`: `code` (an ES module, at most 64 KiB), `entry` (default `main`), `input` (JSON), `actions` (the read actions granted), `connections` (the person's Connections granted), `background` | `ProgramRun`: `runId`, `status` (`running`, `succeeded`, `failed`, `lost`), `value`, `error`, `usage`, `startedAt`, `finishedAt` | Runs the program under the sandbox's default limits with only these host functions: `eloxiv.read(action, input)`, `eloxiv.fetch(connectionId, request)`, `eloxiv.stage(name, rows)`, `eloxiv.staged(name)` and `eloxiv.query(name, sql)`. In the call, it answers when the program ends; in the background it answers `running` at once |
|
|
40
|
+
| `programStatus`: `data.status` | `{ runId }` | `ProgramRun` | How one of the caller's runs stands (a background run still `running` a minute after it started, cut off by a restart, is `lost`) |
|
|
41
|
+
|
|
42
|
+
- **Granted reads only, within what its caller may call.** `eloxiv.read` calls an action the run was granted, and its caller's scope covers (an agent limited to some tools grants a program none beyond them: the agent runtime writes a run's tools into the scope its calls act under), that is a module's (never a kernel module's: governance, consent, MAKE, `data` itself), read-only, and needs no consent; it runs through the invocation path as the person, under the authority of the call that started the run (bound with `bindDeferred`, never its session) and with its provenance, policy and audit as any call. `eloxiv.fetch` reads over one of the granted Connections (when the caller's scope covers `connections.apiRead`) with `connections.apiRead` as the person (their own Connection, `GET` or a reading `POST`, at most 5 pages). Anything else is refused, and a refusal fails the run (guarantee 5 above).
|
|
43
|
+
- **Reusable staged results.** `eloxiv.stage`, `eloxiv.staged` and `eloxiv.query` are the person's staged datasets ([Ingestion, "Staged datasets"](ingestion.md#staged-datasets)), so a later run, `data.query` or the person's agent reads what an earlier run kept without asking the provider again. In the call, stages commit with the call; in the background, each operation runs under the run's recorded authority, asserted in a transaction of its own and confirmed at its commit (`Authority.within`), so once a link no longer holds (a revoked token or agent session, a member removed) the program reads and stages nothing more. A query's result is measured in Postgres as it streams and refused past its limits before the kernel holds it.
|
|
44
|
+
- **Status.** Every run is recorded (`eloxiv.data_run`, migration `0160_sandbox_data`: status, value of at most 256 KiB, error, usage), for its person only, and kept a week.
|
|
45
|
+
- **Quotas.** At most `RUNS_PER_HOUR` (60) runs an hour per person and organisation, and `BACKGROUND_RUNS` (3) in the background at once, counted under the person's lock; past either, `Forbidden`.
|
|
46
|
+
|
|
47
|
+
## MAKE
|
|
48
|
+
|
|
49
|
+
A MAKE module uses **the same manifest as built-in modules**, in its language-neutral JSON form (what `moduleToJson` publishes), plus a capability profile, a sandbox and a lifecycle.
|
|
50
|
+
|
|
51
|
+
### The module source (`MakeModuleSource`)
|
|
52
|
+
|
|
53
|
+
- **`manifest`** (`MakeManifest`): `name` (`mk_<name>`: the module, its schema and its roles; unique in the app), `version` (semver), `cedarNamespace`, `entities` (each with `cedarType`, `table` `<module>.<table>`, `primaryKey`, `columns`, `policyAttributes`, `row` as JSON Schema, and optional `storage`: each field's column declaration as the JSON manifest form publishes an entity's, `{ column, type, nullable, sqlType }`, a field left out being `text`, `boolean`, `bigint`, `double precision` or `jsonb` by its row type and nullable unless required; setup holds the database to these declarations as it holds a built-in module to its Drizzle tables (decision 9), and a MAKE entity is never synced); and, for the Privacy contract, `dataSubjects` by entity name in the JSON manifest form (`{ fields, erase: delete | anonymise with `set` | retain with a `reason`, export?, notPersonal? }` or `{ none: reason, notPersonal? }`), checked as a built-in module's and required for every entity when the privacy module is installed, with every string, JSON or user-typed field (but the primary key and the organisation) classified in `fields` or `notPersonal`; data-subject requests export and erase those records with the kernel's statements run as the module's runtime role ([privacy.md](privacy.md#requests)), `actions` (by name `<module>.<action>`: `title` (one line, at most 80 characters; the module's own, untrusted words: where a person decides on a call, in consent and approval requests and their work items, notifications, push and email, the kernel shows its label of the action's id instead, the module first and never cut, `mk_todos: Urgent`, never the authored title, and every client computes it from the id for stored requests and events too), `description`, `writes`, `target`, `actsOn`, `organisationWide`, `bestEffort`, `hints`, `consent`, and `input`/`output` as JSON Schema) and `events` (`<module>.<event>`: `payload`).
|
|
54
|
+
- **`policy`**: the module's Cedar policy, in its own namespace.
|
|
55
|
+
- **`capabilities`** (`CapabilityProfile`): `sql.read` and `sql.write` (its own entities), `emit` (its own events), `call` (other app or MAKE modules' **read-only** actions that need no consent; never a kernel module's), `settings` (settings it reads), `view` (its own actions its view may ask for), `subscribe` (other modules' events its subscribers may handle: app modules', or MAKE modules' of its own organisation, never a kernel module's; optional, its own events need no listing), and optional `limits` within the kernel's ceilings.
|
|
56
|
+
- **`migrations`**: `{ name, sql }` in order (statements separated by `--> statement-breakpoint`).
|
|
57
|
+
- **`code`**: an ES module exporting `actions`, one async function per action: `async add(input, ctx)`, where `ctx` is `{ actor: { userId, orgId }, origin, invocationId }` (`origin`: `person`, `agent` or `system`, as the invocation path decided), and the host functions are `eloxiv.sql(text, params)`, `eloxiv.emit(type, payload)`, `eloxiv.call(action, input)` and `eloxiv.setting(key)`, each present only if the profile grants it.
|
|
58
|
+
- **`view`** (optional): `{ title, code, slots? }`, an ES module that runs in the sandbox and returns a view tree, drawn only by the view runtime below. A view written as HTML (`{ title, html }`, before views were code) is refused in a draft; one installed before still loads but no longer renders.
|
|
59
|
+
- **`sample`** (optional): rows per entity for the preview.
|
|
60
|
+
- **`subscribers`** (optional, at most 20): `{ id: <module>.<id>, event, entry: subscribers.<name> }`, each handling one of the module's own events or one its profile lists in `subscribe`. The code exports `subscribers`, one async function per entry: `async onAdded(payload, ctx)`, where `ctx` is `{ eventId, event, module, orgId, invocationId, attempt, origin: "system" }` (`attempt` counts its earlier failed attempts at this event). See [Subscribers](#subscribers).
|
|
61
|
+
|
|
62
|
+
### Checks at install
|
|
63
|
+
|
|
64
|
+
A source is checked twice: when it is drafted and again when its install runs (against what is installed then). Everything below is refused with the problem named:
|
|
65
|
+
|
|
66
|
+
- **The kernel's own checks of every module**, run unchanged on the module the source builds (the same `ModuleContract` and `KernelModule` a built-in module has): the manifests together with the app's (`manifestProblems`: names, namespaces, declarations), schemas and names (`moduleSchemaProblems`), durable ids, Cedar's strict validation, the policy scope rule (no action may reach records not tied to the actor), and the permissions a policy tests. A MAKE module's policy is validated, scoped and compiled **alone**: nothing it says can reach another module.
|
|
67
|
+
- **What only MAKE needs**: the `mk_` name and an entity table in the module's own schema; policy attributes are columns of Cedar primitives or of `Eloxiv::User`, `Eloxiv::Org` and `Eloxiv::Group` (never another module's records, never sharing sets); JSON Schemas import without patterns (an untrusted regular expression would run in the kernel's process); no table is named `pg_*`; the profile names only the module's own entities, events and actions, read-only actions of other installed app or MAKE modules that need no consent (a kernel module's action, such as `approvals.approve`, `make.install`, `consent.approve` or `sharing.grant`, is refused: the module's code would act on it as whoever calls the module, a confused deputy), declared settings, and limits within the ceilings; every event `subscribe` names is another installed app module's, or a MAKE module's of the same organisation (a kernel module's event, such as `approvals.requested`, is refused: it is the kernel's own business, and its payload is not the module's to read); every subscriber is named for the module, handles one of its own events or one `subscribe` lists, and has an entry `subscribers.<name>`; every action's key (after `<module>.`) is an identifier; the code loads in the sandbox and exports `actions.<name>` for every action and every subscriber's entry. A rollback runs the same checks of the earlier version against what is installed then. **A MAKE module is checked with the app's modules and its own organisation's MAKE modules only** (its agent and MCP tool names are resolved per caller's organisation), so another organisation's module never refuses it and its problems never name one; what is global, a module's name (its schema and roles) and its Cedar namespace, is refused as "unavailable", naming nothing else.
|
|
68
|
+
- **Migrations are additive and rollback-safe**, checked with PostgreSQL's grammar: only `CREATE TABLE`, `ALTER TABLE ... ADD COLUMN` and `CREATE [UNIQUE] INDEX` (columns only, btree) in the module's schema, with column types from an allowlist, constraints `NOT NULL`, `DEFAULT`, `CHECK`, `PRIMARY KEY`, `UNIQUE` and foreign keys within the schema with `NO ACTION`/`RESTRICT`; defaults built from constants, operators and `now()`/`gen_random_uuid()`; checks from constants and operators only (no function and no clock: a check that holds today and not tomorrow would make every later write fail). An added column is nullable or has a default, is never a key, and its check reads only it (the previous version's writes do not know it). A unique index is built only on a table the same version creates (over an earlier version's rows it could fail, or refuse that version's writes after a rollback). `COMMENT` and every other statement are refused. A new version's list starts with the previous version's migrations, unchanged, and its version is greater.
|
|
69
|
+
|
|
70
|
+
### A call
|
|
71
|
+
|
|
72
|
+
Every call of a MAKE action goes through the one invocation path: identity, policy (the module's own, compiled for the actor), consent, business approval, idempotency, execution, audit and the outbox. A MAKE module serves only the organisation that installed it. Then (`Execute.ts`):
|
|
73
|
+
|
|
74
|
+
1. **Its own session.** A connection of the module's own pool, logged in as the module's runtime role (never the kernel's connection: there is no more privileged role a statement could `RESET` to), begins a transaction. The kernel records, keyed by that transaction's id and committed on its own connection (the runtime role cannot write them): the invocation context (actor, organisation, action) row-level security reads, an exact action's targets, and the call itself (`eloxiv.make_call`: its invocation, its module, and the hash of a one-time ticket only the kernel holds). The session's search path is `pg_catalog` then the module's schema; it has statement, lock and idle-in-transaction timeouts.
|
|
75
|
+
2. **Idempotency.** With a key, the call claims it in this transaction (`eloxiv_ctx.make_claim`); a key another call holds (a concurrent claim waits for it) is answered with that call's receipt.
|
|
76
|
+
3. **Targets** are locked and authorised by the action's compiled filter before the code runs.
|
|
77
|
+
4. **The code** runs in the sandbox with the host functions its profile grants. `sql` sends one statement after the SQL guard accepts it (`SqlGuard.ts`, from PostgreSQL's parse tree): exactly one `SELECT`, `INSERT`, `UPDATE` or `DELETE` with its values as parameters, reading and writing only the entity tables the profile names, every node of an allowlisted kind, every function an allowlisted built-in, every cast to an allowlisted type, every qualified column reference a column of the module's tables (`b.to_jsonb`, functional notation for `to_jsonb(b)`, is refused); every table is then qualified with the module's schema before the statement is sent. `SET`/`RESET` (and so `RESET ROLE`, `SET ROLE`, `SET SESSION AUTHORIZATION`), `set_config`, `current_setting`, `pg_sleep`, `COPY`, `DO`, DDL, `WITH`, `SELECT ... INTO`, functions in `FROM`, session functions and names outside the module's schema are refused. **Results are capped in the database**: a statement that returns rows is wrapped so that at most 1 000 rows and `outputBytes` of their JSON come back, counted where they are produced; over either, no row is sent and the call fails. `emit` takes the module's own declared events (decoded with their schema); `call` runs another module's read-only action through the invocation path as the caller, **with the call's provenance** (its origin and agent session), in a transaction of its own (it writes nothing, so whether this call then commits changes nothing of it); `setting` reads a declared setting for the caller.
|
|
78
|
+
5. **Its output** is decoded with the action's output schema, and every row the transaction wrote (its write log, read inside the transaction through `eloxiv_ctx.transaction_writes()`) is held to the action contract exactly as a built-in handler's: only the module's entity tables, targets as declared, deletes of targets only, surviving rows satisfying the policy for the new row; an action hinted read-only writes nothing.
|
|
79
|
+
6. **One commit.** The kernel's records of the call (its receipt, its `succeeded` audit record, its events) are written in the same transaction by `eloxiv_ctx.make_finish`, which runs as the kernel role, only for the transaction's own call and with its ticket, taking the actor, organisation and action from the kernel's context row (never from its arguments) and refusing events of other modules' types; the receipt it commits names, by reference, every outbox row of the invocation (the events written just before it, and any the kernel published for the call), as an ordinary call's receipt does; then the transaction commits once. So the module's writes never commit without the kernel's audit record and events, nor the reverse; no prepared transaction, superuser or `max_prepared_transactions` is involved (Neon's default of 0 works). A commit whose answer was lost is decided by the database (`pg_xact_status` of the call's transaction). The functions are executable only by MAKE modules' runtime roles, and a session without the call's ticket gets nothing from them.
|
|
80
|
+
|
|
81
|
+
Anything else that goes wrong while the code runs is the call's failure (`ActionFailed`, with the invocation's reference), logged, and never answered with a kernel stack trace.
|
|
82
|
+
|
|
83
|
+
**Load.** No kernel transaction is open while a call runs: the kernel's connections are taken for single statements (the context and call records, a setting read in a transaction of its own), and an agent run's cancellation guard holds one from just before the commit until it is answered. A call holds one interpreter and one connection of its module's pool. Before it takes any of them it is admitted (`MAKE_CALL_LIMITS` in [`Runtime.ts`](../../packages/kernel/src/make/Runtime.ts)): one call per interpreter at once in a kernel process, an organisation at most half of them while another organisation's calls wait (alone, all of them), waiting calls admitted in turn across organisations, a wait of at most 10 s behind at most 32 others of the organisation, past which the call is refused as busy (`ActionFailed`), and at most 120 calls a minute per person and module (per process). A MAKE module serves one organisation, so its bound is its organisation's. Waiting is bounded everywhere: the kernel's pool (30 s, `KERNEL_POOL_WAIT_MS`), a module's pool (5 s), an interpreter (10 s, `SANDBOX_WAIT_MS`; `SandboxBusy` past it). A nested call (a MAKE call's code calling another MAKE module's read-only action) runs within its caller's admission and only if an interpreter is free at once, so nested calls never wait on each other. Drafts, previews and view steps (`make.renderView`, which runs a view's code in the sandbox) are admitted the same way before their transaction (two at once per process, one per organisation while another waits), and their per-person rate limit is counted under a transaction-scoped lock, in every process. The kernel's records of a call that a crash left behind (context, targets, call rows of transactions no longer running) are swept at start and every five minutes.
|
|
84
|
+
|
|
85
|
+
### Subscribers
|
|
86
|
+
|
|
87
|
+
The outbox dispatcher delivers an event to every subscriber of the MAKE modules **installed in the event's organisation** that handles its type, at the version each module runs now (read on every delivery, so a rollback to a version without the subscriber, or a new version, takes effect at once), beside the built-in subscribers, triggers and kernel reactions (`MakeSubscriptions` in [`Outbox.ts`](../../packages/kernel/src/Outbox.ts), [`Subscribe.ts`](../../packages/kernel/src/make/Subscribe.ts)). A delivery runs like a call, with what a built-in subscriber has and nothing more:
|
|
88
|
+
|
|
89
|
+
1. **Its own session**, the module's runtime role, in a transaction. The kernel records, keyed by that transaction and committed on its own connection, the context row-level security reads: the system actor, the event's organisation and the subscriber branch (`$subscriber`), as for every built-in subscriber, so the module's policies let it read and write only rows of that organisation; and the delivery (`eloxiv.make_call`, with the hash of a one-time ticket, the event and the subscriber).
|
|
90
|
+
2. **The code** runs in the sandbox under the module's limits, with `eloxiv.sql` only (the tables its profile names, the SQL guard, results capped in the database). A subscriber emits no event, calls no action and reads no setting: it acts as the system, so it starts no further work of its own, and there is nothing to bind to an authority (`bindDeferred` is for deferred work a call starts; a subscriber starts none).
|
|
91
|
+
3. **Its writes** are held to the module's entity tables.
|
|
92
|
+
4. **Exactly once.** `eloxiv_ctx.make_deliver` records the delivery's success (`outbox_delivery`, as `make:<subscriber id>`: MAKE subscribers' delivery records are a namespace of their own, and no app module's subscriber may be named `mk_*` or take the `make:` form) in the module's transaction, for the event and subscriber the kernel wrote on the delivery's record, with its ticket (a call's ticket never answers it, nor a delivery's the call functions); then the transaction commits once. The module's writes and the record that the event reached the subscriber commit together, so a subscriber runs once per event, however often the dispatcher passes; a failure (the code's, a limit, a refusal) rolls everything back and the delivery is retried under the default delivery policy (backoff, at most 20 attempts, then a dead letter its organisation's administrators can retry or discard). The dispatcher claims events `FOR NO KEY UPDATE`, which the delivery record's reference to its event does not wait for.
|
|
93
|
+
|
|
94
|
+
Deliveries are admitted like calls (as the organisation's system actor).
|
|
95
|
+
|
|
96
|
+
**What a subscriber sees, and acts as, said plainly.** Once an administrator approves a module whose profile lists an event in `subscribe` (or that subscribes to its own events), its subscribers:
|
|
97
|
+
|
|
98
|
+
- act with **the organisation's system authority**, not any person's: row-level security's subscriber branch lets them read and write the module's rows of the event's organisation, whoever caused the event;
|
|
99
|
+
- receive **every such event's whole payload**, with no per-person filter: an event a person's call emitted reaches the subscriber with everything its payload holds, whether or not that person could have shown it to whoever made the module;
|
|
100
|
+
- are delivered **in no guaranteed order**: events of one type, or of one record, may reach a subscriber in another order than they were emitted, and a retried delivery after later ones;
|
|
101
|
+
- start no further work (no `emit`, `call` or `setting`).
|
|
102
|
+
|
|
103
|
+
`make.draft` answers a module with subscribers with its **subscriptions notice** (`subscriptions`: the events, and the three facts above, in one sentence); `make.install` must repeat it exactly, so the approval request the administrator decides shows it beside the hash and the profile. An install that leaves it out, or changes it, installs nothing.
|
|
104
|
+
|
|
105
|
+
**Fan-out.** At most `MAKE_SUBSCRIBERS_PER_EVENT` (20) subscribers per event type across the MAKE modules of one organisation (each module at most 20 in all), checked at draft, install and rollback, counted within the organisation only; the dispatcher delivers to no more.
|
|
106
|
+
|
|
107
|
+
**Versions change under no delivery or call.** An install, a version bump and a rollback take the module's version lock (`MAKE_VERSION_LOCK`, per module) exclusively, in their own transaction. A delivery, once admitted, holds it shared in the dispatcher's transaction and only then reads the version the module runs, its subscribers and its capability profile: a subscriber that version no longer has (or that no longer handles or may read the event) is recorded as delivered and never run, and while a change runs the attempt fails and is retried. A call holds it shared in the kernel transaction that encloses the module's and is refused (`ActionFailed`, "changed version") when a change replaced the version it looked up while it was admitted or waited; a nested call never waits for it (refused as busy). So no version's code or profile runs after a change of version has returned, and none commits after one began. A view's steps run the code of the version installed when each step runs, so a rollback changes an open view at its next step.
|
|
108
|
+
|
|
109
|
+
### The lifecycle (the kernel's `make` module)
|
|
110
|
+
|
|
111
|
+
| Action | Who | What it does |
|
|
112
|
+
| --- | --- | --- |
|
|
113
|
+
| `make.draft` `{ source }` | members (and their agent), at most 20 a minute each | Stores the source with its hash and every problem the checks find; a draft with problems is kept so the drafter can fix it in a new one. Its description (what an agent reads) leads with a worked example, a notes module that drafts, previews and installs as printed (`MAKE_EXAMPLE_SOURCE`, [`Example.ts`](../../packages/kernel/src/make/Example.ts)). A source is read as its author meant it before it is decoded ([`Repair.ts`](../../packages/kernel/src/make/Repair.ts)): given as JSON text, it is that JSON; with one closing brace misplaced, a key the source or its manifest requires but lacks (`manifest`, `policy`, `capabilities`, `migrations`, `code`; `name`, `version`, `cedarNamespace`, `entities`, `actions`) is taken from the one place it landed in, never from inside a JSON Schema, the columns, a migration, the view or the sample data. Nothing is guessed or dropped: a required key found in more than one place, or a module-level key (`policy`, `capabilities`, `migrations`, `code`, `view`, `entities`, `actions` and the rest) anywhere but its own place, is refused (`InvalidInput`) with every place named, since decoding would otherwise drop it unseen by the approver (an empty one, most often an `events: {}` past a misplaced brace, is answered "leave it out"; the example leaves out what it has none of, so there is nothing after its actions to misplace). The result is checked as any source and is what is hashed, previewed and approved. A source that still does not decode is refused (`InvalidInput`) with every problem at once, each naming its path, what was given and what belongs there, from the source schema (`["source"]["manifest"]["actions"]["x.add"] is a string: write an object with description, input, output (optional: …) there`; `… ["description"] is missing: write a string there`) |
|
|
114
|
+
| `make.preview` `{ draftId, calls }` (at least one call) | members, at most 10 a minute each | Sets the draft up in a preview database of its own (a scratch database with the kernel's schemas and the draft's module, set up exactly as an install sets it up), inserts its sample data (the organisation and the person filled in), runs the calls as the caller there (the same execution as a real call; `call` and `setting` are refused in a preview) and reports each call's output or error, the rows left and the events emitted. Only the kernel and the module's runtime role may connect to the preview's database; it is dropped afterwards, with the module's roles when the module is not installed (previews, installs and rollbacks of one module are serialised across the cluster, and every setup holds the module's role lock from creating its roles until it has used them, so a preview elsewhere never drops a role a setup has just made: `packages/testing/test/make-role-race.test.ts`). Only a draft without problems |
|
|
115
|
+
| `make.install` `{ draftId, module, version, hash, capabilities }` | members ask; **an organisation administrator approves** (the module's approval rule, never the requester), seeing the source hash and the capability profile in the request | Installs a draft with a successful preview, only if the request names the draft's own module, version, hash and capability profile, as its module's next version (its first, or a version bump with its new migrations) by running setup with it, then records the version as the one the module runs. Runs once, by the approval workflow, when approved |
|
|
116
|
+
| `make.rollback` `{ module }` | organisation administrators (an agent's call needs the person's consent) | Runs the version installed before the current one again, by setup |
|
|
117
|
+
| `make.slots` | members | The organisation's MAKE views contributed to the app's slots: each installed module's current version's `view.slots` (`{ slot, order? }`, each a slot an installed module declares with `accepts: "view"`; a draft naming another, a command slot, or a slot twice has problems), as `{ slot, module, version, title, order }` in the [Slot](slot.md) order (`order` ascending, unordered after, then installation order: when each module was first installed, kept across version bumps and rollbacks). A slot the app no longer declares is left out. `makeSlot(contributions, slot)` (`@eloxiv/client`) gives one slot's entries, its ties in the order `make.slots` answered; a shell shows each with `make.view` and `make.renderView` |
|
|
118
|
+
| `make.list`, `make.view` | members | The organisation's modules (the version each runs, every version) and drafts; a module's view (its title; none for a view written as HTML) and the actions it may call |
|
|
119
|
+
| `make.renderView` `{ module, version, state, message }` | members, admitted like drafts and previews | One step of a module's view (below): its code in the sandbox, `init()` (no message) or `update(state, message)`, then `render(state)`; answers `{ state, calls, tree }`. `version` is the one `make.view` answered: once another is installed the step is refused (`InvalidInput`), so a view's code never runs against another version's list of the actions it may call, and the shell stops the view (open it again) |
|
|
120
|
+
|
|
121
|
+
**Install is setup.** The kernel runs the same setup an app's release runs, in its own process, with the module's new version among the installed MAKE modules, so its schema, its owner and runtime roles, its migrations (on a session logged in as its owner), its hardening (row-level security generated from its own policy, privileges, the write log and the key guard) and its recorded security state are exactly a built-in module's. Every later setup of the app includes the installed MAKE modules too (read from the database) and holds them to that state. A MAKE module's runtime role logs in, with a password derived (HKDF-SHA-256) from the deployment's MAKE role key (`ELOXIV_MAKE_ROLE_KEY`, required in production; in development derived from `ELOXIV_AUTH_SECRET`) and the role's name, set by every setup as a SCRAM verifier and stored nowhere (on a host that takes only plaintext passwords, such as Neon, as the password itself: [Release, Database hosts](release.md#database-hosts)). MAKE modules are not synced to replicas. Installs and rollbacks are serialised across kernel processes.
|
|
122
|
+
|
|
123
|
+
**What install needs of the setup role.** Install, rollback and preview run setup, which uses the deployment's setup connection (`ELOXIV_ADMIN_DATABASE_URL`) for what setup always needs it for: creating and holding the module's two roles (attributes, memberships, passwords), owner sessions' one-time logins, the module's schema, privileges and row-level security, the migration lease, and (for a preview) creating and dropping a database and writing its sample rows past row-level security. All of it is behind one interface, `MakeSetup` (`install`, `preview`) in [`Lifecycle.ts`](../../packages/kernel/src/make/Lifecycle.ts), built in `Server.ts`. The setup role need not be a superuser: on a managed host (Neon's `neondb_owner`, with `CREATEROLE`, `CREATEDB` and `BYPASSRLS`) setup works as [Release, Database hosts](release.md#database-hosts) describes, and MAKE's install, rollback and preview with it (`make-lifecycle.test.ts` runs on the emulation of Neon's privilege model in CI; the catalogue functions Neon leaves to PUBLIC are refused by MAKE's guard and migration rules, `managed-postgres.test.ts`). Calls of installed modules need none of it.
|
|
124
|
+
|
|
125
|
+
**Versions and rollback.** Versions are additive (above), so a rollback restores the previous version's code, policy and capability profile **over the same schema**: no down-migration runs and no data is lost. The columns the newer version added stay (nullable or defaulted, so the older code's writes succeed); the tables it added stay with their rows, but no entity of the older version governs them, so its runtime role has no policy on them and reaches nothing in them (the guard refuses them too). Its migrations stay recorded. Installing the newer version again (the same content, or a later version) finds them as they were. A version number, once installed, keeps its content.
|
|
126
|
+
|
|
127
|
+
### The view runtime
|
|
128
|
+
|
|
129
|
+
A MAKE view is untrusted code, and it never runs in the browser (decisions: "No iframes, except sandboxed MAKE views"; MAKE's sandbox is QuickJS-WASM). Threat SB-7 (a view sending out what its actions return by navigating its own frame) is closed by keeping the code out of the frame altogether:
|
|
130
|
+
|
|
131
|
+
- **The code runs in the sandbox.** `make.renderView` (members of the installing organisation) runs the view's ES module in a fresh interpreter with nothing granted: no host function (no SQL, events, calls or settings), and the sandbox has no DOM, network, timers or modules. A step runs `init()` (the first, with no message) or `update(state, message)`, then `render(state)` (`ViewStep.ts`). `init` and `update` return `{ state?, calls? }`: the view's next state (JSON, kept by the shell and passed back with the next step) and the calls of its module's own actions it asks for (`{ id, action, input, key? }`). `message` is an event of its tree (`{ type: "event", name, data?, value?, fields }`) or a call's result (`{ type: "result", id, ok, result | error }`). Everything it returns is decoded against the contract (`MakeViewStep`, with a property or key the contract does not name refused, never dropped) and held to at most 5,000 nodes 64 deep; anything else fails the step.
|
|
132
|
+
- **What reaches the browser is a tree.** A node is text (a string or number), nothing (`null`, `false`), or `{ tag, props?, children?, on?, data? }`, with `tag` one of `MAKE_VIEW_TAGS` (text and layout elements, tables, `label`, `form`, `button`, `link`, `input`, `textarea`, `select`, `option`) and `props` among `MAKE_VIEW_PROPS` (`class`, `title`, `style`, `placeholder`, `value`, `checked`, `selected`, `disabled`, `name`, `type`, `min`, `max`, `step`, `rows`, `colspan`, `rowspan`, `ariaLabel`): none names a URL.
|
|
133
|
+
- **The shell draws it where nothing runs and nothing loads** (`mountMakeView`, `shell-foldkit` 0.4.0): an iframe sandboxed with `allow-same-origin` only (`MAKE_VIEW_SANDBOX`: no scripts, forms, popups or navigation of the shell; `allow-same-origin` lets the host, never the frame, draw into the frame's document and read its fields), under the view CSP (`MAKE_VIEW_CSP`, as the document's `<meta>` and the iframe's `csp` attribute): no script, image, media, font, frame, object, connection, form submission or base URL; inline style only. The host draws only the tree's elements and properties, text as text nodes, an input's `type` among `MAKE_VIEW_INPUT_TYPES` (never `file`, `image`, `submit` or `reset`), `style` held to a few CSS properties with plain values (no `url()`, escapes or quotes) of at most 200 characters each (4,000 in all), read in one linear pass, a `form` as a group of fields that is never submitted.
|
|
134
|
+
- **Controls are the host's.** A `button` or `link` with `on` is a link to a fragment of the frame's own document (`about:srcdoc#e-<n>`, the host's own counter, never the view's text): activating it (a click, or Enter) is a same-document fragment change that sends nothing anywhere; the host reads the frame's fragment from its own side, resets it, and sends the view's `update` the event with its `data` and the values of the named fields of its form (or the whole view outside one). A field with `on` is reported when its value changes, with `value`. The host registers no listener in the frame: an engine with scripts off in a frame runs none there (WebKit, the desktop hosts' engine).
|
|
135
|
+
- **Calls are the shell's.** The host makes a call the view asks for only for an action its capability profile lists (`capabilities.view`, from `make.view`), as the signed-in person through the invocation path (the kernel authorises it like any call), under an idempotency key, and refuses any other without a request (the view's `update` gets a `Forbidden` result). **`key`** (1 to 128 URL-safe characters, `MAKE_VIEW_KEY`) is the view's own, the same on every retry of one request and **unique per call** (two calls that reuse a key with the same action and input share one receipt): a retry after a lost answer is answered with the first call's result. The host namespaces it by the mount (`make-view:<instance>:<key>`, the instance new each time it mounts the view), so two tabs or two mounts never share a receipt; a call without one gets a fresh key. **A view key is an idempotency key, not authority.** Each result goes back to the view's `update` through the kernel, never to code in the browser.
|
|
136
|
+
|
|
137
|
+
So nothing of a view's runs in the browser, and nothing in its frame can navigate it or load a URL: what its listed actions return can reach only the person's own screen.
|
|
138
|
+
|
|
139
|
+
The shell item provides the host (`mountMakeView`) and the MAKE screen at `/make/<module>`: a Foldkit Submodel whose Command reads `make.view` as the signed-in session in the selected organisation, and nothing else; its Mount runs `mountMakeView` on the screen's container for that element's lifetime (the view's steps through `make.renderView`, its calls as the session in that organisation), so the frame goes when the screen is discarded (another route, organisation or session); a view that fails is reported to the screen. **Opening a view runs only its `init`**, in the sandbox; the calls it asks for there are its own, made like any other. The session is a handle into the shell's credentials; the token is read only when a request is made.
|
|
140
|
+
|
|
141
|
+
### Native hosts
|
|
142
|
+
|
|
143
|
+
A native host draws the same tree with its own controls, with no web engine at all; the registry's Rune host is one ([`desktop-rune`](../registry/desktop-rune.md), [`app/src/make/`](../../registry/app/desktop-rune/app/src/make)). The view's code runs where it always does, in the kernel's sandbox (`make.renderView`, reached through the daemon's LocalClient `actions` route as the signed-in person in the selected organisation), and the contract is the one above: the tree decoded against `MakeViewStep` (its types generated from the code generation bundle [`codegen/Sandbox.json`](../../packages/contracts/schema/codegen/Sandbox.json), which names the tree's node, element, props and calls: `MakeViewNode`, `MakeViewElement`, `MakeViewProps`, `MakeViewPropValue`, `MakeViewCall`) and held to 5,000 nodes and 64 levels, steps one at a time from the state the last one returned, calls only of the actions `make.view` listed (any other answered `Forbidden` with no request) under `make-view:<mount>:<key>`, the messages `{ type: "event", name, data?, value?, fields }` and `{ type: "result", id, ok, result | error }`, fields collected by name from the control's nearest `form` or the whole view exactly as the web host collects them, and every answer for a view that is gone dropped. The closed vocabulary is what makes this safe without a frame: no element or prop names a URL, so the host has nothing to load or open, and it executes nothing.
|
|
144
|
+
|
|
145
|
+
What a native host draws differently, by design (the Rune host's scope, in its README):
|
|
146
|
+
|
|
147
|
+
- **`style`**: the web host's filter first, then only a documented subset is drawn (colours, font weight, style and size, text alignment, margins and padding, one border width, colour and radius, `display: flex` with direction, gap and alignment, sizes in `px`, `rem`, `em` or `100%`, opacity); `calc()` and the other functions, other percentages and the remaining properties are ignored. `class` is inert, as on the web.
|
|
148
|
+
- **Tables** are rows of equal-width cells: `colspan` and `rowspan` are ignored.
|
|
149
|
+
- **Inputs**: `date`, `time`, `datetime-local` and `color` are text fields; `number` keeps to a number's characters; `select` is an inline list box whose option values are their text (as the web host draws them).
|
|
150
|
+
- **Layout** is a column of blocks with paragraphs of text-level runs, not CSS's inline formatting: inline controls sit on their own lines.
|
|
151
|
+
|
|
152
|
+
## How an implementation is checked
|
|
153
|
+
|
|
154
|
+
Read programs are proven in [`registry/test/data-programs.test.ts`](../../registry/test/data-programs.test.ts), on Bun and Node, against a records protocol fake: only granted read actions (not an ungranted one, a write or a kernel module's, even caught); only the person's own granted Connections; staged results reused by a later run in the background without reading the provider again, with a status no other person or organisation reads; the hourly and background quotas, per person; a sub-agent limited to `data_run` granting a program nothing beyond it; a background program reading and staging nothing more once its person leaves the organisation; and a query result too large refused in Postgres before the kernel holds it.
|
|
155
|
+
|
|
156
|
+
`sandboxConformance(subject)` registers, with a subject that runs code with kit-written host functions: an entry called with JSON arguments reaching only the granted functions; no `fetch`, `XMLHttpRequest`, `WebSocket`, `setTimeout`, `setInterval`, `require`, `process`, `Bun`, `Deno`, native bridge or host globals; static and dynamic imports, the network, the file system, the process and timers unreachable; an ungranted host function absent and the `eloxiv` object frozen; a caught refusal still failing the run; each limit (time for busy loops and slow host calls, steps, memory, stack, host calls, output and host arguments); nothing shared between runs or with the host; only JSON passed out; throws, rejections and missing entries reported; and `check`. The Eloxiv kernel runs it in `packages/testing/test/sandbox.test.ts`.
|
|
157
|
+
|
|
158
|
+
MAKE is proven against the kernel in:
|
|
159
|
+
|
|
160
|
+
- `packages/testing/src/conformance/Sandbox.ts` also proves a hostile run stops only itself: deep `JSON.parse`, `JSON.stringify`, regular expressions and host-call arguments fail that run and the next one runs, 25 hostile runs leave the engine healthy, queued unawaited host calls are refused where they are made, a run returning with calls still waiting runs none of them, redefining promises does not break the result, and the host's timers keep running (no stall over 250 ms) while code loops.
|
|
161
|
+
- `make-sandbox.test.ts`: a hostile module whose action tries 28 ways out (`RESET ROLE`, `SET ROLE`, `SET LOCAL ROLE`, `SET SESSION AUTHORIZATION`, `set_config` plain and qualified, `current_setting`, `CURRENT_USER`, another module's, the kernel's, Better Auth's and the catalogue's tables, forging the invocation context, file reads, `pg_sleep`, `dblink`, two statements, a data-modifying CTE, `COPY`, `DO`, DDL, a `regclass` cast, a function in `FROM`, a write its profile does not grant, a foreign event, an action outside its profile, a governance action) and each is `Forbidden`; a read-only action that writes is `Forbidden`; a call of another module's read-only action runs as the caller with the call's provenance (`person` over HTTP, `agent` from the agent); the kernel's health route answers within 750 ms throughout a busy loop, deep host-call arguments, a 40 MB result and a result past the row limit, each of which fails without a stack trace; 15 drafts whose code crashes the interpreter leave later calls working; rows of another organisation or person refused by row-level security; settings, the network and an endless loop fail the call; a caught refusal followed by a write commits nothing; another organisation cannot call it; refusals are audited; and a session logged in directly as its runtime role is that role after `RESET ROLE`, cannot `SET ROLE` or `set_config('role', ...)`, reaches no other module's, kernel's or Better Auth's table, cannot write the invocation context or run DDL or `TRUNCATE`, and sees none of its own rows without a context the kernel wrote. Its receipts (ledger C-004): a keyed call that emits an event commits a receipt naming that outbox row by reference (never its payload), and a replay returns exactly that receipt; a call that fails after emitting leaves neither event nor receipt.
|
|
162
|
+
- `make-lifecycle.test.ts`: the agent (scripted model) drafts, previews and asks to install a module, every step audited as the agent's; the requester cannot approve; an administrator's approval installs it once with its own schema and roles, hardened; its actions run with policy, targets, events, idempotent replays and audit, for its organisation only; the agent uses them as tools; its view runs in the sandbox (`make.renderView`: `init`'s tree and calls, a result through `update` into the tree), no view document is served, and a draft with an HTML view is refused; its agent tool descriptions are marked as the module's untrusted text, shortened and flattened; a version bump runs its migrations and new code; only an administrator rolls back, and the previous version runs over the same schema with the newer one's column and rows kept and its table closed; installing the newer version again finds them; drafts with problems or without a preview are not installed; a preview must call something; an install that names other capabilities or another hash than its draft's does not install, and the approval request shows the hash and the profile; drafts are rate limited; another organisation cannot take the name; and one commit: no prepared transactions (`max_prepared_transactions` is 0), concurrent retries with one key run once (one row, one receipt, one success record, three replays), a failed call leaves no row, receipt or success record, and a session logged in as the runtime role cannot call `make_finish` or `make_claim` without the ticket nor write the audit log or the outbox.
|
|
163
|
+
- `make-authoring.test.ts`: the worked example in `make.draft`'s description drafts, previews and installs as printed, and its policy keeps one member's notes from another; a source with one closing brace misplaced, or given as JSON text, drafts as the same source (its hash); a key in two places (a permit in one action and a forbid in another, no policy at the top) or left where it is not read is refused, every place named, and nothing is drafted; one missing what cannot be found is refused with every problem at once; a value of the wrong kind or a missing key is refused with its path, what was given and what belongs there (never a bare `Expected object` or `Missing key`, backlog 50); a source leaving out its events and its empty profile lists drafts and installs with them empty. `registry/test/make-real-model.test.ts` (the `model live` workflow's `make-live` job, Bun and Node) is the same lifecycle authored from a task on a real model.
|
|
164
|
+
- `make-manifest.test.ts`: the source checks (each refusal above) and the SQL guard's verdicts, without a database.
|
|
165
|
+
- `packages/kernel/test/sandbox-gc.test.ts`, driving the interpreter thread directly with the pool's worker limits and reading its output: 30 ways a run ends (results, host calls, refusals, failures, every limit and interrupt, checks) each free their runtime with nothing alive (no QuickJS assertion in the thread's output) and the thread keeps serving; deep `JSON.parse`, `JSON.stringify` and host-call arguments, under the pool's limits and a 2 MiB thread stack, are each the run's stack limit, never abort, and the next run works (through the pool too, on Bun and Node alike); 13 ways the code's own JavaScript runs while the host reads what it threw or returned (getters, `toString`, `valueOf`, `Symbol.toPrimitive`, `toJSON`, Proxy traps; at the top level, from the entry, in a check) never abort either; a 2 MiB run of 4 KiB strings stops at its memory limit within 18 MiB; collected and idle after a 48 MiB run, the thread retains less than 16 MiB more than before it; output, host-call arguments, the kernel's arguments and host answers are counted in UTF-8 bytes; and one thread over 2,380 runs keeps each within its cap, its memory within 256 MiB of its warm-up peak, and, idle after a last 48 MiB run, retains nothing of them.
|
|
166
|
+
- `make-subscribers.test.ts`: a subscriber handles its own event exactly once (a failed first attempt rolled back and retried, further passes running it no more, one delivery record), under the module's limits (a busy loop stopped) with `sql` only (no `emit`); another module's event its profile lists reaches it, and a rollback to a version without that subscriber stops it at once; a draft whose subscriber handles an event its profile does not list, a kernel module's event, or another organisation's module's event is refused.
|
|
167
|
+
- `registry/test/make-real-model.test.ts` (with `ELOXIV_MODEL_OPENAI_API_KEY` and `ELOXIV_MODEL_LIVE=1`, in the `model live` workflow; up to three attempts, each a fresh module, under 300k tokens and 25 steps a run): the whole lifecycle on a real model, the model writing the module from a task: the agent drafts, previews and asks to install; an administrator approves; the agent uses the action; a version bump; a rollback; a draft naming a kernel module's action refused, and its install too.
|
|
168
|
+
- `make-surfaces.test.ts`: MAKE actions on MCP's `tools/list` and the typed RPC client's `make.actions()` for the organisation's members, with descriptions marked untrusted (flattened), to no other organisation, and to a token scoped to them but not to one scoped to other actions; calls through the invocation path (a scoped token refused, an agent's call of a consent action held for consent, a non-MAKE action refused on `$make.call`); a rollback takes the newer version's actions out of both listings at once.
|
|
169
|
+
- `make-load.test.ts`: 50 concurrent calls across two organisations while a third organisation's built-in calls answer within 3 s, every MAKE call answered (served, or refused as busy), both organisations served, no connection left idle in a transaction, the per-person call limit, concurrent drafts answered promptly within the person's limit while built-in calls stay prompt, the sweep of a crashed call's records, and a clean shutdown; `gate.test.ts`: the admission gate's turns across keys, its bounded wait and queue, an interrupted waiter, and the sandbox refusing at once a run that may not wait.
|
|
170
|
+
- `packages/testing/test/make-view-step.test.ts`: a view's step in the sandbox: `init`, then `update` with a call's result and with an event, the tree drawn each time; no `fetch`, `XMLHttpRequest`, `WebSocket`, `location`, `document`, `navigator`, timers or host function; a tree with another element (`script`, `img`, `iframe`), a URL property (`href`, `src`, `action`), an event handler property or too many nodes refused.
|
|
171
|
+
- `e2e/make-view.spec.ts` (threat SB-7): the shell's view host in Chromium: the frame sandboxed without scripts or forms, under the view CSP; a button clicked, a link activated by Enter, a form's fields and a watched checkbox each reaching the view, what the person typed kept across redraws, no script in the frame; **a tree that puts what the view's listed action returned into every URL-bearing element and property** (images, scripts, frames, meta refresh, links, forms, image and submit inputs, CSS `url()` plain and escaped, `cursor` and `list-style` URLs, event handler properties, markup in text), with every control activated and Enter pressed in every field, **sends not one request to the attacker's server**, never moves the frame or the page, and leaves no such element, no URL but the host's own fragments and no `url()` in the frame; elements put into the frame behind the host's back (an image, a CSS URL, a script, a frame) load and run nothing either; only listed actions are called (an unlisted one answered `Forbidden` without a request), under the view's keys within its mount. In the shell itself (`/make/<module>`): the frame is sandboxed under the view CSP, the view's steps run through `make.renderView` and its listed action is called as the signed-in person in the selected organisation (the unlisted one making no request), another organisation opens the view afresh (the old frame is gone), and leaving the route removes it. `registry/test/shell-foldkit-slots.test.ts` holds the MAKE screen's Story and Scene tests (the Command's arguments carry a session handle, never a token; stale results dropped; the Mount released when the frame closes), and `registry/test/shell-foldkit-isolation.test.ts` proves opening a view reads `make.view` only (a destructive action listed first is never called).
|
|
172
|
+
|
|
173
|
+
## Not yet guaranteed
|
|
174
|
+
|
|
175
|
+
- **MAKE modules have no jobs, workflows, ingress sources, query views, skills, settings of their own or sync**; their subscribers have `sql` only.
|
|
176
|
+
- **Names**: `mk_` is MAKE's: no app module may be named `mk_*` (setup refuses it), so the surfaces tell a MAKE action from an app's by its name: MCP's tools (`<module>-<key>`, and the authentication gate audits a refused tool call by its action's canonical name, `<module>.<key>`, as every surface does), the RPC and HTTP routes for MAKE actions, and the CLI (`eloxiv call mk_<module>.<action>` goes to `/make/actions`, audited as `cli`).
|
|
177
|
+
- **Agent tool groups**: every MAKE action is in the group `make-modules` (`MAKE_MODULES_TOOL_GROUP`) and its module's own (`mk_<name>`); `KernelApp.agentTools.disabledGroups` may name either (a module's before it is made), closing those actions to agents on every surface, as for the app's groups.
|
|
178
|
+
- **Surfaces**: MAKE actions are served on HTTP (`/make/actions/*`), to the agent, on MCP (tools named `<module>-<key>`, each one action's and so one organisation's, registered as modules are installed, listed and called by `Invocation.reach` and the invocation path; refusals encoded through `InvocationError`, message included), on the typed RPC client (`$make.actions` lists the ones the caller reaches, `$make.call` calls one; the client's `make.actions()` and `make.call()`), and through the client SDK's `makeModuleClient`; not yet in the OpenAPI document.
|
|
179
|
+
- **The preview's directory**: a preview database holds the organisation but not its members, roles or groups, so policies that test them see none there.
|
|
180
|
+
- **One organisation per module name**: MAKE modules are installed for the organisation that made them; another organisation must choose another name.
|
|
181
|
+
- **Install runs setup in the kernel's process** with the deployment's setup connection (`ELOXIV_ADMIN_DATABASE_URL`, behind `MakeSetup`; see above): a superuser, or a managed host's administrative role; a deployment that cannot give the kernel one cannot install or preview MAKE modules.
|
|
182
|
+
- **Bun's workers have no heap limit, nor a stack size**: there a worker's heap is bounded by the interpreter's own limit and the host-call caps, not by `resourceLimits`; and its smaller native stack can overflow inside the WebAssembly under deep `JSON.parse` or `JSON.stringify` before QuickJS's own stack check (Node's 16 MiB worker stack does not). That run fails as a stack limit; its interpreter is dropped without being freed, and the worker discarded, as after any failed run (`packages/kernel/test/sandbox-gc.test.ts`).
|
|
183
|
+
- **What a view can draw**: the tree's elements and properties only: no images, media, links to anywhere, file inputs, custom fonts, scripts of its own or stylesheets (inline `style` with a few properties), and a form is never submitted (its button sends the view its fields; Enter in a field does nothing). A view written as HTML before 0.4.0 of the shell no longer renders: its module's next version must give it as code. The desktop hosts' webviews are not separately tested; the routing the host relies on (a fragment link activated in a script-less frame, read from the parent) was tried in WebKitGTK and Chromium.
|
|
184
|
+
- **A cluster shared by several apps**: a MAKE module's roles are named for the module (`eloxiv_mod_<name>`, `eloxiv_own_<name>`), cluster-wide, and setup sets the runtime role's password from this deployment's key: two apps on one cluster must not make modules of the same name (a setup or preview of one would reset the other's role's password). Neither loses the roles to the other's preview: setup holds the module's role lock (`MAKE_ROLE_LOCK`) from creating them until it has used them. Roles named per app (or per install) are a later option; they would need the catalogue functions that bind a session's role to its module by name (`record_migration`, `make_call_of`) to read that binding elsewhere.
|
|
185
|
+
- **Limits are per kernel process**: the admission bounds and the per-person call limit count one process's calls; the draft and preview limits count every process's.
|
|
186
|
+
- **Runtime roles and other databases**: a MAKE module's runtime role can log in, and PostgreSQL lets every role connect to a database whose `CONNECT` privilege PUBLIC holds; it holds no privilege there. Restrict `eloxiv_mod_mk_%` to the app's database in `pg_hba.conf`. Preview databases revoke `CONNECT` from PUBLIC.
|