@feltdb/feltkit 0.3.24 → 0.3.26
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/dist/app.d.ts +116 -0
- package/dist/app.js +73 -1
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.d.ts +1 -1
- package/dist/appboundry/build.js +18 -4
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.d.ts +11 -0
- package/dist/appboundry/guest.js +20 -0
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/cli/main.js +59 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/dashboard/assets/{index-BXTNQAg1.css → index-BehzsQOa.css} +1 -1
- package/dist/dashboard/assets/{index-BEjtLLYq.js → index-Clsfddp8.js} +9 -9
- package/dist/dashboard/index.html +2 -2
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -0
- package/dist/docs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/measure/index.d.ts +117 -0
- package/dist/measure/index.js +479 -0
- package/dist/measure/index.js.map +1 -0
- package/dist/platform/deployments.d.ts +1 -1
- package/dist/runtime/application-authority.d.ts +54 -0
- package/dist/runtime/application-authority.js +55 -0
- package/dist/runtime/application-authority.js.map +1 -0
- package/dist/runtime/authboundry.d.ts +25 -13
- package/dist/runtime/authboundry.js +15 -7
- package/dist/runtime/authboundry.js.map +1 -1
- package/dist/runtime/browser-inference.d.ts +2 -2
- package/dist/runtime/browser-inference.js +2 -2
- package/dist/runtime/context.d.ts +51 -0
- package/dist/runtime/runtime.js +56 -10
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services.d.ts +34 -0
- package/dist/runtime/services.js +58 -1
- package/dist/runtime/services.js.map +1 -1
- package/dist/runtime/transactions.d.ts +9 -2
- package/dist/runtime/transactions.js +14 -4
- package/dist/runtime/transactions.js.map +1 -1
- package/dist/server/admin.js +20 -2
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.js +21 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/project.d.ts +2 -0
- package/dist/server/project.js +9 -5
- package/dist/server/project.js.map +1 -1
- package/docs/GUARANTEES.md +10 -0
- package/docs/MEASURE.md +144 -0
- package/docs/README.md +3 -2
- package/docs/TRANSACTIONS.md +46 -0
- package/docs/UPSTREAM-GAPS.md +1 -1
- package/package.json +6 -6
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-build/SKILL.md +14 -2
package/docs/TRANSACTIONS.md
CHANGED
|
@@ -118,6 +118,15 @@ sequence name rule and encoding, and the outbox state machine and recovery polic
|
|
|
118
118
|
shared module with no Node imports. FeltKit's runtime and the artifact guest (through the
|
|
119
119
|
host) both use it.
|
|
120
120
|
|
|
121
|
+
**Anonymous callers.** An effect runs as the caller. A function called without a signed-in caller
|
|
122
|
+
(`access: "public"`, such as a contact form) has no one to run it as, so staging a notification,
|
|
123
|
+
webhook or job refuses with `UNAUTHORIZED`, and the mutation doesn't commit. The refusal names the
|
|
124
|
+
function and the supported path: declare an agent (`app.agent`, §8) and stage
|
|
125
|
+
`ctx.afterCommit.agent(name, input)`. The agent runs after the commit as its own declared principal and
|
|
126
|
+
can send the notification. In an AppBoundry artifact, where application agents can't run, the refusal
|
|
127
|
+
says so instead. Giving effects a declared identity of their own is an open design question (TA-1 in
|
|
128
|
+
docs/platform/GAP-REGISTER.md).
|
|
129
|
+
|
|
121
130
|
**AppBoundry: host interface `transactions@1`.** It is required only by artifacts that use
|
|
122
131
|
these features:
|
|
123
132
|
|
|
@@ -311,3 +320,40 @@ retry runs it; a run repeated after its writes committed writes nothing again; a
|
|
|
311
320
|
triggers nothing; an `app.event` in `on` triggers it; tenancy (non-member → no tenant; member → its
|
|
312
321
|
tenant with its own role); a pending run survives a restart and the next process performs it;
|
|
313
322
|
declarations are checked; an AppBoundry build refuses `app.agent`.
|
|
323
|
+
|
|
324
|
+
## 9. Business audit trail (`app.auditTrail`)
|
|
325
|
+
|
|
326
|
+
SupplyDesk and TableOS each wrote the same thing: a collection of events about their own subjects,
|
|
327
|
+
written in the same transaction as each change, with the actor and the request id. FeltKit provides it:
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
export const events = app.auditTrail("events", { subjects: ["invoice", "vendor"] as const });
|
|
331
|
+
|
|
332
|
+
// in a mutation, next to the change it describes:
|
|
333
|
+
await events.record(ctx, { subject: "invoice", id, type: "invoice.approved", data: { amount } });
|
|
334
|
+
|
|
335
|
+
// anywhere (a query, a mutation):
|
|
336
|
+
const history = await events.history(ctx, "invoice", id); // in order
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
| Field | |
|
|
340
|
+
|---|---|
|
|
341
|
+
| `subjectType`, `subjectId` | What the event is about (`subjects` is the closed list). |
|
|
342
|
+
| `type`, `data` | The app's event name and details. |
|
|
343
|
+
| `actor`, `actorType` | The caller, or `anonymous` for a public call: an event never refuses a public form. |
|
|
344
|
+
| `at` | Wall-clock time, for display. |
|
|
345
|
+
| `seq` | **The order**: a FeltDB sequence per subject, allocated in the writing transaction (1, 2, 3…, no repeats or gaps among committed events), never a clock. |
|
|
346
|
+
| `requestId` | The request that caused it: the link to FeltKit's activity log (capability, authorization decision, writes). |
|
|
347
|
+
|
|
348
|
+
- **Atomicity.** If the mutation fails or its commit is refused, the event isn't written either.
|
|
349
|
+
- **Reading it.** The trail is an ordinary declared collection (with `tenant` if the app is
|
|
350
|
+
multi-tenant), so queries can read it with `ctx.db`. Who may read it is decided by the functions that
|
|
351
|
+
read it.
|
|
352
|
+
- **Append-only** is the helper's contract, not enforced storage: the app shouldn't patch or delete
|
|
353
|
+
events.
|
|
354
|
+
- **Adopting it for an existing collection.** The fields match the shape SupplyDesk and TableOS wrote by hand,
|
|
355
|
+
but the trail allocates `seq` from its own sequences (`audit:<trail>:<subject>:<id>`). A subject that already
|
|
356
|
+
has events numbered by the app's own sequence starts again at 1, so with existing data either keep reading
|
|
357
|
+
history by `at` as well, or move it before switching. An anonymous caller is recorded as actor `anonymous`.
|
|
358
|
+
- **Where it runs.** It works in FeltKit and in AppBoundry artifacts. An artifact with a trail requires
|
|
359
|
+
`transactions@1`, because of the sequence.
|
package/docs/UPSTREAM-GAPS.md
CHANGED
|
@@ -93,7 +93,7 @@ A1–A4 are closed by the released `@appport/core` 1.4.0 / `@appport/sdk` 1.4.0
|
|
|
93
93
|
| A7 | `HttpBinding` (mapped mode) answers 500 for any code outside AppPort's standard set, including namespaced extension codes and codes a capability's integration contract declares (`failures[].code`), with no way for the application to give them a status | — | FeltKit wraps the binding and sets the status for the codes it returns itself (`FELTKIT_APPPORT_STATUS`: `feltkit.FAILED_PRECONDITION` 409, `UPSTREAM_REJECTED`/`OUTCOME_UNKNOWN` 502, `UNAVAILABLE`/`NOT_CONFIGURED` 503), from the same table as its own HTTP API; `packages/sdk/test/error-contract.test.ts` | Open (found 2026-11-03). Ask: an option mapping extension codes to statuses, or using a declared failure's class |
|
|
94
94
|
| A8 | Subscriptions are not authorized by the application's `Authorizer`. `server/src/connection.ts#subscribe` checks the event's declared permissions against `session.permissions` only: a connection identified by a principal (FeltKit's are; FeltKit grants from its policy, never from `session.permissions`) cannot subscribe to any permissioned event, and **a subscription to `*` requires nothing and receives every event, including events the session may not observe** (spec §21.7 says it must not be delivered). Events also have no scope, so a per-tenant event (presence in one workspace) reaches every subscriber | — | FeltKit does not use AppPort events yet (FK-GAP-004 is blocked on this). Reproduction: `packages/server/test/subscriptions.test.ts` on `rkendel1/appport` branch `claude/scoped-event-authorization` | Open (found 2026-11-05). Ask: authorize subscribe *and each delivery* through the application's `Authorizer` (event ref as the capability, `{ scope }` as input), and an optional `scope` on events and subscriptions |
|
|
95
95
|
| A9 | `AuthorizationDecision` can deny only with `UNAUTHORIZED` or `FORBIDDEN`. A policy that hides what exists (an unknown id and a forbidden one answered alike, as `NOT_FOUND`) cannot say so in a decision | — | `feltkit({ authorize })` lets the hook throw `fail("NOT_FOUND", …)`, recorded as a denial (`authority.resource`) | Open (found 2026-11-05). Ask: an optional `NOT_FOUND` denial code (or a `conceal: true` flag) on the decision |
|
|
96
|
-
| A10 | The HTTP event stream (`GET /appport/events`) names every subscription `sub_sse_<index>` (`@appport/server` 1.2.0 and 1.3.0, `http.ts#events`), and the application's event bus keys subscriptions by that id across connections. A second client's subscription replaces the first's, which silently stops receiving events | — | FeltKit gives each subscription its own bus id (`runtime.ts`, wrapping `application.subscribe`); the connection still echoes the client's id. `test/events.test.ts` (two clients, one scope) |
|
|
96
|
+
| A10 | The HTTP event stream (`GET /appport/events`) names every subscription `sub_sse_<index>` (`@appport/server` 1.2.0 and 1.3.0, `http.ts#events`), and the application's event bus keys subscriptions by that id across connections. A second client's subscription replaces the first's, which silently stops receiving events | — | FeltKit gives each subscription its own bus id (`runtime.ts`, wrapping `application.subscribe`); the connection still echoes the client's id. `test/events.test.ts` (two clients, one scope) | **Closed upstream; workaround removed.** `@appport/server` registers each subscription under a connection-scoped id (`connection.js`: `${connection}:${subscriptionId}`). FeltKit's wrapper is deleted; `test/events.test.ts` (several clients, one scope) passes on 1.3.2 without it |
|
|
97
97
|
|
|
98
98
|
## AppPort Services (`rkendel1/appport-services`)
|
|
99
99
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feltdb/feltkit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.26",
|
|
4
4
|
"description": "FeltKit: one application, one FeltDB instance, one developer experience. SDK, runtime, CLI, and dashboard.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -57,13 +57,13 @@
|
|
|
57
57
|
"@appport/authorization": "1.1.1",
|
|
58
58
|
"@appport/integration": "1.2.5",
|
|
59
59
|
"@appport/protocol": "1.5.0",
|
|
60
|
-
"@appport/resolver-client": "0.
|
|
60
|
+
"@appport/resolver-client": "0.3.0",
|
|
61
61
|
"@appport/schema": "1.1.6",
|
|
62
62
|
"@appport/sdk": "1.8.1",
|
|
63
63
|
"@appport/server": "1.3.2",
|
|
64
64
|
"@appport/services": ">=0.16.0 <1.0.0",
|
|
65
65
|
"@feltdb/core": ">=0.21.0 <1.0.0",
|
|
66
|
-
"create-feltkit": "0.3.
|
|
66
|
+
"create-feltkit": "0.3.26",
|
|
67
67
|
"esbuild": "0.25.12",
|
|
68
68
|
"express": "4.22.3",
|
|
69
69
|
"mailerport": ">=0.1.0 <1.0.0",
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
"@mailerport/service": "0.1.0",
|
|
87
87
|
"@feltdb/webllm": ">=0.20.0 <1.0.0",
|
|
88
88
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
89
|
-
"@stack-ui/core": "
|
|
90
|
-
"@stack-ui/react": "
|
|
91
|
-
"@stack-ui/tokens": "
|
|
89
|
+
"@stack-ui/core": "0.8.1",
|
|
90
|
+
"@stack-ui/react": "0.8.1",
|
|
91
|
+
"@stack-ui/tokens": "0.8.1",
|
|
92
92
|
"@types/node": "22.19.1",
|
|
93
93
|
"@types/react": "19.2.2",
|
|
94
94
|
"@types/react-dom": "19.2.2",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://anthropic.com/claude-code/plugin.schema.json",
|
|
3
3
|
"name": "feltkit",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.26",
|
|
5
5
|
"description": "Skills for building and operating FeltKit applications: project structure and SDK, AppPort Services, FeltDB data and consistency, the FeltKit agent over MCP, and operations. Guidance only: they grant no permission.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "FeltKit"
|
|
@@ -99,7 +99,11 @@ validation and the transaction: do not use it unless the user asks and understan
|
|
|
99
99
|
- **Effects that announce the change**: `ctx.afterCommit.notifications.send(...)`, `.webhooks.emit(...)`,
|
|
100
100
|
`.jobs.enqueue(...)` happen only if the mutation commits (recorded in its transaction, performed after it).
|
|
101
101
|
`ctx.services.*` effects happen even if the commit is later refused.
|
|
102
|
-
- **
|
|
102
|
+
- **A business audit trail**: `export const events = app.auditTrail("events", { subjects: ["invoice"] as const })`,
|
|
103
|
+
then `await events.record(ctx, { subject: "invoice", id, type: "invoice.approved", data })` next to the change, and
|
|
104
|
+
`events.history(ctx, "invoice", id)` to read it in order. Each event has the actor (or `anonymous`), the request
|
|
105
|
+
id and a per-subject `seq`, and commits with the change. Don't build your own (docs/TRANSACTIONS.md §9).
|
|
106
|
+
- **Ordering any other append-only log** written in the same transaction: ``seq: await ctx.db.sequence(`audit:${invoiceId}`)``
|
|
103
107
|
and `orderBy: [{ field: "seq", direction: "asc" }]`. Never order by `Date.now()`: several writes share a millisecond.
|
|
104
108
|
Order is per stream (the name): one stream per subject, so unrelated writers never contend. Writers to one stream
|
|
105
109
|
serialize (`CONFLICT`); add `retry: { sequenceConflicts: 3 }` to the mutation to have it re-run instead, if its
|
|
@@ -176,6 +180,13 @@ test("a member completes a task", async () => {
|
|
|
176
180
|
|
|
177
181
|
Each test app gets an isolated FeltDB instance. Test denials too (`app.as("viewer")` should be refused writes).
|
|
178
182
|
|
|
183
|
+
**Callers in tests.** `app.query(...)` / `app.mutation(...)` on the test app itself are **anonymous**: no session,
|
|
184
|
+
like a visitor on a public page. Use that for `access: "public"` functions. `app.as({ id, type: "user", roles: [] })`
|
|
185
|
+
is a *signed-in* account with no roles, a different caller: a staff-only function refuses it with FORBIDDEN, while
|
|
186
|
+
it refuses an anonymous caller with UNAUTHORIZED. `app.as(who, { session: false })` is a known principal without a
|
|
187
|
+
session. An anonymous mutation can't stage `ctx.afterCommit.notifications/webhooks/jobs` (they run as the caller);
|
|
188
|
+
stage `ctx.afterCommit.agent(name, input)` for a declared `app.agent` instead.
|
|
189
|
+
|
|
179
190
|
## Portability (AppBoundry)
|
|
180
191
|
|
|
181
192
|
`npx feltkit build --target appboundry` compiles the app into `<name>.app` (runs without the project or FeltKit). It
|
|
@@ -184,7 +195,8 @@ refuses, naming file and line: `ctx.agent`, `ctx.unsafe`, `app.integration`,
|
|
|
184
195
|
artifact has no locale data; format for people in the frontend). It omits Studio, `/mcp`, API keys, schedules and
|
|
185
196
|
webhook delivery. A plain `feltkit build` prints the same list as a warning. If the user wants the artifact, avoid
|
|
186
197
|
these from the start, and test it with `createArtifactTestApp("<name>.app")` from `@feltdb/feltkit/testing` (same
|
|
187
|
-
`as(who).query/mutation` calls).
|
|
198
|
+
`as(who).query/mutation` calls). Serve it with `npx @appport/appboundry run <name>.app` (an app with built-in accounts
|
|
199
|
+
also needs `--accounts operator-sessions`: people then get sessions from the operator).
|
|
188
200
|
|
|
189
201
|
## When to stop and ask
|
|
190
202
|
|