@feltdb/feltkit 0.3.15 → 0.3.16

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.
@@ -43,34 +43,31 @@ host runs artifacts in Docker, Podman, a microVM or something else is AppBoundry
43
43
  does not depend on it.
44
44
 
45
45
  ```bash
46
- npx feltkit deploy --target appboundry # APPBOUNDRY_URL, APPBOUNDRY_TOKEN (APPBOUNDRY_HOST while M1a needs it)
46
+ npx feltkit deploy --target appboundry # APPBOUNDRY_URL, APPBOUNDRY_TOKEN (a deploy token); APPBOUNDRY_HOST optional
47
47
  npx feltkit status
48
48
  ```
49
49
 
50
50
  | Output | Owner | What it is |
51
51
  |---|---|---|
52
52
  | Application artifact | FeltKit build | `.feltkit/appboundry/<name>.app`: manifest, module that imports nothing, frontend |
53
- | Deployment request | FeltKit → AppBoundry | the artifact uploaded as a deterministic `.tar.gz` (with `x-archive-sha256`), then a deployment intent (`artifactId`, host, `Idempotency-Key`) |
53
+ | Deployment request | FeltKit → AppBoundry | the artifact uploaded as a deterministic `.tar.gz` (with `x-archive-sha256`), then a deployment intent (`artifactId`, optional host, `Idempotency-Key`) |
54
54
  | Execution environment | AppBoundry | never visible to FeltKit |
55
55
 
56
- `src/cli/deploy-appboundry.ts` speaks AppBoundry's managed-hosting API (rkendel1/appboundry
57
- `apps/cloud-portal`, M1a): `GET /api/applications/{id}/hosting`, `POST …/artifacts`, `POST …/deployments`,
58
- `GET …/deployments/{id}`. AppBoundry verifies the upload itself and stores it immutably; the same build
59
- always produces the same archive and the same artifact. FeltKit reports **Running** only when AppBoundry
60
- says Running and its evidence (reported by the runtime, recorded by the portal) names the module this
61
- build produced. `feltkit status` asks AppBoundry, using the request recorded in
62
- `.feltkit/appboundry/deployment.json` (never the token).
63
-
64
- **What AppBoundry still needs before this works against a production portal** (all on AppBoundry's side;
65
- FeltKit's adapter is written to the contract and tested against a stand-in for it). The full contract FeltKit
66
- expects, endpoint by endpoint, with acceptance tests for both sides: [APPBOUNDRY-DEPLOY-CONTRACT.md](APPBOUNDRY-DEPLOY-CONTRACT.md).
67
-
68
- 1. **A deploy credential.** The M1a operator API accepts only a signed-in platform owner's browser session.
69
- A CLI needs a scoped token AppBoundry issues and accepts as `Authorization: Bearer`.
70
- 2. **Registration from the artifact.** Today the application is registered once in the portal UI; deploy
71
- refuses an unregistered application with that instruction.
72
- 3. **Placement.** M1a asks the caller for the execution host (`APPBOUNDRY_HOST`); AppBoundry should choose.
73
- 4. **An address.** M1 has no public routing yet, so a Running deployment has no URL to report.
56
+ `src/cli/deploy-appboundry.ts` speaks AppBoundry's managed-hosting API with a **deploy token** the platform
57
+ owner issues (scoped to one application or an organization; revocable; optional expiry):
58
+ `GET /api/applications/{id}/hosting`, `POST …/artifacts`, `POST …/deployments`, `GET …/deployments/{id}`.
59
+ AppBoundry verifies the upload itself, stores it immutably, and registers the application from the verified
60
+ manifest the first time (when the token's scope allows). Without `APPBOUNDRY_HOST`, AppBoundry places the
61
+ deployment. FeltKit checks that the artifact AppBoundry accepted is this build (`artifactId` = SHA-256 of
62
+ `manifest.json`, and the module digest) and reports **Running** only when AppBoundry says Running and its
63
+ evidence (from the runtime, via the host's agent) names this build's module, on the current attempt.
64
+ `feltkit status` asks AppBoundry, using the references in `.feltkit/appboundry/deployment.json` (never the
65
+ token). The contract: [APPBOUNDRY-DEPLOY-CONTRACT.md](APPBOUNDRY-DEPLOY-CONTRACT.md).
66
+
67
+ **What is not there yet, on AppBoundry's side:** public routing (a Running deployment has no address yet:
68
+ FeltKit says so), and execution of deploy-token deployments in production: AppBoundry keeps its isolation
69
+ release gate closed until the runtime's isolation requirements pass, and answers `NO_EXECUTION_CAPACITY
70
+ (untrusted_execution_disabled)` meanwhile. The artifact is stored; nothing runs.
74
71
 
75
72
  ### Running the AppBoundry runtime yourself: `--target appboundry-self-hosted`
76
73
 
@@ -229,6 +229,28 @@ published contract declares (`appport.integration/1` `failures`). Tests:
229
229
  - Session tokens are bearer tokens: anyone holding one acts as its principal until it
230
230
  expires or is revoked.
231
231
 
232
+ ### Secure tokens (`ctx.crypto.token`)
233
+
234
+ Tokens are drawn from Node's CSPRNG (`crypto.randomBytes`) in FeltKit's runtime and by the host in an
235
+ AppBoundry artifact (`crypto@1`); the guest never generates them. 16–256 bytes (default 32), base64url.
236
+ Tested: `test/crypto-token.test.ts` (uniqueness, per-bit variation, bounds, artifact, refusal without
237
+ the interface); on AppBoundry's side, the appboundry-host crypto tests in `rkendel1/appboundry`.
238
+
239
+ ### Application authorization (`feltkit({ authorize })`)
240
+
241
+ | Guarantee | How | Test |
242
+ |---|---|---|
243
+ | Every interface, one decision | Evaluated in the one execution path every call takes (`/api`, AppPort, MCP, agent actions, jobs) and in the AppBoundry guest | `test/authorize.test.ts` (HTTP, AppPort, a real MCP client, the compiled artifact) |
244
+ | Order | Roles, then argument validation, then `authorize`, then the handler. A caller without the role, or with invalid arguments, never reaches it | same |
245
+ | Decision and effect agree | The hook reads through the call's own `ctx.db`: a mutation's commit is checked against those reads; a change in between is `CONFLICT` and nothing is written | same ("membership revoked mid-call") |
246
+ | Revocation is live | A query's live read set includes the hook's reads; a watching client gets `FORBIDDEN` on the next run | same ("live") |
247
+ | Fail closed | A hook that throws (other than a FeltKit `FORBIDDEN`/`UNAUTHORIZED`), returns something other than a boolean or an AppPort decision, or tries to write refuses the call (`INTERNAL`) | same |
248
+ | Evidence | Denials and allows are recorded in the activity entry's `authority.resource`, beside the role decision and its id | same |
249
+
250
+ Not covered: the hook does not run for AppPort Services effects made directly by services
251
+ (those are authorized by the role policy and the services' own ownership rules), and FeltKit
252
+ does not evaluate resources with AuthBoundry (UPSTREAM-GAPS).
253
+
232
254
  ## AppPort Services
233
255
 
234
256
  Services run on the application's FeltDB instance (`createServices({ db })`,
package/docs/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # FeltKit 0.3.15 documentation
1
+ # FeltKit 0.3.16 documentation
2
2
 
3
3
  Shipped with `@feltdb/feltkit`. In a project: `node_modules/@feltdb/feltkit/docs/`, or run `npx feltkit docs`.
4
- Public copy: https://cdn.jsdelivr.net/npm/@feltdb/feltkit@0.3.15/docs/README.md
4
+ Public copy: https://cdn.jsdelivr.net/npm/@feltdb/feltkit@0.3.16/docs/README.md
5
5
 
6
6
  - [ARCHITECTURE.md](ARCHITECTURE.md): How FeltKit is put together: one FeltDB instance, AppPort, AppPort Services
7
7
  - [GUARANTEES.md](GUARANTEES.md): What FeltKit guarantees, and its known limitations
@@ -89,6 +89,8 @@ A1–A4 are closed by the released `@appport/core` 1.4.0 / `@appport/sdk` 1.4.0
89
89
  | A5 | A handler cannot report "outcome unknown" itself. Any error it throws releases the claim, so when an integration handler throws `OUTCOME_UNKNOWN` (the API gave no definite answer), or a mutation's FeltDB commit is unconfirmed (`COMMIT_OUTCOME_UNKNOWN`), a same-key replay reaches the handler again | — | Integrations: `runtime/integrations.ts` refuses that replay from its own call record (`_feltkit_integration_calls`) with AppPort's `IdempotencyOutcomeUnknownError`; the call record stays, it is also the evidence of the external request. Mutations: the FeltDB transaction id is derived from AppPort's replay key (`idempotencyStorageKey`), so FeltDB's transaction-id binding refuses the replay (`IDEMPOTENCY_CONFLICT` → FeltKit `OUTCOME_UNKNOWN`, `committed: true`) instead of writing again; tests "A5: …" in `test/appport-adoption.test.ts` | Open. Ask: a way for a handler to end a request with its claim kept, e.g. an error flag (`keepIdempotencyClaim`) or a documented error reason the runtime treats as unknown |
90
90
  | A6 | `handleRequest` validates a request's input before it asks the authorizer, so a caller without the capability's permission and with invalid input gets `INVALID_INPUT` (learning the input contract) instead of `FORBIDDEN`, and the refusal is not a denial | — | The capability's input schema, which FeltKit supplies (`runtime/capabilities.ts`), runs FeltKit's policy check first: `handleRequest` / `handleStreamRequest` are wrapped to carry the caller (AsyncLocalStorage), and the gate throws AppPort's `FORBIDDEN` / `UNAUTHORIZED` from `validate()`, which AppPort answers and reports as a denial. FeltKit's own call path authorizes again. Test: "authority before arguments on AppPort too" in `test/auth.test.ts` | Open. Ask: authorize before validating input when `authorization` does not depend on the input (or an authorizer flag to be consulted first) |
91
91
  | 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 |
92
+ | 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 |
93
+ | 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 |
92
94
 
93
95
  ## AppPort Services (`rkendel1/appport-services`)
94
96
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feltdb/feltkit",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
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",
@@ -62,7 +62,7 @@
62
62
  "@appport/server": "1.1.5",
63
63
  "@appport/services": ">=0.15.0 <1.0.0",
64
64
  "@feltdb/core": ">=0.21.0 <1.0.0",
65
- "create-feltkit": "0.3.15",
65
+ "create-feltkit": "0.3.16",
66
66
  "esbuild": "0.25.12",
67
67
  "express": "4.22.3",
68
68
  "mailerport": ">=0.1.0 <1.0.0",
@@ -10,7 +10,7 @@
10
10
  "name": "feltkit",
11
11
  "source": "./",
12
12
  "description": "Skills for building and operating FeltKit applications.",
13
- "version": "0.3.15"
13
+ "version": "0.3.16"
14
14
  }
15
15
  ]
16
16
  }
@@ -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.15",
4
+ "version": "0.3.16",
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"
@@ -33,10 +33,11 @@ tests/*.test.ts run by `feltkit test`
33
33
  (`exceptions.add-evidence` fails at load; write `exceptions.addevidence` or `evidence.add`). The `returns` schema is
34
34
  the published contract and rejects undeclared fields: derive it from the collection with `s.doc(tasks)`, and project
35
35
  with `.pick(...)`, `.omit(...)`, `.extend({...})`; never restate a collection's fields in a second schema.
36
- 5. Grant the permission to roles in `feltkit({ roles })`. Use `npx feltkit dev`; check the dashboard's Capabilities screen.
36
+ 5. Per-record rules ("only members of this workspace") go in one `feltkit({ authorize })` hook, not in each handler: it gets `{ function, args, principal, db }` after roles and validation and returns `true` or `{ allowed: false, reason }`.
37
+ 6. Grant the permission to roles in `feltkit({ roles })`. Use `npx feltkit dev`; check the dashboard's Capabilities screen.
37
38
  People sign in to a deployed app through built-in accounts, `auth: { accounts: { roles: ["member"] } }` (the starter has it; the frontend calls `useSession().signUp/signIn`), or an identity provider through `auth.authenticate`.
38
39
  Password reset and address verification: `auth.accounts.email: { from, verify? }` (Mailerport; `MAILPORT_URL`/`MAILPORT_API_KEY` in production; the client's `requestPasswordReset`, `resetPassword`, `requestVerification`, `handleRedirect`). Google, GitHub, or OIDC sign-in: `auth.providers` with a `clientId` each and the secret as `credential-ref:<id>-client-secret`; never put a client secret in code. Both need `FELTKIT_PUBLIC_URL` and `FELTKIT_AUTH_SECRET` in production (`feltkit vercel env` sets them).
39
- 6. Add or update a test with `createTestApp`; run `npx feltkit test`. Then `npx feltkit build`.
40
+ 7. Add or update a test with `createTestApp`; run `npx feltkit test`. Then `npx feltkit build`.
40
41
 
41
42
  ```ts
42
43
  // feltkit/app.ts