@feltdb/feltkit 0.3.36 → 0.4.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/dist/app.d.ts +153 -3
- package/dist/app.js +159 -7
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.js +21 -0
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +4 -0
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/client/index.d.ts +189 -0
- package/dist/client/index.js +201 -0
- package/dist/client/index.js.map +1 -1
- package/dist/clock.d.ts +24 -0
- package/dist/clock.js +49 -0
- package/dist/clock.js.map +1 -0
- package/dist/dashboard/assets/index-BhxrvY37.js +15 -0
- package/dist/dashboard/assets/index-CSzYeCo_.css +1 -0
- 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/event-stage.js +2 -0
- package/dist/event-stage.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/policy.d.ts +9 -1
- package/dist/policy.js +16 -3
- package/dist/policy.js.map +1 -1
- package/dist/presence.d.ts +85 -0
- package/dist/presence.js +37 -0
- package/dist/presence.js.map +1 -0
- package/dist/quota.d.ts +72 -0
- package/dist/quota.js +143 -0
- package/dist/quota.js.map +1 -0
- package/dist/react/agent-control.d.ts +189 -0
- package/dist/react/agent-control.js +366 -0
- package/dist/react/agent-control.js.map +1 -0
- package/dist/react/index.d.ts +14 -1
- package/dist/react/index.js +41 -0
- package/dist/react/index.js.map +1 -1
- package/dist/runtime/activity.d.ts +8 -0
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/agent-control.d.ts +18 -0
- package/dist/runtime/agent-control.js +34 -1
- package/dist/runtime/agent-control.js.map +1 -1
- package/dist/runtime/agent.js +16 -4
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/assemble.js +1 -1
- package/dist/runtime/assemble.js.map +1 -1
- package/dist/runtime/authority.d.ts +38 -0
- package/dist/runtime/authority.js +13 -2
- package/dist/runtime/authority.js.map +1 -1
- package/dist/runtime/capabilities.js +2 -1
- package/dist/runtime/capabilities.js.map +1 -1
- package/dist/runtime/changes.d.ts +17 -0
- package/dist/runtime/changes.js +65 -2
- package/dist/runtime/changes.js.map +1 -1
- package/dist/runtime/context.d.ts +114 -0
- package/dist/runtime/contract.js +9 -3
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/events.js +17 -1
- package/dist/runtime/events.js.map +1 -1
- package/dist/runtime/integrations.js +7 -7
- package/dist/runtime/integrations.js.map +1 -1
- package/dist/runtime/invocations.d.ts +19 -2
- package/dist/runtime/invocations.js +16 -3
- package/dist/runtime/invocations.js.map +1 -1
- package/dist/runtime/policies.d.ts +5 -2
- package/dist/runtime/policies.js.map +1 -1
- package/dist/runtime/presence-host.d.ts +84 -0
- package/dist/runtime/presence-host.js +303 -0
- package/dist/runtime/presence-host.js.map +1 -0
- package/dist/runtime/providers.d.ts +130 -1
- package/dist/runtime/providers.js +251 -9
- package/dist/runtime/providers.js.map +1 -1
- package/dist/runtime/resource-access.d.ts +137 -0
- package/dist/runtime/resource-access.js +177 -0
- package/dist/runtime/resource-access.js.map +1 -0
- package/dist/runtime/runtime.d.ts +73 -0
- package/dist/runtime/runtime.js +594 -37
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/sessions.d.ts +11 -0
- package/dist/runtime/sessions.js +15 -0
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/tenancy.d.ts +59 -0
- package/dist/runtime/tenancy.js +128 -0
- package/dist/runtime/tenancy.js.map +1 -1
- package/dist/runtime/workers.d.ts +123 -0
- package/dist/runtime/workers.js +291 -0
- package/dist/runtime/workers.js.map +1 -0
- package/dist/server/admin.js +48 -1
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.d.ts +0 -19
- package/dist/server/index.js +61 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp.d.ts +8 -15
- package/dist/server/mcp.js +40 -3
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/project.js +6 -5
- package/dist/server/project.js.map +1 -1
- package/dist/server/tenancy.d.ts +7 -0
- package/dist/server/tenancy.js +31 -0
- package/dist/server/tenancy.js.map +1 -1
- package/dist/server/watch.d.ts +10 -0
- package/dist/server/watch.js +88 -0
- package/dist/server/watch.js.map +1 -0
- package/dist/testing/index.d.ts +3 -1
- package/dist/testing/index.js +3 -2
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-CONTROL.md +130 -4
- package/docs/APPBOUNDRY.md +37 -0
- package/docs/ARCHITECTURE.md +6 -2
- package/docs/AUTH.md +35 -0
- package/docs/COMPONENTS.md +71 -0
- package/docs/GUARANTEES.md +4 -4
- package/docs/PRESENCE-AND-SIGNALING-PROPOSAL.md +152 -0
- package/docs/PROVIDERS.md +58 -1
- package/docs/README.md +3 -2
- package/docs/SECURITY.md +71 -3
- package/docs/TRANSACTIONS.md +48 -0
- package/docs/UPSTREAM-GAPS.md +16 -2
- package/package.json +16 -16
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-agent/SKILL.md +1 -1
- package/skills/feltkit-build/SKILL.md +11 -1
- package/skills/feltkit-data/SKILL.md +1 -1
- package/skills/feltkit-operations/SKILL.md +1 -1
- package/skills/feltkit-services/SKILL.md +1 -1
- package/dist/dashboard/assets/index-9rMS3yBm.js +0 -15
- package/dist/dashboard/assets/index-DkiYTUMR.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAkB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E,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC;QAChE,OAAO,EAAE;YACP,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO;gBAChC,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;gBACpC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;gBAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,SAAkB,EAAE,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,IAAI,CAAU,EAAE,CAAC,CAAC;YACtG,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,eAAe,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,KAAc,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAU;SACzH;QACD,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE;KAC1B,CAAC;AACJ,CAAC"}
|
package/docs/AGENT-CONTROL.md
CHANGED
|
@@ -43,7 +43,8 @@ control gate first. New work is refused with `CONFLICT` and a `details.reason` w
|
|
|
43
43
|
A *signaled* update (no text yet) never blocks: the agent keeps working while the person types.
|
|
44
44
|
|
|
45
45
|
The reasoner calls **checkpoint** between steps. It returns `proceed` (false while paused or interrupted), the updates to take into account
|
|
46
|
-
now (oldest first), and how many are still signaled.
|
|
46
|
+
now (oldest first), and how many are still signaled. While the task is held, a checkpoint hands over nothing new: received updates stay
|
|
47
|
+
received (and withdrawable) until the first checkpoint after a resume. Delivering marks updates `delivered` with the checkpoint version, once. A delivered
|
|
47
48
|
update that is not acknowledged (the reasoner's process died) is returned again by the next checkpoint and is never re-delivered as new.
|
|
48
49
|
|
|
49
50
|
Approving a proposed action also runs it, so approval is refused while the task is paused or interrupted. **Complete** is refused while any
|
|
@@ -93,10 +94,39 @@ The lifecycle is implemented once, in `AgentControl`; each surface is a thin cal
|
|
|
93
94
|
| Live state | `GET /api/agent/tasks/:id/control/events` (SSE, event `control`): the whole state on connect and after every change | — |
|
|
94
95
|
| MCP | — | `feltkit_agent_checkpoint`, `feltkit_agent_acknowledge` |
|
|
95
96
|
| AppPort | `appport.agent.{state,signal,submit,withdraw,pause,resume,interrupt,stop}` | `appport.agent.{checkpoint,acknowledge}` |
|
|
97
|
+
| AppPort event | `appport.agent.changed@1`, scope `agentTaskScope(taskId)` (below) | — |
|
|
96
98
|
|
|
97
99
|
The SSE stream is level-triggered: every frame is the full state (with a `revision`), read back from FeltDB. A lost frame or a reconnect
|
|
98
100
|
loses nothing.
|
|
99
101
|
|
|
102
|
+
### The change event: `appport.agent.changed@1`
|
|
103
|
+
|
|
104
|
+
After every durable change (signal, submit, withdraw, pause, resume, interrupt, stop, a checkpoint that delivers updates, an
|
|
105
|
+
acknowledgment, and in-flight work ending while a person holds the task), AgentControl publishes AppPort's change event
|
|
106
|
+
(spec/agent-control-1.md §7) with `scope: agentTaskScope(taskId)`:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{ "taskId": "task-…", "revision": "e82d8943…", "sequence": 4, "phase": "paused", "mode": "paused", "changes": ["mode", "phase"] }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- **`sequence`** starts at 1 and grows by exactly 1 per change, per task. It is a durable counter (`_feltkit_sequences`,
|
|
113
|
+
compare-and-set), so it continues after a restart; `view()` and `appport.agent.state` carry the latest as `state.sequence`.
|
|
114
|
+
- **`revision`** is the state's revision read after the change is durable: equal to what `appport.agent.state` answers then.
|
|
115
|
+
- **Observation follows reading the task**: a subscriber needs `feltkit.agent.read` and must be able to read the task (its workspace;
|
|
116
|
+
a non-person only its own task). A subscription without a task scope is refused.
|
|
117
|
+
- It is a notification and a cursor, not the state, and AppPort delivers events at most once: a consumer that sees a gap, or reconnects,
|
|
118
|
+
reads `appport.agent.state`.
|
|
119
|
+
- `runAgentChangedEventConformance` (@appport/testing) passes: `test/conformance/agent-events.test.ts`; FeltKit's own scenarios are in
|
|
120
|
+
`test/agent-changed.test.ts`.
|
|
121
|
+
|
|
122
|
+
### Live state on a FeltDB server
|
|
123
|
+
|
|
124
|
+
FeltKit's change feed takes FeltDB's commit notices (`db.onCommit`, FeltDB 0.23, where `db.capabilities().commitListener`): a write to
|
|
125
|
+
agent state is reported as it commits, on a FeltDB server too (feltdb-server 0.7.0 announces every commit's collections). Before, the
|
|
126
|
+
remote feed polled FeltKit's `_feltkit_collections` markers, which agent-state writes never stamp, so on a server the SSE stream above
|
|
127
|
+
did not move on a steering change. The poll remains as the fallback (`FELTKIT_CHANGE_POLL_MS`; 1 s embedded and 5 s on a server with
|
|
128
|
+
notices, 150 ms and 1 s without them).
|
|
129
|
+
|
|
100
130
|
## A reasoner loop
|
|
101
131
|
|
|
102
132
|
```ts
|
|
@@ -121,6 +151,83 @@ export const run = app.action({
|
|
|
121
151
|
|
|
122
152
|
`test/fixtures/steering/feltkit/work.ts` is a complete, tested version, including resuming after a restart without repeating a step.
|
|
123
153
|
|
|
154
|
+
## In the browser and React
|
|
155
|
+
|
|
156
|
+
The client (`@feltdb/feltkit/client`) has one method per operation and a live subscription:
|
|
157
|
+
|
|
158
|
+
| Method | HTTP |
|
|
159
|
+
|---|---|
|
|
160
|
+
| `client.agentControl(taskId)` | `GET …/control` |
|
|
161
|
+
| `client.signalAgentUpdate(taskId, { note?, idempotencyKey? })` | `POST …/control/signal` |
|
|
162
|
+
| `client.submitAgentUpdate(taskId, text, { instructionId?, idempotencyKey? })` | `POST …/control/submit` |
|
|
163
|
+
| `client.withdrawAgentUpdate(taskId, instructionId, reason?)` | `POST …/control/withdraw` |
|
|
164
|
+
| `client.controlAgent(taskId, "pause" \| "resume" \| "interrupt" \| "stop", reason?)` | `POST …/control/<op>` |
|
|
165
|
+
| `client.watchAgentControl(taskId, listener, onError?)` | `GET …/control/events` (SSE) |
|
|
166
|
+
|
|
167
|
+
`watchAgentControl` is level-triggered: every frame replaces the local state. A frame that repeats the last revision,
|
|
168
|
+
or that is older than the last one shown (a lower checkpoint count or record sequence, `controlRevisions()`), is
|
|
169
|
+
dropped. It reconnects after a dropped stream and stops on a refusal (signed out, no access, no such task).
|
|
170
|
+
|
|
171
|
+
`@feltdb/feltkit/react`:
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
const control = useAgentControl(taskId); // or "skip"
|
|
175
|
+
// control.state, .phase, .updates, .buttons, .pending[op], .errors[op], .error
|
|
176
|
+
// control.signal(), .submit(text, { instructionId?, idempotencyKey? }), .withdraw(id), .pause(), .resume(), .interrupt(), .stop(reason?)
|
|
177
|
+
|
|
178
|
+
<AgentControlBar taskId={taskId} /> // icons with aria-label and title; labels shows text
|
|
179
|
+
<AgentControlBar taskId={taskId} labels confirmStop={false} />
|
|
180
|
+
<AgentUpdateComposer taskId={taskId} /> // "Tell the agent what changed", the bar, and send (↑)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
- **Server state only.** Every button reflects the phase the server last reported; the only local state is which
|
|
184
|
+
operation is in flight (`pending`). Before the first frame, everything is disabled.
|
|
185
|
+
- **One update per draft.** `submit` sends an idempotency key, one per draft text, kept until it is sent: a double
|
|
186
|
+
click is one in-flight request, and a retry of the same text is the same update on the server.
|
|
187
|
+
- **Typed refusals.** Operations throw `AgentControlError` with `kind`: `conflict` (with `reason`: `AGENT_PAUSED`,
|
|
188
|
+
`CONCURRENT_CHANGE`, `INSTRUCTIONS_OPEN`, …), `idempotency-key-reused`, `forbidden`, `unauthorized`, `not-found`,
|
|
189
|
+
`other`. The components show the last refusal in an `role="alert"` line.
|
|
190
|
+
- **The composer** signals "an update is coming" once when the person focuses or types (`signalOnType={false}` turns
|
|
191
|
+
it off), fills that signal on send (`instructionId`), and shows each update's state (signaled, received, delivered,
|
|
192
|
+
incorporated, conflict, withdrawn, abandoned), the agent's resolution note, and Withdraw for signaled and received
|
|
193
|
+
updates. Its helper text follows the phase ("The agent knows an update is coming and keeps working. It takes your
|
|
194
|
+
update at its next checkpoint." after signalling).
|
|
195
|
+
- **Styling.** `fk-agent-*` classes with the same `--fk-*` variables as the auth screens, `className` on every
|
|
196
|
+
component, `unstyled`, and `<FeltKitAgentControlStyles disabled />`. Icons are inline SVG (pencil, pause, play,
|
|
197
|
+
bolt, stop, arrow-up); no runtime dependencies.
|
|
198
|
+
|
|
199
|
+
Which buttons are enabled, from the reported phase (`agentControlButtons(state)`):
|
|
200
|
+
|
|
201
|
+
| Phase | Update coming | Pause / Resume | Interrupt | Stop |
|
|
202
|
+
|---|---|---|---|---|
|
|
203
|
+
| running | yes | Pause | yes | yes |
|
|
204
|
+
| blocked (waiting for an approval) | yes | Pause | only while a model generation runs | yes |
|
|
205
|
+
| pausing (work still in flight) | yes | Resume | only while a model generation runs (interrupt cancels it) | yes |
|
|
206
|
+
| paused | yes | Resume | no: nothing is running to cancel | yes |
|
|
207
|
+
| interrupted | yes | Resume | no: already interrupted | yes |
|
|
208
|
+
| completed, stopped | no | no | no | no |
|
|
209
|
+
|
|
210
|
+
Interrupt differs from pause only in cancelling a running model generation now; an action is never aborted. So where
|
|
211
|
+
no generation is in flight it is disabled, with the reason in its title. Stop asks for confirmation
|
|
212
|
+
(`confirmStop={false}` or a custom message).
|
|
213
|
+
|
|
214
|
+
### Approving a proposal
|
|
215
|
+
|
|
216
|
+
`useOwnActions` and the client's `approveAction` / `rejectAction` already existed; two components sit on them:
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
<PendingApprovals /> // your agents' proposals, live (useOwnActions({ state: "proposed" }))
|
|
220
|
+
<ActionApproval action={action} approve={approve} reject={reject} /> // one proposal
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
`ActionApproval` shows the operation and its exact input, approves with the action's `inputDigest` (so the approval
|
|
224
|
+
binds to that input; a changed input is refused by the server), rejects with an optional reason, and shows the state
|
|
225
|
+
the server reported. A proposal past its `expiresAt` shows "Expired" and never offers Approve (`approvalOptions`).
|
|
226
|
+
|
|
227
|
+
Tests: `test/agent-control-client.test.ts` (the client against a real server: every operation, idempotent submit,
|
|
228
|
+
typed refusals, SSE frames, stale frames dropped; the components rendered with react-dom/server: the matrix per phase,
|
|
229
|
+
labels, the composer, and one request per double-clicked submit).
|
|
230
|
+
|
|
124
231
|
## What is tested (`test/agent-control.test.ts`)
|
|
125
232
|
|
|
126
233
|
The acceptance scenario (signal while a tool runs, type, submit, incorporate at the next checkpoint, continue, full history); pause during
|
|
@@ -128,15 +235,34 @@ an in-flight tool and resume; multiple updates, ordering and duplicate delivery;
|
|
|
128
235
|
during a dispatched tool; restart with a paused task and a pending update; redelivery after a restart; stop with pending updates;
|
|
129
236
|
authority; concurrent people; the HTTP endpoints and SSE stream with reconnect; an external agent over MCP; the AppPort capabilities.
|
|
130
237
|
|
|
238
|
+
## Who owns the agent loop (decision, 0.4.0)
|
|
239
|
+
|
|
240
|
+
A product that hands work to agent workers (Handoff: coding work to separately running runners) needs two
|
|
241
|
+
different things. FeltKit owns the first and leaves the second to the product:
|
|
242
|
+
|
|
243
|
+
| Reusable execution integration: FeltKit owns it | Delegation policy: the product owns it |
|
|
244
|
+
|---|---|
|
|
245
|
+
| **Who a worker is**: a registered worker principal (`ctx.grants.registerWorker`), its token, independent revocation, refused on its next call once revoked (docs/SECURITY.md) | which runner gets which work, how many at once, priorities and queues |
|
|
246
|
+
| **What it may do**: a work grant (AppPort delegated authority) for capabilities, one actor and one work item, checked on every surface | which capabilities a kind of work needs, and for how long |
|
|
247
|
+
| **Lease and claim of work**: platform invocations (`ctx.invocations.start` / `progress` / `transition`), a claim with a lease, fenced writes, an expired claim reclaimed as a new attempt; a worker whose grant names the invocation claims it as itself (`attribution.worker: "authenticated"`) | when to give up on a worker, re-assignment, escalation to a person |
|
|
248
|
+
| **Checkpoints**: `ctx.agent.checkpoint` / `acknowledge`, the gate on generations and proposals, pause/resume/interrupt/stop | what an update means for the plan (the model and the product's prompt) |
|
|
249
|
+
| **Resume by key**: `ctx.agent.openTask({ key })` returns the same task; proposals keyed per step never run twice; a job's or a keyed call's external effect (`ctx.effect`) is never begun twice | how a run is restarted (a scheduler, a queue consumer, the runner's own supervisor) |
|
|
250
|
+
| **Approvals of exact calls** (`ctx.grants.approve`), **effects and reconciliation** (`ctx.effect`, `appport.invocation.status`) | who approves what, and the review UI |
|
|
251
|
+
|
|
252
|
+
What FeltKit still does not do: run the loop. A reasoner is application code (an action) or an external runner; a
|
|
253
|
+
runner that stops must be started again by something the product runs. Owning that would mean a FeltKit
|
|
254
|
+
scheduler and process supervisor (a new execution system), which the pieces above make unnecessary: re-running
|
|
255
|
+
a step with the same keys is safe, so any at-least-once restarter (a job retry, a queue redelivery, a runner's
|
|
256
|
+
supervisor) is enough. Implemented in 0.4.0: workers, work grants, invocation claims by workers, and approvals
|
|
257
|
+
(`test/workers.test.ts`); nothing product-specific.
|
|
258
|
+
|
|
131
259
|
## Limits
|
|
132
260
|
|
|
133
|
-
- **FeltKit has no agent loop runner
|
|
261
|
+
- **FeltKit has no agent loop runner** (see "Who owns the agent loop"). Steering takes effect at the reasoner's boundaries. A reasoner that dies (process restart) leaves
|
|
134
262
|
durable, unambiguous state, but something must start it again: re-calling the action with the same key, as the fixture does, or an MCP
|
|
135
263
|
agent reconnecting.
|
|
136
264
|
- **Pause and interrupt are not preemption of external work.** A dispatched action finishes or times out; only model generations are
|
|
137
265
|
cancelled immediately.
|
|
138
266
|
- FeltDB 0.22 has no paused execution status; FeltKit keeps the mode in its control record and leaves FeltDB's execution status as the
|
|
139
267
|
action lifecycle sets it.
|
|
140
|
-
- The AppPort change event `appport.agent.changed@1` is not emitted yet; live state is FeltKit's SSE stream. AppPort's
|
|
141
|
-
`lintAgentControlSupport` reports this as a warning.
|
|
142
268
|
- The AppPort capability schemas are written in FeltKit until a published `@appport/protocol` carries the contract module.
|
package/docs/APPBOUNDRY.md
CHANGED
|
@@ -247,6 +247,11 @@ artifact that behaves differently from your application:
|
|
|
247
247
|
| `Intl`, `toLocaleString` / `toLocaleDateString` / `toLocaleTimeString`, `localeCompare` | the guest engine has no locale data (see below), so they would give different output than under `feltkit dev` |
|
|
248
248
|
| Node APIs (`node:*`, `fs`, …) in backend code | the artifact runs without Node |
|
|
249
249
|
| imports of `@feltdb/feltkit/<subpath>` in backend code | only `@feltdb/feltkit` exists in the guest |
|
|
250
|
+
| `app.action(...)` | it runs outside a transaction (model calls, external effects, streaming); an artifact runs transactions only (AppBoundry B1, `actions@1` proposed) |
|
|
251
|
+
| `feltkit({ providers })` | a provider reaches external systems and serves channels; an artifact has no network access |
|
|
252
|
+
| `resource: { guests, agents }`, `app.channel`, `app.presence` | resolved per call, delivered per recipient, or expired on FeltKit's runtime (K1, K2, K4, K6) |
|
|
253
|
+
| `visibility` other than `"public"` (0.4.0) | the host dispatches every function in the manifest on `/api`, `/appport` and `/mcp` and knows no internal calls, workers or service principals: an internal function would be public there |
|
|
254
|
+
| `ctx.grants`, `ctx.invocations`, `ctx.integrations`, `ctx.authority`, `ctx.presence`, `ctx.channels` (0.4.0) | FeltKit runtime services with no host interface: workers, work grants and approvals; the invocation store; outbound calls; AuthBoundry; leases; channels. The guest also refuses them at run time with `CONFIGURATION`, instead of an undefined property |
|
|
250
255
|
|
|
251
256
|
Only the handler context is checked: `ctx.agent` (or the first parameter of a `handler`,
|
|
252
257
|
whatever it is named, and `({ agent })` destructured) is refused, while `roles.agent` or
|
|
@@ -285,6 +290,38 @@ compiled by esbuild (`target: es2022`). What differs from Node:
|
|
|
285
290
|
Format numbers and dates for people in the frontend, or with explicit code (`toFixed`,
|
|
286
291
|
your own digit grouping).
|
|
287
292
|
|
|
293
|
+
## Portability audit: what keeps a FeltKit application off AppBoundry (0.4.0, against AppBoundry `0515c5a`)
|
|
294
|
+
|
|
295
|
+
Read against AppBoundry's source at `0515c5a` (`packages/appboundry-host/src/manifest.ts`: `SUPPORTED_INTERFACES` =
|
|
296
|
+
`collections`, `services`, `identity`, `web`, `migrations`, `transactions`, `crypto`, `events`, `components`, `tenancy`,
|
|
297
|
+
each `@1`; `docs/artifact-runtime.md`; `docs/COMPLETE-APPLICATION-GAP-REGISTER.md`) and FeltKit's artifact build
|
|
298
|
+
(`src/appboundry/build.ts`, `guest.ts`). Classes: **AppBoundry runtime limitation** (the host has no interface for it;
|
|
299
|
+
FeltKit refuses at build), **FeltKit portability issue** (FeltKit's to fix), **app-specific** (the application chose
|
|
300
|
+
something an artifact cannot be).
|
|
301
|
+
|
|
302
|
+
| # | Finding | Where | Class | Status |
|
|
303
|
+
|---|---|---|---|---|
|
|
304
|
+
| 1 | No non-transactional function kind: `app.action` (model calls, streaming, external effects, 0.4.0 `ctx.effect` and action capabilities) cannot be built | host manifest allows `query`/`mutation` only; AppBoundry gap register B1; FeltKit `build.ts` `ACTION_WHY` | AppBoundry runtime limitation | refused at build; needs `actions@1` |
|
|
305
|
+
| 2 | No network egress: `app.integration`, `feltkit({ providers })`, `ctx.integrations`, webhook delivery | guest imports nothing; `permissions.network: "none"`; gap register A1 | AppBoundry runtime limitation (by design: the guest stays socket-less) | refused at build; host-performed declared egress proposed (A1) |
|
|
306
|
+
| 3 | `app.agent` (FK-GAP-013's sibling, K8): code run after a commit as another principal | the guest ABI runs code only inside a call, as its caller; no agents interface | AppBoundry runtime limitation | **not in 0.4.0** (K8 was not implemented in either round; `git log` has no K8 commit); refused at build |
|
|
307
|
+
| 4 | `ctx.agent`, agent control, `appport.agent.changed@1`, FeltKit's agent tools on `/mcp` | FeltDB agent state is served by FeltKit's runtime; gap register D3 | AppBoundry runtime limitation | refused at build (`ctx.agent`); omitted from the manifest |
|
|
308
|
+
| 5 | Presence and channels (K1, K2): a lease expires on a clock, a channel decides each recipient at delivery | host has no timer for guest code and no per-recipient receive rule (events@1 decides at observe) | AppBoundry runtime limitation | refused at build |
|
|
309
|
+
| 6 | Guests, agent grants, workers, work grants and approvals (K4, K6, 0.4.0 P0) | resolved per call from `_feltkit_resource_access` by FeltKit's runtime; identity@1 has operator-issued sessions only | AppBoundry runtime limitation | refused at build (bindings, `ctx.grants`) |
|
|
310
|
+
| 7 | Built-in accounts (`auth.accounts`) | `identity-host-interface.md` (`accounts@1` proposed) | AppBoundry runtime limitation | declared in `identity`; host refuses unless the operator accepts operator sessions |
|
|
311
|
+
| 8 | `visibility` (0.4.0): an internal function in the manifest would be callable by anyone holding its `access` on `/api`, `/appport`, `/mcp` | the manifest carries no visibility and the guest did not check it | **FeltKit portability issue** | **fixed**: the build refuses it (`test/appboundry.test.ts`) |
|
|
312
|
+
| 9 | `ctx.grants`, `ctx.invocations`, `ctx.integrations`, `ctx.authority`, `ctx.presence`, `ctx.channels` built into an artifact failed only at run time, as `undefined` property access | `guest.ts` ctx has none of them; the build checked only bindings | **FeltKit portability issue** | **fixed**: refused at build with the line, and a `CONFIGURATION` refusal in the guest |
|
|
313
|
+
| 10 | Node APIs, a filesystem, ports, processes, long-lived connections in backend code | the guest is a WASM sandbox with no imports; the host owns HTTP, SSE (`/api/events`) and the clock | AppBoundry runtime limitation (by design) | refused at build (`node:*`, `fs`, …); FeltKit's runtime features that need them (the dev server, Studio, file links, image variants, schedules, the services worker for jobs) are FeltKit's server's, listed in `omitted` |
|
|
314
|
+
| 11 | Locale data (`Intl`, `toLocale*`, `localeCompare`) | Boa built without `intl` | AppBoundry runtime limitation (engine size) | refused at build and at run time |
|
|
315
|
+
| 12 | `feltkit({ auth: { authenticate } })` | the identity hook runs on FeltKit's server | FeltKit portability issue (not small: needs an identity host operation) | refused at build; not changed |
|
|
316
|
+
| 13 | An application whose value is in actions, agents or integrations (Handoff: workers opening pull requests) | — | app-specific | runs on FeltKit's runtime; an artifact can hold its transactional part only |
|
|
317
|
+
|
|
318
|
+
What a FeltKit app artifact can be today: queries and mutations over declared collections, AppPort Services
|
|
319
|
+
(files, notifications, configuration, jobs, recorded webhooks), sequences and after-commit effects
|
|
320
|
+
(`transactions@1`), `app.event` (`events@1`), migrations, tenancy (`tenancy@1`), `ctx.crypto.token`,
|
|
321
|
+
`approval: "required"` for people's direct calls, the audit trail, and companion components where an operator
|
|
322
|
+
enables them. Nothing above needs a FeltKit compiler or a second execution system: each runtime limitation is a
|
|
323
|
+
host interface AppBoundry would add (`actions@1`, declared egress, an agents interface, a timer for leases).
|
|
324
|
+
|
|
288
325
|
## What is not in the artifact
|
|
289
326
|
|
|
290
327
|
The build lists these (`omitted` in the manifest) instead of pretending to carry them:
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -37,6 +37,10 @@ shortest correct path:
|
|
|
37
37
|
| `runtime/content.ts` | File bytes in `_feltkit_file_content`: stored before the file record, verified on read, removed with the file (FeltDB's content store is not used yet: no deletion, no memory runtime). File links (`_feltkit_file_links`, token digests; cacheable links derive their token by HMAC). Image variants in `_feltkit_file_variants`, keyed by the original's storage key, released with its bytes. |
|
|
38
38
|
| `runtime/image-variants.ts` | Deriving a declared image variant (`services.files.variants`) with pure-JavaScript codecs (`jpeg-js`, `pngjs`): sniff, header size check, EXIF orientation, area-average downscale. Loaded on first use. |
|
|
39
39
|
| `runtime/runtime.ts` | Lifecycle, hot reload, `call()`, AppPort application construction. |
|
|
40
|
+
| `runtime/presence-host.ts` | `ctx.presence`, the live-lease read view, expiry by a timer on the runtime's clock, leases ending with their session (src/presence.ts declares them). |
|
|
41
|
+
| `runtime/resource-access.ts` | Guest links and agent grants (`_feltkit_resource_access`), the resource gate (guests and granted agents) at the execution boundary. |
|
|
42
|
+
| `quota.ts`, `clock.ts` | Call quotas (sliding windows, in the process) and the injectable clock leases and quotas read. |
|
|
43
|
+
| `server/watch.ts` | `feltkit dev`'s watcher: one non-recursive watch per directory (a recursive watch loses files replaced by a rename). |
|
|
40
44
|
| `runtime/loader.ts` | Loads `feltkit/` (tsx in development, the esbuild bundle in production). |
|
|
41
45
|
| `server/` | HTTP server, AppPort binding, MCP endpoint (application tools + `feltkit_agent_*`), admin API, dev/build/start/deploy workflows. |
|
|
42
46
|
| `server/management.ts` | AppPort Services' `createManagementRouter`: embedded in the admin API for Studio's Services screens (as a dev identity), and the services console on a loopback origin, authenticated by FeltKit sessions. |
|
|
@@ -110,8 +114,8 @@ installed Services release does not take `@feltdb/core` as a peer dependency.
|
|
|
110
114
|
|
|
111
115
|
## Request lifecycle of a mutation
|
|
112
116
|
|
|
113
|
-
1.
|
|
114
|
-
2.
|
|
117
|
+
1. Authorize: AppPort's authorizer evaluates the caller's roles against `access`.
|
|
118
|
+
2. Parse and validate arguments against the function's `args` schema, then admit the call under its quotas.
|
|
115
119
|
3. Run the handler with a `Writer`. Reads see pending writes; writes are validated and buffered.
|
|
116
120
|
4. Validate the return value against `returns`, if declared.
|
|
117
121
|
5. Commit one FeltDB transaction: inserts as `requireAbsent`, updates/deletes with
|
package/docs/AUTH.md
CHANGED
|
@@ -161,6 +161,41 @@ under the clients' control: the platform ends the authority and tells every othe
|
|
|
161
161
|
live queries, at once; a participant whose own client ignores that can only be cut off by the others closing
|
|
162
162
|
their side, or by a server in the media path.
|
|
163
163
|
|
|
164
|
+
## Guests
|
|
165
|
+
|
|
166
|
+
People without an account can join one thing (a meeting) through a link a host issues:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
feltkit({ roles: { guest: ["meetings.join", "meetings.chat"], … }, auth: { guests: { roles: ["guest"], ttlMs: 24 * 3_600_000 } } });
|
|
170
|
+
|
|
171
|
+
export const invite = app.mutation({ access: "meetings.host", args: { meetingId: s.string() },
|
|
172
|
+
handler: (ctx, { meetingId }) => ctx.grants.guestLink(meetings, meetingId, { label: "external" }) }); // { id, token, url, role, expiresAt }
|
|
173
|
+
|
|
174
|
+
export const join = app.mutation({ access: "meetings.join", args: { code: s.string() },
|
|
175
|
+
resource: { collection: meetings, id: "code", by: "code", guests: true, agents: "grant" }, handler: … });
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
- **Redeem:** `POST /api/auth/guest { token, displayName }` answers a session (a cookie for the browser client, else a
|
|
179
|
+
token) for `guest:<random>` with the link's role and `principal.guest = { link, resource, expiresAt }`; it lasts until
|
|
180
|
+
the link expires (at most 12 h).
|
|
181
|
+
- **Scope:** a guest reaches only functions declaring `resource` with `guests: true`, and only for its own record
|
|
182
|
+
(another is NOT_FOUND). Everything else (other functions, actions, tenancy) is refused. `ctx.auth.principal.guest`
|
|
183
|
+
tells a function it is serving a guest.
|
|
184
|
+
- **Revocation and expiry:** `ctx.grants.revoke(meetings, id, linkId)`. The guest session is resolved from its link on
|
|
185
|
+
every request, so revoking or expiry ends it at once.
|
|
186
|
+
- **Agents:** `ctx.grants.admitAgent(meetings, id, "scribe-bot")` admits a named agent (an `app.agent`, a component,
|
|
187
|
+
or an identity with an operator-issued session) to one record; with `agents: "grant"` every other agent or service
|
|
188
|
+
is refused there.
|
|
189
|
+
- Only a signed-in person issues links and grants (the issuing function's `access` decides which person).
|
|
190
|
+
|
|
191
|
+
## A tenant's public face (branding before sign-in)
|
|
192
|
+
|
|
193
|
+
`POST /api/tenants/current/public { slug?, domains?, branding? }` (needs `tenant.update`) sets a workspace's slug
|
|
194
|
+
(`acme`), custom domains (`meet.acme.com`) and branding (`displayName`, `logoUrl`, `primaryColor`, `accentColor`,
|
|
195
|
+
`backgroundColor`, `tagline`). Slugs and domains are unique across workspaces. A join or sign-in page brands itself
|
|
196
|
+
before anyone signs in with `GET /api/tenants/resolve?slug=acme` (or `?domain=…`, or no parameter: the request's own
|
|
197
|
+
host), `client.resolveTenant({ slug })`: the answer is `{ slug, branding }` and nothing else about the workspace.
|
|
198
|
+
|
|
164
199
|
## Workspaces (tenancy)
|
|
165
200
|
|
|
166
201
|
A tenant ("workspace", or whatever `tenant.name` says) has members.
|
package/docs/COMPONENTS.md
CHANGED
|
@@ -67,6 +67,77 @@ export default defineComponent(async (ctx) => {
|
|
|
67
67
|
});
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
## Pattern: a media worker (an SFU adapter, a recording bot)
|
|
71
|
+
|
|
72
|
+
A video call's media does not flow through FeltKit: browsers send it peer to peer, or to a media server (an SFU).
|
|
73
|
+
What belongs to the application is the authority around it: who may join which call's media, who may record it,
|
|
74
|
+
which bot is in which call, and what happened. A media worker is a component that holds that line. Everything below
|
|
75
|
+
uses only the contract above (`ComponentContext`, `ctx.afterCommit.work`, `ctx.work`) and functions; nothing here is
|
|
76
|
+
a separate API.
|
|
77
|
+
|
|
78
|
+
| Need | How |
|
|
79
|
+
|---|---|
|
|
80
|
+
| Identity | `principal: { id: "component:media", roles: ["media"] }`: a service principal with its own declared roles, never a person's. |
|
|
81
|
+
| Which calls it may touch | Functions it calls declare `resource: { collection: calls, id: "callId", agents: "grant" }`; a host admits it to one call with `ctx.grants.admitAgent(calls, callId, "component:media")` (declared components are known principals). Without that grant every call is FORBIDDEN, and revoking the grant stops it on the next call. |
|
|
82
|
+
| Starting work | A mutation records it in its own transaction: `ctx.afterCommit.work("media", "record", { callId })`. It exists exactly when the host's "start recording" commits. |
|
|
83
|
+
| Doing work | The component claims (`ctx.work.claim({ kinds: ["record"], leaseMs })`), acts, and settles (`ctx.work.finish(item, { outcome: "done", receipt })`). A worker that dies leaves the item claimable again with `resumed: true`; an upload that may have happened is settled `unknown`, never retried blindly. |
|
|
84
|
+
| Being present in the call | The worker calls a mutation that holds an `app.presence` lease for it (`ctx.presence.join(peers, …)` as `component:media`) and renews it on a timer shorter than `ttlMs`. If the worker or its process stops, the lease expires and the call's live queries show it gone; `onEnd` can settle the call. (`bind: "session"` needs a session; a component has none, so it renews.) |
|
|
85
|
+
| Browsers reaching the media server | Not with a FeltKit session token: a mutation (`media:ticket`, resource-bound to the call) authorizes the person and records a one-time ticket (`await ctx.crypto.token()` as its id, with an expiry); the browser presents it on the component's WebSocket route (`websocket: true`); the component redeems it with `ctx.call("media:redeem", { ticket })` (marks it used, returns who and which call) before it lets the connection signal. The component authenticates its own traffic; FeltKit's routes stay FeltKit's. |
|
|
86
|
+
| SFU credentials | `credentials: ["sfu-api-key"]`, read with `ctx.credential("sfu-api-key")` (`FELTKIT_CREDENTIAL_SFU_API_KEY` in production). `network: "egress"` for the SFU's API. |
|
|
87
|
+
| Signing room tokens for the SFU | `ctx.derive("sfu-room-token")`: stable secret material for this application, never in the artifact. |
|
|
88
|
+
| Health | `health()` with named checks, e.g. `{ state: "degraded", checks: { signaling: { state: "ready" }, sfu: { state: "failed", detail: "SFU unreachable" } } }`. Mark it `required: false` if calls should still work (chat, presence) while recording is down; the application then reports `partial` instead of being unavailable. |
|
|
89
|
+
| Results | The worker writes what it produced through a mutation (`ctx.call("recordings:store", { callId, file })`) under its grant, so the record, its evidence and Activity are the application's like any other write. |
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
// feltkit/app.ts (excerpt)
|
|
93
|
+
components: {
|
|
94
|
+
media: { entry: "media/component.ts", routes: ["/media/"], websocket: true, required: false,
|
|
95
|
+
principal: { id: "component:media", roles: ["media"] }, credentials: ["sfu-api-key"] },
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// media/component.ts
|
|
99
|
+
import { defineComponent } from "@feltdb/feltkit/server";
|
|
100
|
+
export default defineComponent(async (ctx) => {
|
|
101
|
+
const sfu = connectSfu(await ctx.credential("sfu-api-key")); // your SFU client
|
|
102
|
+
let stopped = false;
|
|
103
|
+
const loop = (async () => {
|
|
104
|
+
while (!stopped) {
|
|
105
|
+
for (const item of await ctx.work.claim({ kinds: ["record"], leaseMs: 120_000 })) {
|
|
106
|
+
const { callId } = item.input as { callId: string };
|
|
107
|
+
const lease = await ctx.call("peers:joinAsBot", { callId, name: "Recorder" }); // FORBIDDEN without a grant
|
|
108
|
+
const renew = setInterval(() => void ctx.call("peers:renew", { id: lease.id }).catch(() => undefined), 20_000);
|
|
109
|
+
try {
|
|
110
|
+
const file = await sfu.record(callId);
|
|
111
|
+
await ctx.call("recordings:store", { callId, file });
|
|
112
|
+
await ctx.work.finish(item, { outcome: "done", receipt: { file } });
|
|
113
|
+
} catch (error) {
|
|
114
|
+
await ctx.work.finish(item, { outcome: "retry", error: { message: (error as Error).message } });
|
|
115
|
+
} finally {
|
|
116
|
+
clearInterval(renew);
|
|
117
|
+
await ctx.call("peers:leave", { id: lease.id }).catch(() => undefined);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
await new Promise((r) => setTimeout(r, 1_000));
|
|
121
|
+
}
|
|
122
|
+
})();
|
|
123
|
+
return {
|
|
124
|
+
upgrade: (request, socket, head) => sfu.acceptSignaling(request, socket, head, (ticket) => ctx.call("media:redeem", { ticket })),
|
|
125
|
+
health: async () => ({ state: (await sfu.ping()) ? "ready" : "degraded", checks: { sfu: { state: (await sfu.ping()) ? "ready" : "failed" } } }),
|
|
126
|
+
close: async () => { stopped = true; await loop; await sfu.close(); },
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
What this pattern does not give you:
|
|
132
|
+
- **FeltKit does not relay media**, and a component cannot subscribe to `app.event`/`app.channel` messages (its
|
|
133
|
+
context has no subscription). Signaling for the SFU goes over the component's own WebSocket route; signaling between
|
|
134
|
+
browsers can use `app.channel`.
|
|
135
|
+
- **Preemption of media**: ending someone's lease or revoking a grant stops the worker's next function call, not
|
|
136
|
+
packets already flowing to the SFU. Tell the SFU to drop the participant when your onEnd agent or revoking mutation
|
|
137
|
+
runs (from the worker, which polls its work, or as `afterCommit.work("media", "kick", …)`).
|
|
138
|
+
- **On AppBoundry** the component runs as a companion beside the guest only where a host enabled companions; presence,
|
|
139
|
+
channels, guest links and grants are FeltKit runtime features that the AppBoundry build refuses today.
|
|
140
|
+
|
|
70
141
|
## On AppBoundry (`components@1`)
|
|
71
142
|
|
|
72
143
|
An `appboundry.app/1` guest is a WebAssembly module with no network, no secrets, JSON-only routes and no
|
package/docs/GUARANTEES.md
CHANGED
|
@@ -184,10 +184,10 @@ code in their text. `FeltKitClientError` exposes `code` and `retryable`.
|
|
|
184
184
|
| The current state does not allow it | `FAILED_PRECONDITION` | `feltkit.FAILED_PRECONDITION` | 409 | no |
|
|
185
185
|
| A record this mutation read changed before commit | `CONFLICT` | `CONFLICT` | 409 | **yes** |
|
|
186
186
|
| Any other state conflict (duplicate unique value, already applied) | `CONFLICT` | `CONFLICT` | 409 | no |
|
|
187
|
-
| An external API (`app.integration`) refused the request (4xx) | `UPSTREAM_REJECTED` | `UPSTREAM_REJECTED`, `details.status` = the API's status | 502 | no |
|
|
188
|
-
| The request was sent; the outcome is not known | `OUTCOME_UNKNOWN` | `
|
|
189
|
-
| A dependency is unreachable | `UNAVAILABLE` | `UNAVAILABLE` | 503 | **yes** |
|
|
190
|
-
| A credential or URL an operator must provide is missing | `CONFIGURATION` | `NOT_CONFIGURED` (`details.hint`) | 503 | no |
|
|
187
|
+
| An external API (`app.integration`) refused the request (4xx) | `UPSTREAM_REJECTED` | `feltkit.UPSTREAM_REJECTED`, `details.status` = the API's status | 502 | no |
|
|
188
|
+
| The request was sent; the outcome is not known | `OUTCOME_UNKNOWN` | `CONFLICT`, `details.reason: EFFECT_OUTCOME_UNKNOWN` (AppPort's `outcomeUnknown`; `classifyOutcome` answers `unknown`) | 502 (`/api`), 409 (`/appport`) | no: ask `appport.invocation.status`, verify it |
|
|
189
|
+
| A dependency is unreachable | `UNAVAILABLE` | `feltkit.UNAVAILABLE` | 503 | **yes** |
|
|
190
|
+
| A credential or URL an operator must provide is missing | `CONFIGURATION` | `feltkit.NOT_CONFIGURED` (`details.hint`) | 503 | no |
|
|
191
191
|
| Unexpected | `INTERNAL` | `INTERNAL_ERROR` | 500 | no |
|
|
192
192
|
|
|
193
193
|
An external API's 401 or 404 is `UPSTREAM_REJECTED`: it is about FeltKit's credential for that
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Presence, expiry and transient messages
|
|
2
|
+
|
|
3
|
+
Status: **implemented in 0.4.0** (unpublished until released), on the currently pinned FeltDB and AppPort. The
|
|
4
|
+
evidence below is from a real application (rkendel1/meetings), which built each of these itself. What shipped,
|
|
5
|
+
and where it differs from the proposal:
|
|
6
|
+
|
|
7
|
+
| # | Shipped as | Tests |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| P1 | `app.presence(name, shape, { ttlMs, onEnd, history })`, `ctx.presence.join/renew/end/history`, `ctx.db` showing live leases only; `bind: "session"` for resident agents. `onEnd` names an `app.agent`. | `test/presence.test.ts` |
|
|
10
|
+
| P2 | `app.channel(name, { message, access: { send, receive }, authorize: { send?, receive }, maxBytes, quota })` and `await ctx.channels.send(channel, scope, message)` in mutations; clients subscribe as to any event (`client.subscribe`, `useEvent`). | `test/channels.test.ts` |
|
|
11
|
+
| P3 | `quota` on functions (`per: "principal" \| "function" \| "arg:<name>" \| "principal+arg:<name>"`) and `feltkit({ quotas })`. | `test/quotas.test.ts` |
|
|
12
|
+
|
|
13
|
+
Differences from the proposal: P1's `onEnd` runs an `app.agent` (its own principal, at least once) instead of a
|
|
14
|
+
mutation "as the platform"; P3's counters are per process and in memory, so they do not survive a restart (see
|
|
15
|
+
docs/SECURITY.md, "Quotas"); P1 leases are ordinary FeltDB records until FeltDB's record TTL and ephemeral
|
|
16
|
+
collections can carry them. The "Also found" items below are fixed (`test/mcp-session-errors.test.ts`,
|
|
17
|
+
`test/dev-watch.test.ts`). The original proposal follows.
|
|
18
|
+
|
|
19
|
+
Three capabilities, each one an application had to build itself:
|
|
20
|
+
|
|
21
|
+
| # | Capability | Owning package | App code it replaces (meetings) |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| P1 | Presence: session-bound, expiring leases | FeltDB (lease records, expiry), FeltKit (API, session binding, live re-evaluation) | `feltkit/_presence.ts` + settlement in every call-touching mutation |
|
|
24
|
+
| P2 | Transient messages: scoped, authorized, not durable | AppPort (authorized, scoped events; UPSTREAM-GAPS A8, FK-GAP-004), then FeltKit | `feltkit/signals.ts` (a relay through durable records, deleted on read) |
|
|
25
|
+
| P3 | Quotas: per-principal limits on a function | FeltKit runtime (AppPort error semantics: `RATE_LIMITED`, `retryAfterMs`) | the signaling budget in `feltkit/signals.ts` |
|
|
26
|
+
|
|
27
|
+
## P1. Presence
|
|
28
|
+
|
|
29
|
+
### The gap (evidence)
|
|
30
|
+
|
|
31
|
+
- **No expiry.** FeltDB records do not expire, and a live query does not re-run because time passed. The
|
|
32
|
+
app keeps `lastSeenAt` per connection, treats `now - lastSeenAt > 45 s` as gone, and *settles* lazily:
|
|
33
|
+
every join, leave or check-in marks expired connections and ends calls whose last person is gone
|
|
34
|
+
(`settle()`). A crashed participant stays visible until someone else's next write, up to 45 s + one
|
|
35
|
+
check-in interval: **measured 60 s** (scripts/e2e-session-expiry.mjs).
|
|
36
|
+
- **No link between a session and the records it holds.** When a session ends (sign-out elsewhere,
|
|
37
|
+
revocation, expiry), FeltKit knows at once; the app does not. Measured (scripts/e2e-termination.mjs):
|
|
38
|
+
the participant's own browser stops media in ~11–12 s (its next heartbeat gets `UNAUTHORIZED`), but
|
|
39
|
+
**everyone else keeps a media connection open for 50–56 s**, until the presence expires. A client that
|
|
40
|
+
ignores the app keeps sending media for that long. Revocations the app *does* see (host removal,
|
|
41
|
+
access change) terminate in ~255 ms, including against a non-cooperating client.
|
|
42
|
+
- **It is subtle to get right.** The meetings audit found three lifecycle defects in the hand-built version
|
|
43
|
+
(a reload ended a solo call and split its recap; an expired connection was told it was "removed";
|
|
44
|
+
ghost tiles after a reload), each needing tests with a controlled clock.
|
|
45
|
+
|
|
46
|
+
### Why the application should not own it
|
|
47
|
+
|
|
48
|
+
Expiry needs a clock-driven write or a time-aware read that the application cannot schedule per record;
|
|
49
|
+
binding to sessions needs the session store, which applications cannot and should not read. Every
|
|
50
|
+
collaborative application (cursors, typing indicators, device sessions, multiplayer, calls) needs the
|
|
51
|
+
same thing.
|
|
52
|
+
|
|
53
|
+
### Contract (proposed)
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
// Declared like a collection; records are leases.
|
|
57
|
+
export const peers = app.presence("peers", { callId: s.ref(calls), name: s.string(), mic: s.boolean() }, {
|
|
58
|
+
ttlMs: 45_000, // a lease not renewed within ttlMs ends with reason "expired"
|
|
59
|
+
history: true, // ended leases are kept (who was present, when, why it ended)
|
|
60
|
+
onEnd: "calls:settle", // a mutation run (as the platform, at most once per lease) when one ends
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const lease = await ctx.presence.join(peers, { callId, name, mic: true }); // bound to the caller's session
|
|
64
|
+
await ctx.presence.renew(peers, lease.id, { mic: false }); // only by its holder
|
|
65
|
+
await ctx.presence.end(peers, lease.id, "left" | "removed"); // holder: left; others need access
|
|
66
|
+
const live = await ctx.db.find(peers, { callId }); // live leases only, in queries
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Guarantees:
|
|
70
|
+
|
|
71
|
+
1. A lease ends exactly once, with one reason: `left`, `removed`, `expired`, `session-ended`, `replaced`.
|
|
72
|
+
2. **When the holder's session ends, its leases end at once** (`session-ended`), on every surface.
|
|
73
|
+
3. A live query over a presence collection re-runs when a lease ends by time, not only by write.
|
|
74
|
+
4. `onEnd` runs after the end commits, at most once per lease, with the lease and reason.
|
|
75
|
+
5. Ended leases remain readable as history (attendance) when `history: true`.
|
|
76
|
+
|
|
77
|
+
### Regression tests (to write with the implementation)
|
|
78
|
+
|
|
79
|
+
- a lease not renewed for `ttlMs` disappears from a live query without any other write;
|
|
80
|
+
- signing out, revoking the session and session expiry each end the session's leases with `session-ended`,
|
|
81
|
+
observed by another principal's live query within one second;
|
|
82
|
+
- `onEnd` runs once per ended lease under concurrent renew/end/expiry;
|
|
83
|
+
- only the holder renews; another principal's `end` is authorized by the function's access, not by the lease;
|
|
84
|
+
- history keeps reason and times across restart.
|
|
85
|
+
|
|
86
|
+
## P2. Transient messages
|
|
87
|
+
|
|
88
|
+
### The gap (evidence)
|
|
89
|
+
|
|
90
|
+
AppPort events cannot carry per-recipient messages safely: subscriptions are not authorized per
|
|
91
|
+
subscriber or per delivery, and events have no scope (UPSTREAM-GAPS A8; FeltKit's FK-GAP-004 is blocked on
|
|
92
|
+
it). So the meetings app relays WebRTC offers and answers **through durable records**: insert, live query
|
|
93
|
+
by recipient, delete on acknowledgement, delete on departure, with app-built limits (one pending signal
|
|
94
|
+
per pair, 60 per minute per connection, 64 kB, role checks). Every signal is a FeltDB transaction.
|
|
95
|
+
|
|
96
|
+
### Contract (proposed)
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
export const signaling = app.channel("signaling", {
|
|
100
|
+
message: s.object({ kind: s.enum(["offer", "answer"]), sdp: s.string({ maxLength: 65_536 }) }),
|
|
101
|
+
// Who may send to and receive on a scope (here: a connection id), decided per message.
|
|
102
|
+
authorize: { send: "calls:maySignal", receive: "calls:ownsConnection" },
|
|
103
|
+
quota: { per: "principal", limit: 60, windowMs: 60_000 },
|
|
104
|
+
});
|
|
105
|
+
await ctx.channels.send(signaling, toConnectionId, { kind: "offer", sdp }); // at most once, not stored
|
|
106
|
+
useChannel(signaling, myConnectionId, (message, from) => …); // React
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Guarantees: delivered at most once to current, authorized subscribers of the scope; nothing durable;
|
|
110
|
+
authorization at subscribe **and** at each delivery; bounded size; quota enforced by the platform.
|
|
111
|
+
|
|
112
|
+
### Regression tests
|
|
113
|
+
|
|
114
|
+
- a subscriber not authorized for a scope receives nothing, including with a `*` subscription;
|
|
115
|
+
- authorization is re-evaluated per delivery (revoked mid-stream → no further messages);
|
|
116
|
+
- quota exceeded → `RATE_LIMITED` with `retryAfterMs`, other senders unaffected;
|
|
117
|
+
- nothing about a message remains in FeltDB after delivery.
|
|
118
|
+
|
|
119
|
+
## P3. Quotas
|
|
120
|
+
|
|
121
|
+
### The gap (evidence)
|
|
122
|
+
|
|
123
|
+
FeltKit has no rate limiting (SECURITY.md: "put a reverse proxy in front"). A proxy cannot see the
|
|
124
|
+
principal or the meeting, so the app counts signals itself on the sender's presence record (a write per
|
|
125
|
+
signal, contending with its heartbeats). Chat and reactions have no limit at all.
|
|
126
|
+
|
|
127
|
+
### Contract (proposed)
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
app.mutation({ access: "chat.send", quota: { per: "principal", limit: 30, windowMs: 10_000 }, … });
|
|
131
|
+
app.mutation({ quota: [{ per: "principal", limit: 60, windowMs: 60_000 }, { per: "arg:code", limit: 600, windowMs: 60_000 }], … });
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Refused with `RATE_LIMITED` and `details.retryAfterMs` before the handler runs; recorded in the activity log;
|
|
135
|
+
the same on HTTP, AppPort and MCP; counters kept outside the application's transaction.
|
|
136
|
+
|
|
137
|
+
### Regression tests
|
|
138
|
+
|
|
139
|
+
- the (limit+1)th call in a window is refused before the handler runs, on HTTP, `/appport` and `/mcp`;
|
|
140
|
+
- `per: "arg:<name>"` isolates scopes; a refused call commits nothing;
|
|
141
|
+
- counters survive restart; concurrent calls never exceed the limit.
|
|
142
|
+
|
|
143
|
+
## Also found while building the evidence
|
|
144
|
+
|
|
145
|
+
- **MCP dropped idempotency keys** (fixed: `test/mcp-idempotency.test.ts`).
|
|
146
|
+
- **`measure` counted presence, relays and media transports as domain** (fixed: three detectors and the
|
|
147
|
+
ownership check, `test/measure.test.ts`).
|
|
148
|
+
- An expired agent session is refused on `/mcp` with "An agent session token is required", which reads as
|
|
149
|
+
a missing token, not an expired one.
|
|
150
|
+
- `feltkit dev` stopped reloading a function module after a sequence of edits (an edit, then the file
|
|
151
|
+
restored by copy, then `touch`): no "Reloaded functions" line, old code kept serving until restart.
|
|
152
|
+
Not yet reduced to a reproduction.
|