@feltdb/feltkit 0.3.29 → 0.3.31
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 +101 -11
- package/dist/app.js +131 -3
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.js +2 -0
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest-tenancy.d.ts +2 -2
- package/dist/appboundry/guest-tenancy.js.map +1 -1
- package/dist/appboundry/guest.js +27 -2
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/appboundry/host.js +3 -0
- package/dist/appboundry/host.js.map +1 -1
- package/dist/authorize.d.ts +47 -4
- package/dist/authorize.js +37 -0
- package/dist/authorize.js.map +1 -1
- package/dist/cli/deploy-appboundry.d.ts +1 -1
- package/dist/cli/deploy-appboundry.js.map +1 -1
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/main.js +27 -1
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/dashboard/assets/index-9rMS3yBm.js +15 -0
- package/dist/dashboard/assets/index-DkiYTUMR.css +1 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +4 -0
- package/dist/docs.js.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/event-stage.js.map +1 -1
- package/dist/execution.d.ts +186 -0
- package/dist/execution.js +105 -0
- package/dist/execution.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/measure/index.js.map +1 -1
- package/dist/platform/approvals.js.map +1 -1
- package/dist/platform/artifacts.js.map +1 -1
- package/dist/platform/changes.d.ts +54 -54
- package/dist/platform/changes.js.map +1 -1
- package/dist/platform/deployments.d.ts +32 -32
- package/dist/platform/exec.js.map +1 -1
- package/dist/platform/platform.js.map +1 -1
- package/dist/platform/releases.js.map +1 -1
- package/dist/platform/server.js.map +1 -1
- package/dist/platform/workspaces.js.map +1 -1
- package/dist/policy.d.ts +172 -0
- package/dist/policy.js +311 -0
- package/dist/policy.js.map +1 -0
- package/dist/react/auth.d.ts +10 -10
- package/dist/react/auth.js +1 -1
- package/dist/react/auth.js.map +1 -1
- package/dist/react/context.d.ts +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/runtime/accounts.js.map +1 -1
- package/dist/runtime/activity.d.ts +17 -1
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/agent.d.ts +3 -3
- package/dist/runtime/agent.js +9 -3
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/application-authority.d.ts +33 -3
- package/dist/runtime/application-authority.js +74 -14
- package/dist/runtime/application-authority.js.map +1 -1
- package/dist/runtime/assemble.d.ts +13 -0
- package/dist/runtime/assemble.js +29 -1
- package/dist/runtime/assemble.js.map +1 -1
- package/dist/runtime/audit.js.map +1 -1
- package/dist/runtime/authboundry.d.ts +17 -0
- package/dist/runtime/authboundry.js +8 -1
- package/dist/runtime/authboundry.js.map +1 -1
- package/dist/runtime/authority.d.ts +10 -0
- package/dist/runtime/authority.js +17 -0
- package/dist/runtime/authority.js.map +1 -1
- package/dist/runtime/backup-environment.js.map +1 -1
- package/dist/runtime/backup.js.map +1 -1
- package/dist/runtime/changes.js.map +1 -1
- package/dist/runtime/claims.js.map +1 -1
- package/dist/runtime/collections.js.map +1 -1
- package/dist/runtime/content.d.ts +77 -2
- package/dist/runtime/content.js +153 -6
- package/dist/runtime/content.js.map +1 -1
- package/dist/runtime/context.d.ts +207 -3
- package/dist/runtime/contract.js +16 -3
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/credentials.d.ts +31 -2
- package/dist/runtime/credentials.js +55 -3
- package/dist/runtime/credentials.js.map +1 -1
- package/dist/runtime/crypto-token.js.map +1 -1
- package/dist/runtime/data.d.ts +25 -0
- package/dist/runtime/data.js +92 -8
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/decisions.js.map +1 -1
- package/dist/runtime/deployment.js.map +1 -1
- package/dist/runtime/execution-host.d.ts +54 -0
- package/dist/runtime/execution-host.js +54 -0
- package/dist/runtime/execution-host.js.map +1 -0
- package/dist/runtime/generation.js.map +1 -1
- package/dist/runtime/image-variants.d.ts +48 -0
- package/dist/runtime/image-variants.js +295 -0
- package/dist/runtime/image-variants.js.map +1 -0
- package/dist/runtime/instance.js.map +1 -1
- package/dist/runtime/integrations.d.ts +8 -6
- package/dist/runtime/integrations.js +46 -5
- package/dist/runtime/integrations.js.map +1 -1
- package/dist/runtime/invocations.d.ts +313 -0
- package/dist/runtime/invocations.js +493 -0
- package/dist/runtime/invocations.js.map +1 -0
- package/dist/runtime/live.d.ts +10 -7
- package/dist/runtime/live.js +24 -12
- package/dist/runtime/live.js.map +1 -1
- package/dist/runtime/loader.js.map +1 -1
- package/dist/runtime/local-authority.d.ts +92 -0
- package/dist/runtime/local-authority.js +396 -0
- package/dist/runtime/local-authority.js.map +1 -0
- package/dist/runtime/oauth-credentials.d.ts +40 -3
- package/dist/runtime/oauth-credentials.js +133 -25
- package/dist/runtime/oauth-credentials.js.map +1 -1
- package/dist/runtime/outbox.js +3 -0
- package/dist/runtime/outbox.js.map +1 -1
- package/dist/runtime/policies.d.ts +89 -0
- package/dist/runtime/policies.js +152 -0
- package/dist/runtime/policies.js.map +1 -0
- package/dist/runtime/projects.d.ts +1 -1
- package/dist/runtime/readiness.js +11 -0
- package/dist/runtime/readiness.js.map +1 -1
- package/dist/runtime/runtime.d.ts +66 -5
- package/dist/runtime/runtime.js +328 -18
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services-rules.d.ts +9 -0
- package/dist/runtime/services-rules.js +47 -1
- package/dist/runtime/services-rules.js.map +1 -1
- package/dist/runtime/services.d.ts +154 -9
- package/dist/runtime/services.js +343 -14
- package/dist/runtime/services.js.map +1 -1
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/state-contract.js.map +1 -1
- package/dist/runtime/storage-check.js.map +1 -1
- package/dist/runtime/targets.d.ts +1 -1
- package/dist/runtime/tenancy.js.map +1 -1
- package/dist/runtime/transactions.d.ts +15 -0
- package/dist/runtime/transactions.js +5 -0
- package/dist/runtime/transactions.js.map +1 -1
- package/dist/schema.js.map +1 -1
- package/dist/server/admin.d.ts +72 -51
- package/dist/server/admin.js +125 -0
- package/dist/server/admin.js.map +1 -1
- package/dist/server/components.js.map +1 -1
- package/dist/server/index.js +72 -6
- package/dist/server/index.js.map +1 -1
- package/dist/server/management.js.map +1 -1
- package/dist/server/mcp.d.ts +59 -37
- package/dist/server/mcp.js +24 -1
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/operators.d.ts +1 -0
- package/dist/server/operators.js +1 -1
- package/dist/server/operators.js.map +1 -1
- package/dist/server/ports.d.ts +7 -0
- package/dist/server/ports.js +17 -0
- package/dist/server/ports.js.map +1 -1
- package/dist/server/production.js.map +1 -1
- package/dist/server/project.js.map +1 -1
- package/dist/server/session-http.js.map +1 -1
- package/dist/server/tenancy.js.map +1 -1
- package/dist/surfaces.d.ts +153 -0
- package/dist/surfaces.js +228 -0
- package/dist/surfaces.js.map +1 -0
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-OPERATIONS.md +1 -1
- package/docs/ARCHITECTURE.md +2 -1
- package/docs/CONNECTIONS.md +151 -0
- package/docs/EXECUTION.md +271 -0
- package/docs/GUARANTEES.md +134 -8
- package/docs/INVOCATIONS.md +170 -0
- package/docs/POLICIES.md +121 -0
- package/docs/README.md +6 -2
- package/docs/SECURITY.md +30 -0
- package/docs/TRANSACTIONS.md +4 -0
- package/package.json +27 -19
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-services/SKILL.md +1 -1
- package/dist/dashboard/assets/index-BehzsQOa.css +0 -1
- package/dist/dashboard/assets/index-UuZ63NA6.js +0 -15
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# People's own connections (`credential.owner: "person"`)
|
|
2
|
+
|
|
3
|
+
> **Status: reference implementation.** This branch preserves a FeltKit implementation that passed
|
|
4
|
+
> its acceptance tests. The decided ownership (2026-11-13):
|
|
5
|
+
>
|
|
6
|
+
> - **AppPort Services** defines the portable contract for a user-owned connection.
|
|
7
|
+
> - **FeltKit** implements it as one host, with the code described here.
|
|
8
|
+
> - **AuthBoundry** decides every use.
|
|
9
|
+
>
|
|
10
|
+
> The AppPort contract is still to be written from this implementation. Until it is, this document
|
|
11
|
+
> describes FeltKit's behavior, not a published AppPort interface.
|
|
12
|
+
|
|
13
|
+
An application declares an integration once. Each person connects **their own** account to it:
|
|
14
|
+
|
|
15
|
+
- Ada's mailbox is Ada's, and Grace's is Grace's.
|
|
16
|
+
- Each grant is kept apart, renewed and revoked on its own.
|
|
17
|
+
- A grant is used only for work done for its owner, with AuthBoundry deciding every call on their
|
|
18
|
+
behalf.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
export const mail = app.integration("mail", {
|
|
22
|
+
baseUrl: { env: "MAIL_API_URL" },
|
|
23
|
+
credential: {
|
|
24
|
+
ref: "credential-ref:mail",
|
|
25
|
+
owner: "person", // each person connects their own account
|
|
26
|
+
oauth2: { tokenUrl: { env: "MAIL_TOKEN_URL" }, authorizeUrl: { env: "MAIL_AUTHORIZE_URL" },
|
|
27
|
+
revokeUrl: { env: "MAIL_REVOKE_URL" }, clientId: { env: "MAIL_CLIENT_ID" },
|
|
28
|
+
clientSecret: "credential-ref:mail-client-secret", scopes: ["mail.read", "offline.access"] },
|
|
29
|
+
},
|
|
30
|
+
operations: {
|
|
31
|
+
me: { method: "GET", path: "/me", output: Out, effect: "observation", access: "mail.read" },
|
|
32
|
+
send: { method: "POST", path: "/send", input: { to: s.string(), text: s.string() }, output: Out,
|
|
33
|
+
effect: "consequential", access: "mail.send", authority: "mail.send" },
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`owner: "person"` requires `oauth2`. The default, `owner: "application"`, is unchanged: one grant
|
|
39
|
+
for the application, connected by someone holding `credential.store`.
|
|
40
|
+
|
|
41
|
+
## Four separate things
|
|
42
|
+
|
|
43
|
+
| | What | Where |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| Integration | the application knows how to reach the provider: endpoints, client, operations | `app.integration(...)` |
|
|
46
|
+
| Connection | Ada connected her account | FeltKit's credential vault, one entry per (integration, person) |
|
|
47
|
+
| Authority | what Ada allows the application to do with it | AuthBoundry: the person's grant of each operation's capability to the application's executor |
|
|
48
|
+
| Execution | a call made for Ada uses Ada's grant, decided now | `ctx.integrations.invoke`, FeltKit's integration host |
|
|
49
|
+
|
|
50
|
+
## Connecting, seeing, disconnecting: only one's own
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
await ctx.integrations.connections.connect("mail"); // { url, expiresAt }: open the provider's page
|
|
54
|
+
await ctx.integrations.connections.list(); // [{ integration, state, scope, expiresAt, renewable, connectedAt, renewals, failure? }]
|
|
55
|
+
await ctx.integrations.connections.disconnect("mail"); // { disconnected, providerRevocation }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Over HTTP, with the person's session:
|
|
59
|
+
|
|
60
|
+
- `POST /api/integrations/<name>/oauth/connect` starts it;
|
|
61
|
+
- the provider returns to `/api/integrations/<name>/oauth/callback`;
|
|
62
|
+
- `GET /api/integrations/connections` lists them;
|
|
63
|
+
- `DELETE /api/integrations/<name>/connection` disconnects.
|
|
64
|
+
|
|
65
|
+
The rules:
|
|
66
|
+
|
|
67
|
+
- **Who.** Only a signed-in person (`type: "user"`), for themselves. No permission, `credential.store`
|
|
68
|
+
included, lets anyone connect, list or disconnect another person's connection. A service or agent
|
|
69
|
+
connects nothing.
|
|
70
|
+
- **Connecting.** It uses authorization code with PKCE (S256). The state is single use, expires after
|
|
71
|
+
10 minutes, and is bound to the person who started it, so only that person completes it.
|
|
72
|
+
- **Disconnecting.**
|
|
73
|
+
1. The provider is asked to revoke both tokens (RFC 7009), when it declares how.
|
|
74
|
+
2. The grant is erased here, whatever the provider answered.
|
|
75
|
+
3. The next call is refused, and nothing is sent.
|
|
76
|
+
- **Status** never carries a token.
|
|
77
|
+
|
|
78
|
+
## Using a connection
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
await ctx.integrations.invoke("mail.me", {}); // a person: their own connection
|
|
82
|
+
await ctx.integrations.invoke("mail.me", {}, { onBehalfOf: "ada" }); // the application's own principal, for Ada
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
At every call, in this order. If any step refuses, nothing is recorded as sent and nothing is sent.
|
|
86
|
+
|
|
87
|
+
1. **The caller holds the operation's `access`** (as for every integration).
|
|
88
|
+
2. **Whose connection.**
|
|
89
|
+
- A signed-in person always uses their own. Naming anyone else is `FORBIDDEN`.
|
|
90
|
+
- A service, agent or system principal must name the person (`onBehalfOf`). It has no connection
|
|
91
|
+
of its own.
|
|
92
|
+
3. **AuthBoundry decides, now.** The application's executor asks for the operation's capability
|
|
93
|
+
(`authority`, default `<integration>.<operation>`), on behalf of that person.
|
|
94
|
+
- A deny is `FORBIDDEN`.
|
|
95
|
+
- An authority that can't answer is `UNAVAILABLE` (retryable).
|
|
96
|
+
- Withdrawing a grant stops the very next call.
|
|
97
|
+
4. **The person's grant is resolved.** It is renewed first if it's about to expire. None is
|
|
98
|
+
`FAILED_PRECONDITION` (connect first). It never falls back to anyone else's grant, or to an
|
|
99
|
+
application grant.
|
|
100
|
+
|
|
101
|
+
The call record (`integrations.calls()`) keeps `onBehalfOf` and AuthBoundry's decision
|
|
102
|
+
(`capability`, `decisionId`, `delegationId`). Activity records connect, renewal, failure, revocation
|
|
103
|
+
and denial. Neither ever holds a token.
|
|
104
|
+
|
|
105
|
+
With `authority.local`, every operation of a person-owned integration is added to the private
|
|
106
|
+
AuthBoundry's capabilities, so a person can grant each one.
|
|
107
|
+
|
|
108
|
+
## Isolation
|
|
109
|
+
|
|
110
|
+
- **Separate custody entries.** Each connection is its own entry, at
|
|
111
|
+
`connection:<integration>:<sha-256 digest of the person's id>`, and records its owner.
|
|
112
|
+
- **The custody contract refuses those ids.** `store`, `remove` and `withSecret` are what AppPort's
|
|
113
|
+
`credential.store`, Studio and the CLI use. FeltKit's `storeCredential` refuses them too.
|
|
114
|
+
- **Not listed.** They don't appear in the credential inventory.
|
|
115
|
+
- **Reads check the owner.** A read without the owner, or as anyone else, returns nothing. Another
|
|
116
|
+
person's material can't be stored in someone's place.
|
|
117
|
+
- **Renewal is per connection.** Single flight and the lock are keyed by the connection's id, and the
|
|
118
|
+
compare-and-set by its version. One person's renewal, rotation or failure never touches another's.
|
|
119
|
+
- **The database vault** (`FELTKIT_CREDENTIAL_VAULT=database`) encrypts each entry under the host's
|
|
120
|
+
key, bound to its id.
|
|
121
|
+
|
|
122
|
+
## Application integrations are unchanged
|
|
123
|
+
|
|
124
|
+
- An integration without `owner: "person"` keeps one grant: connected with `credential.store`, used by
|
|
125
|
+
every caller holding the operation's `access`.
|
|
126
|
+
- AuthBoundry isn't asked; it never was for these.
|
|
127
|
+
- `onBehalfOf` on such a call is refused (`INVALID_ARGUMENT`) rather than ignored.
|
|
128
|
+
|
|
129
|
+
## Evidence (`packages/sdk/test/connections.test.ts`)
|
|
130
|
+
|
|
131
|
+
The tests use a simulated OAuth provider: each token belongs to the account it was issued for. A
|
|
132
|
+
scripted AuthBoundry speaks the check contract, plus one run uses the real private AuthBoundry. They
|
|
133
|
+
cover:
|
|
134
|
+
|
|
135
|
+
- two people connecting one integration;
|
|
136
|
+
- independent renewal (concurrent, rotation, one person's revoked refresh token);
|
|
137
|
+
- independent revocation (disconnect, a withdrawn grant, per-operation authority);
|
|
138
|
+
- cross-user isolation: another person, an administrator with every permission, a service, custody
|
|
139
|
+
writes and reads, and a replayed callback;
|
|
140
|
+
- application-integration compatibility;
|
|
141
|
+
- failure and recovery: authority down, token endpoint down, restart.
|
|
142
|
+
|
|
143
|
+
## Not covered here
|
|
144
|
+
|
|
145
|
+
- **The AppPort Services contract.** It is to be written from this implementation.
|
|
146
|
+
- **An administrator revoking someone's connection** in an incident. There's no route; a person
|
|
147
|
+
disconnects their own.
|
|
148
|
+
- **Grant types other than OAuth 2.0 authorization code.** API-key connections per person aren't
|
|
149
|
+
supported.
|
|
150
|
+
- **Pending connections live in memory.** A connection started on one process must finish on that
|
|
151
|
+
process.
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# Placement-neutral execution
|
|
2
|
+
|
|
3
|
+
An invocation has the same identity, lifecycle, authority and evidence wherever its work runs.
|
|
4
|
+
**FeltKit's control plane is authoritative; the computer is replaceable.**
|
|
5
|
+
|
|
6
|
+
## Control plane and execution plane
|
|
7
|
+
|
|
8
|
+
| | Owns | Where |
|
|
9
|
+
|---|---|---|
|
|
10
|
+
| **Control plane** (FeltKit) | the invocation, its executions and attempts, the authority work runs under, placement, leases and fencing, dispatch and recovery, evidence | `runtime/invocations.ts`, the after-commit outbox, the services worker |
|
|
11
|
+
| **Execution plane** (an environment) | running the work, and reporting what happened through the control plane's fenced operations | an `ExecutionAdapter` (`runtime/execution-host.ts`) |
|
|
12
|
+
|
|
13
|
+
An environment gains **no authority** by being registered, trusted or Boundry-operated. It can
|
|
14
|
+
disappear: the lifecycle and its evidence are in FeltKit's platform state
|
|
15
|
+
(`_feltkit_invocations`, `_feltkit_outbox`), never in a worker's memory, files or queue.
|
|
16
|
+
|
|
17
|
+
## Identities
|
|
18
|
+
|
|
19
|
+
| | Id | Stable across |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| Invocation | `inv_…` | everything: retries, recovery, re-dispatch |
|
|
22
|
+
| Execution | `exe_…` (the invocation's n-th; one today) | attempts and re-dispatches |
|
|
23
|
+
| Attempt | `att_…_<n>` | nothing: each claim is a new attempt |
|
|
24
|
+
|
|
25
|
+
## The execution contract: `feltkit.execution/1`
|
|
26
|
+
|
|
27
|
+
This is what an environment receives (`ExecutionRequest`, `src/execution.ts`), kept as small as the
|
|
28
|
+
platform needs:
|
|
29
|
+
|
|
30
|
+
| Field | Meaning |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `invocation`, `execution` | the identities above |
|
|
33
|
+
| `work` | `{ operation, version }`: the job type the application declares; version `"1"` until operations are versioned |
|
|
34
|
+
| `input` | references only: the invocation, and the application's small payload. Never a host path. |
|
|
35
|
+
| `authority` | `{ requestedBy, runAs, onBehalfOf, checked, delegation }`: computed by the control plane before placement, see below |
|
|
36
|
+
| `requirements` | `{ needs, deadlineMs, memoryMb?, concurrency? }`: what the work needs |
|
|
37
|
+
| `placement` | `{ allow?, deny?, prefer? }`: where it may and may not run. Constraints and a preference, never permission. |
|
|
38
|
+
|
|
39
|
+
**The result and evidence** are recorded per attempt (`AttemptRecord`):
|
|
40
|
+
|
|
41
|
+
- the environment and worker that claimed it (`{ id, via, run }`);
|
|
42
|
+
- its outcome:
|
|
43
|
+
- `running`, `succeeded`, `failed`, `awaiting_approval`, `cancelled`;
|
|
44
|
+
- `unknown`, for an attempt that lost its claim without reporting, or reported an ambiguous external
|
|
45
|
+
outcome;
|
|
46
|
+
- its error, and a result reference (at most 4 KB);
|
|
47
|
+
- bounded evidence events: `claimed`, `progress`, `succeeded`, `failed`, `awaiting_approval`,
|
|
48
|
+
`cancelled`, `abandoned`.
|
|
49
|
+
|
|
50
|
+
## The adapter boundary
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
interface ExecutionAdapter {
|
|
54
|
+
readonly environment: EnvironmentDescriptor; // id, kind, version, provides, limits, cancellation, available
|
|
55
|
+
dispatch(request: ExecutionRequest, staging: { effects: AfterCommit }): { outboxId: string; job: string };
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Dispatch** stages exactly one after-commit effect in the caller's transaction.
|
|
60
|
+
|
|
61
|
+
- There is **one outbox**. Every environment is reached through it, so dispatch is durable,
|
|
62
|
+
performed once and recovered for every environment alike.
|
|
63
|
+
- Recovery's dispatch logic (pending, done or failed; re-dispatch) works on that outbox record and
|
|
64
|
+
is not adapter-specific.
|
|
65
|
+
|
|
66
|
+
**Reporting** goes through the control plane's fenced operations, whatever the environment:
|
|
67
|
+
|
|
68
|
+
- `ctx.invocations.start(id, { environment?, worker? })` opens an attempt. A claimant from an
|
|
69
|
+
environment other than the one the execution was placed in is refused (`WRONG_ENVIRONMENT`).
|
|
70
|
+
- `progress(id, { claim, note?, data? })` records evidence and renews the lease (a heartbeat).
|
|
71
|
+
- `transition(id, completed | failed | awaiting_approval, { claim, … })` closes the attempt.
|
|
72
|
+
- `cancel(id)` is the person's own. It is cooperative today: the work sees it at its next report.
|
|
73
|
+
|
|
74
|
+
**The adapter in use: `managed`.** It is exactly the path FeltKit already had, behind the interface:
|
|
75
|
+
|
|
76
|
+
1. The outbox enqueues an AppPort Services job.
|
|
77
|
+
2. The services worker runs the declared handler, as the principal the work runs as.
|
|
78
|
+
3. The handler reports through `ctx.invocations`.
|
|
79
|
+
|
|
80
|
+
Its descriptor: `kind: "managed"`, it provides `feltkit.function` and `appport.services`, its deadline
|
|
81
|
+
limit is 15 minutes, and it states no memory or concurrency limit (it can't promise one).
|
|
82
|
+
|
|
83
|
+
## Placement
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
runtime.execution.register(adapter); // an environment becomes placeable (grants nothing)
|
|
87
|
+
runtime.execution.policy = { id, version, order: ["managed", …] }; // the operator's: allowed, in preference order
|
|
88
|
+
runtime.execution.resolver = resolvePlacement; // replaceable; deterministic; returns no authority
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The default resolver (`resolvePlacement`) evaluates every registered environment against:
|
|
92
|
+
|
|
93
|
+
- **the policy:** not in `order` means not allowed;
|
|
94
|
+
- **the work's constraints:** `allow`, `deny` (by id or kind);
|
|
95
|
+
- **its requirements:** `needs`, the deadline, and memory and concurrency (an environment that can't
|
|
96
|
+
promise a limit can't take work that needs one);
|
|
97
|
+
- **availability.**
|
|
98
|
+
|
|
99
|
+
Then it decides:
|
|
100
|
+
|
|
101
|
+
- The eligible environments are ordered by the policy.
|
|
102
|
+
- An eligible `prefer` is selected. An ineligible one is explained, not obeyed.
|
|
103
|
+
- Otherwise the first eligible environment is selected.
|
|
104
|
+
- If nothing is eligible, the result is `UNPLACEABLE`, with every reason.
|
|
105
|
+
|
|
106
|
+
The same inputs, in any order, give the same decision.
|
|
107
|
+
|
|
108
|
+
In application code, constraints are optional on `accept`, and most applications pass none:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
await ctx.invocations.accept({ surface: "share", envelope, dispatch: { job: "work.run", requirements: { deadlineMs: 120_000 }, placement: { deny: ["device"] } } });
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Unplaceable work is refused at accept** (`FAILED_PRECONDITION`, `details.reason: "UNPLACEABLE"`,
|
|
115
|
+
`details.decision`). Nothing is recorded or dispatched.
|
|
116
|
+
|
|
117
|
+
## Authority is independent of placement
|
|
118
|
+
|
|
119
|
+
1. **At accept, before placement.** The work runs as the accepting principal, which must hold its
|
|
120
|
+
function's `access`. If it doesn't, the work is `FORBIDDEN`, and nothing is placed or dispatched.
|
|
121
|
+
The record keeps three things apart, so none is mistaken for another:
|
|
122
|
+
- `requestedBy`: who asked;
|
|
123
|
+
- `runAs`: who the work executes as;
|
|
124
|
+
- `checked`: `[{ permission, source: "roles" }]`, what was verified. That is the requester's
|
|
125
|
+
permission to *start* the work under the application's roles. It is **not** an agent's
|
|
126
|
+
delegated authority over the person's resources: `delegation: "decided-at-execution"`.
|
|
127
|
+
2. **The resolver takes no authority and returns none.** A preference, a "trusted" environment, or an
|
|
128
|
+
environment that "provides" anything never adds to it.
|
|
129
|
+
3. **At execution, as before.** The handler runs as that principal (`runtime.call` authorizes the
|
|
130
|
+
function again). Delegated decisions on a person's behalf are AuthBoundry's, asked by the work when
|
|
131
|
+
it runs (`ctx.authority.decide`).
|
|
132
|
+
|
|
133
|
+
## Durable placement evidence
|
|
134
|
+
|
|
135
|
+
Each execution is stored on the invocation's record (`executions[]`):
|
|
136
|
+
|
|
137
|
+
- the request;
|
|
138
|
+
- **the placement decision** (`feltkit.placement/1`): the policy as applied (id, version **and
|
|
139
|
+
order**), every environment **as described at the time** (`environments`), the requirements and
|
|
140
|
+
constraints, every evaluation with its reasons, the eligible ones, the selected one, why, and when.
|
|
141
|
+
A later change to the live, process-local policy or to an environment's description can't make an
|
|
142
|
+
old decision unexplainable;
|
|
143
|
+
- its own dispatch evidence (`dispatch { job, outboxIds }`, re-dispatches included), so a later
|
|
144
|
+
execution can't rewrite it;
|
|
145
|
+
- the adapter and version;
|
|
146
|
+
- the dispatch time;
|
|
147
|
+
- its attempts.
|
|
148
|
+
|
|
149
|
+
The dispatch it caused is its own outbox record. All of it is written with the record's
|
|
150
|
+
compare-and-set, survives restarts, and is reviewable without any worker. No credential, secret or
|
|
151
|
+
claim token is in it: the claim token is never returned, and Studio redacts it.
|
|
152
|
+
|
|
153
|
+
## Who executed, under what authority (M1)
|
|
154
|
+
|
|
155
|
+
Each attempt records the decisions made while it ran, and what they established. These fields are
|
|
156
|
+
from FeltKit `runtime/invocations.ts`, filled by `ctx.authority.decide`:
|
|
157
|
+
|
|
158
|
+
- **`decisions[]`.** Each AuthBoundry decision made while the attempt ran, as it was answered:
|
|
159
|
+
capability, on whose behalf, outcome, `decisionId`, `delegationId`, and the executor's proof.
|
|
160
|
+
- They are recorded when made, before the decision is returned, attributed by the request that
|
|
161
|
+
claimed the attempt.
|
|
162
|
+
- They are never reconstructed later from current permissions or delegations. A revocation changes
|
|
163
|
+
the next decision, not the recorded ones.
|
|
164
|
+
- **`executor`.**
|
|
165
|
+
- `proven` (`method: "agent_credential"`) only when **every** decision of the attempt was answered
|
|
166
|
+
with AuthBoundry's proof (A2), naming this executor.
|
|
167
|
+
- Otherwise `asserted`.
|
|
168
|
+
- The `agentCredentialId` is an identifier; the proof is that AuthBoundry authenticated the
|
|
169
|
+
credential for those decisions.
|
|
170
|
+
- **`attribution: { environment: "asserted", worker: "asserted" }`.** An authenticated agent identity
|
|
171
|
+
doesn't prove which computer ran the work. The environment and worker stay asserted until remote
|
|
172
|
+
workers authenticate (M4).
|
|
173
|
+
|
|
174
|
+
**How FeltKit reads the proof** (`executorProofOf`, `runtime/authboundry.ts`). It is proven only if
|
|
175
|
+
FeltKit sent an agent credential **and** the answer says `proven: true` by `agent_credential` for
|
|
176
|
+
exactly this executor, with a credential id. Anything else is `asserted`, including an AuthBoundry
|
|
177
|
+
without A2.
|
|
178
|
+
|
|
179
|
+
**Where the credential comes from.**
|
|
180
|
+
|
|
181
|
+
- `authority.executor.credential` (a custody reference); or
|
|
182
|
+
- with `authority.local`, the executor's own credential. `@authboundry/local` issues it, and FeltKit
|
|
183
|
+
keeps it in custody (`credential-ref:authboundry-local-agent`), stores each renewal, and sends it on
|
|
184
|
+
every decision. The private authority sets `agent_required`, so the executor can no longer be merely
|
|
185
|
+
asserted there.
|
|
186
|
+
|
|
187
|
+
**No secret in records.** Records hold ids only; the secret never leaves custody.
|
|
188
|
+
|
|
189
|
+
**The six distinctions, from one record:**
|
|
190
|
+
|
|
191
|
+
| Distinction | Field |
|
|
192
|
+
|---|---|
|
|
193
|
+
| Who requested | `executions[].request.authority.requestedBy` |
|
|
194
|
+
| For whom | `…authority.onBehalfOf`, and each decision's `onBehalfOf` |
|
|
195
|
+
| Which agent executed | `attempts[].executor` (proven or asserted) |
|
|
196
|
+
| Which authority permitted it | `attempts[].decisions[]` (`decisionId`, `delegationId`) |
|
|
197
|
+
| Which environment ran it | `attempts[].environment` (asserted) |
|
|
198
|
+
| What happened | `attempts[].outcome`, its result or error, and the invocation's outcome |
|
|
199
|
+
|
|
200
|
+
## Safety
|
|
201
|
+
|
|
202
|
+
- **Workers are disposable.** A worker that disappears leaves a `running` attempt. After its lease
|
|
203
|
+
expires, recovery reports it as `stalled`, and the next `start` reclaims it under the same invocation
|
|
204
|
+
and execution, as a new attempt.
|
|
205
|
+
- **Fencing.** Only the attempt holding the current claim can report or move the invocation. A stale
|
|
206
|
+
worker gets `CLAIM_LOST`.
|
|
207
|
+
- **External effects are not exactly-once.**
|
|
208
|
+
- The outbox recovers dispatch, and the managed adapter's job runs replay a committed attempt, but
|
|
209
|
+
an external side effect can still be ambiguous.
|
|
210
|
+
- An abandoned attempt reads `unknown`, and the next attempt receives `previous` so it can reconcile
|
|
211
|
+
before repeating an effect. FeltKit's integration calls already record unknown outcomes and verify
|
|
212
|
+
them rather than resend.
|
|
213
|
+
- A worker reports an ambiguous outcome as `failed` with `OUTCOME_UNKNOWN`: the attempt reads
|
|
214
|
+
`unknown` and the invocation never reads `completed`.
|
|
215
|
+
|
|
216
|
+
## Status
|
|
217
|
+
|
|
218
|
+
**Implemented and tested** (`packages/sdk/test/execution.test.ts`, 9 tests; plus `invocations.test.ts`
|
|
219
|
+
and `surfaces.test.ts`):
|
|
220
|
+
|
|
221
|
+
- the contract;
|
|
222
|
+
- the adapter boundary, with the managed adapter;
|
|
223
|
+
- deterministic placement, with structured rejection;
|
|
224
|
+
- authority checked before and independently of placement;
|
|
225
|
+
- durable decisions across a restart;
|
|
226
|
+
- attempts with environment and worker;
|
|
227
|
+
- fencing;
|
|
228
|
+
- recovery by a replacement worker under the same identity;
|
|
229
|
+
- `unknown` for abandoned attempts and ambiguous outcomes;
|
|
230
|
+
- no infrastructure details in the contract;
|
|
231
|
+
- an unrelated application with no placement code.
|
|
232
|
+
|
|
233
|
+
**Implemented, but not under production conditions:**
|
|
234
|
+
|
|
235
|
+
- A second environment exists only as a **controlled fixture** (`fixture-remote`): an in-process job
|
|
236
|
+
standing in for a worker elsewhere. It proves the contract and the control plane's behavior, not
|
|
237
|
+
remote execution.
|
|
238
|
+
- The managed adapter has run only in tests and development.
|
|
239
|
+
|
|
240
|
+
**Designed, not implemented:**
|
|
241
|
+
|
|
242
|
+
- a remote worker protocol (how a worker outside the process authenticates and calls the control
|
|
243
|
+
plane);
|
|
244
|
+
- re-placement: a new execution when the selected environment becomes unavailable (today re-dispatch
|
|
245
|
+
keeps the original placement);
|
|
246
|
+
- preemptive cancellation;
|
|
247
|
+
- versioned operations (`work.version` is `"1"`);
|
|
248
|
+
- environment health beyond the `available` flag.
|
|
249
|
+
|
|
250
|
+
**Blocked:**
|
|
251
|
+
|
|
252
|
+
- AppBoundry artifacts don't host the invocation store, so an artifact can't be the control plane.
|
|
253
|
+
- **Corrected 2026-11-14:** an earlier version said AuthBoundry had no agent-credential proof. It has
|
|
254
|
+
one. `authorize/check` accepts `x-authboundry-agent-credential` (AB
|
|
255
|
+
crates/server/src/agent_credentials.rs), and FeltKit sends it when `authority.executor.credential` is
|
|
256
|
+
set. What remains is narrower:
|
|
257
|
+
- a worker can't call alone (the application's check credential must come with it);
|
|
258
|
+
- `on_behalf_of` with an agent credential is untested;
|
|
259
|
+
- the response doesn't say whether the executor was proven.
|
|
260
|
+
|
|
261
|
+
See docs/AGENT-CAPABILITY-INFRASTRUCTURE.md §5.
|
|
262
|
+
|
|
263
|
+
## Limits
|
|
264
|
+
|
|
265
|
+
- One execution per invocation.
|
|
266
|
+
- A re-dispatch reuses the original placement even if policy changed.
|
|
267
|
+
- Policy and environments are per process (`runtime.execution`), not stored. Each decision snapshots
|
|
268
|
+
the policy order and the environment descriptors it used, so it explains itself; the live policy
|
|
269
|
+
has no history of its own.
|
|
270
|
+
- An attempt's environment and worker are asserted by its (authenticated) principal. Proving the
|
|
271
|
+
executor per attempt needs an agent credential (docs/AGENT-CAPABILITY-INFRASTRUCTURE.md §5, A1-A2).
|
package/docs/GUARANTEES.md
CHANGED
|
@@ -69,6 +69,7 @@ this inside its commit lock; a failed check rejects the whole transaction with
|
|
|
69
69
|
| `get(id)` | `ifVersion` / `requireAbsent` precondition on that record | The record changed, appeared, or was deleted |
|
|
70
70
|
| `find(filter)`, `count(filter)` with at least one field | FeltDB read basis on the equality predicate, captured before the read | Any matching record changed, appeared (phantom), disappeared, or stopped matching — by any writer |
|
|
71
71
|
| `query({ where })` with some `eq` clauses | Read basis on the `eq` clauses only (range clauses dropped) | Same as above, for a superset of the read: may report conflicts the range would have excluded, never misses one |
|
|
72
|
+
| `query({ where })` with an `in` clause (non-empty) | One read basis per distinct value: that value as an equality, with the read's `eq` clauses (a second `in` is dropped) | Any record whose field is in the set changed, appeared or disappeared; a write outside the set does not conflict. An empty `in` is checked as a read without it |
|
|
72
73
|
| `find()`/`count()` with no filter, or `query` with only range clauses | The collection's change marker (`_feltkit_collections`), touched by every commit made through `ctx.db` or the dashboard | Any commit to the collection through FeltKit. **Not** writes made through `ctx.unsafe.feltdb`. |
|
|
73
74
|
| Records the mutation wrote | `ifVersion` on updates and deletes, at the version the mutation **first read** (a `get` before the `patch`); `requireAbsent` on inserts | Lost updates, including a change committed between the handler's read and its write |
|
|
74
75
|
|
|
@@ -155,7 +156,7 @@ writes the new one in the mutation's transaction, conditioned on the version it
|
|
|
155
156
|
- File bytes are stored in the same FeltDB instance (`_feltkit_file_content`, with
|
|
156
157
|
their SHA-256, re-hashed on every read) before the file record is committed, so a
|
|
157
158
|
record never points at bytes that were not stored; if the record cannot be committed
|
|
158
|
-
the bytes are removed. Deleting a file removes its bytes. FeltDB 0.15's content store
|
|
159
|
+
the bytes are removed. Deleting a file removes its bytes and the image variants derived from them. FeltDB 0.15's content store
|
|
159
160
|
is not used: it cannot delete content, and the memory runtime has none (UPSTREAM-GAPS
|
|
160
161
|
F6, F8, F9).
|
|
161
162
|
- Files are capped at 1 MiB by default (`services.files.maxBytes`).
|
|
@@ -225,7 +226,10 @@ published contract declares (`appport.integration/1` `failures`). Tests:
|
|
|
225
226
|
write. A watched query re-runs when a change's keys meet its predicates, when a
|
|
226
227
|
collection it read wholly changed, or when a change has no keys for a collection it
|
|
227
228
|
read. So inserts, updates (including a record moving out of a predicate) and deletes
|
|
228
|
-
re-run exactly the predicates they touch, and never fewer.
|
|
229
|
+
re-run exactly the predicates they touch, and never fewer. A set membership (`in`) on a
|
|
230
|
+
keyed field is one predicate per value (preferred after an equality on `id` or another
|
|
231
|
+
keyed field, before the tenant field), so a change to a record in the set re-runs the
|
|
232
|
+
query and one outside it does not.
|
|
229
233
|
- **Keyed fields** are `id`, the fields of declared indexes and unique constraints,
|
|
230
234
|
references (`s.ref`) and the tenant field. A read filtering only on other fields counts
|
|
231
235
|
as a whole-collection read. Values of other fields never leave the server in any form.
|
|
@@ -252,6 +256,17 @@ published contract declares (`appport.integration/1` `failures`). Tests:
|
|
|
252
256
|
- Queries cannot write through `ctx.db`. FeltKit does not sandbox handlers, so a query
|
|
253
257
|
can still make network calls or other side effects; FeltKit does not claim purity.
|
|
254
258
|
- `count` reads all matching records.
|
|
259
|
+
- **Set membership** (`where: [{ field, in: [...] }]`, FRAME-GAP-05): at most 256 strings, finite numbers,
|
|
260
|
+
booleans or nulls, with `eq`'s equality; an empty list matches nothing; checked before FeltDB sees it
|
|
261
|
+
(`INVALID_ARGUMENT`). A FeltDB without `in` (0.21.0 and before) is `FAILED_PRECONDITION`, never a wrong
|
|
262
|
+
answer. A cursor continues only the same set. Inside a mutation, pending writes are matched too.
|
|
263
|
+
- **Index directions** (`indexes: [{ fields, directions }]`): FeltDB's state contract declares index fields
|
|
264
|
+
only (ascending), so FeltKit also declares an index with a `desc` direction to an embedded FeltDB (local,
|
|
265
|
+
memory) as `<name>_ordered`, at start and reload (idempotent; durable across restarts). With
|
|
266
|
+
`{ fields: ["authorId", "createdAt"], directions: ["asc", "desc"] }`, `where authorId in [...] orderBy
|
|
267
|
+
createdAt desc` is an index merge: a page examines about `limit + 1` records, whatever the authors have
|
|
268
|
+
written (`test/membership-query.test.ts`, by `explain` and `plan.recordsExamined`). A FeltDB server serves
|
|
269
|
+
`in` as a predicate (same results; cost as an unindexed predicate).
|
|
255
270
|
- `search` reads the records matching its equality `where` in pages, in the requested
|
|
256
271
|
order, until `limit` (≤ 100) match: cost is linear in the records matching `where`, not
|
|
257
272
|
in the result. It examines at most 50,000 records and then fails with
|
|
@@ -286,6 +301,28 @@ the interface); on AppBoundry's side, the appboundry-host crypto tests in `rkend
|
|
|
286
301
|
| 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 |
|
|
287
302
|
| Evidence | Denials and allows are recorded in the activity entry's `authority.resource`, beside the role decision and its id | same |
|
|
288
303
|
|
|
304
|
+
### Ownership declared on the function (`owner`)
|
|
305
|
+
|
|
306
|
+
A per-record rule in the hook is keyed by the function's name, so a renamed or moved function
|
|
307
|
+
silently falls out of it (FRAME-GAP-04: Frame's `comments:remove` rule never applied to
|
|
308
|
+
`social:uncomment`, and any member could delete any comment). Declare ownership on the function:
|
|
309
|
+
`owner: { collection, id, field, via? }` (`via: { collection, field }` when `field` is
|
|
310
|
+
`s.ref(via.collection)` and that record's `field` is the principal). The rule is part of the
|
|
311
|
+
function's definition, so it moves with it.
|
|
312
|
+
|
|
313
|
+
| Guarantee | How | Test |
|
|
314
|
+
|---|---|---|
|
|
315
|
+
| Checked when declared | An object that is not this app's collection, an unknown field, an `id` that is not a declared argument, a `via` field that is not `s.ref(via.collection)`, an action, a `public` function, or an unknown member: a `TypeError` when the function is declared. Unknown function options are refused too (a misspelled `ownr` or `aproval` never leaves a function unprotected) | `test/ownership.test.ts` |
|
|
316
|
+
| Every interface, one decision | The same boundary as the hook (`/api`, AppPort, MCP, agent actions, jobs, the AppBoundry guest), after roles and argument validation, before the hook and the handler | same (HTTP AppPort; artifact parity) |
|
|
317
|
+
| Fail closed | No caller `UNAUTHORIZED`; no record `NOT_FOUND`; no owner recorded, a `via` record naming none, or another owner `FORBIDDEN` | same |
|
|
318
|
+
| Decision and effect agree | Read with the call's own reader: tenant-scoped, fenced at commit, tracked live | as the hook |
|
|
319
|
+
| Approval grants no ownership | An approved proposal runs as its proposer, who must own the record | same |
|
|
320
|
+
| Evidence | `authority.resource` on the activity entry, allowed or denied, with the reason | same |
|
|
321
|
+
|
|
322
|
+
The hook still runs after ownership and now receives `definition`, the function itself:
|
|
323
|
+
compare `definition === posts.remove`, not `function === "posts:remove"`, so a rename breaks the
|
|
324
|
+
import instead of the rule.
|
|
325
|
+
|
|
289
326
|
Not covered: the hook does not run for AppPort Services effects made directly by services
|
|
290
327
|
(those are authorized by the role policy and the services' own ownership rules), and FeltKit
|
|
291
328
|
does not evaluate resources with AuthBoundry (UPSTREAM-GAPS).
|
|
@@ -301,8 +338,8 @@ no completion is reported as outcome unknown, never as success or failure. Enabl
|
|
|
301
338
|
|
|
302
339
|
| Service | What runs | Verified (packages/sdk/test) |
|
|
303
340
|
|---|---|---|
|
|
304
|
-
| Files | records with audit; bytes in the same instance | persistence, authorization, upload/read/delete, restart (`services`) |
|
|
305
|
-
| Notifications | in-app channel, delivered inline; recipient-only | persistence, delivery, recipient-only access, restart (`services`) |
|
|
341
|
+
| Files | records with audit; bytes in the same instance; links (cacheable on request), image variants | persistence, authorization, upload/read/delete, restart (`services`); links (`file-links`); cacheable links and variants (`file-cache-variants`) |
|
|
342
|
+
| Notifications | in-app channel, delivered inline; recipient-only; inbox paging (`page`, `unreadCount`, `markAllRead`) on the recipient timeline index | persistence, delivery, recipient-only access, restart (`services`); paging, cursors bound to the walk, counts, mark-all-read as the caller, the contract's indexes (`notification-paging`) |
|
|
306
343
|
| Configuration | variables and credential references for the running environment | persistence, environment separation; the console page edits the environment the application reads (`services`, `console`) |
|
|
307
344
|
| API keys | created, rotated, revoked on the package's page; accepted on `/appport` and `/mcp` with `services.apiKeys.roles` | secret shown once, never listed, revocation → 401, survives restart (`console`) |
|
|
308
345
|
| Webhooks | signed delivery to registered endpoints; history | signed with the environment's secret, delivered as the emitter, secret in no record or log (`console`) |
|
|
@@ -327,14 +364,102 @@ no completion is reported as outcome unknown, never as success or failure. Enabl
|
|
|
327
364
|
- FeltKit is single-tenant per application: the Services tenant is the application
|
|
328
365
|
name. Configuration environments map `development`/`test` → `development`,
|
|
329
366
|
`production` → `production`.
|
|
330
|
-
-
|
|
331
|
-
`
|
|
367
|
+
- **Notification inbox** (`ctx.services.notifications.page / unreadCount / markAllRead`, FRAME-GAP-08):
|
|
368
|
+
AppPort Services' `inbox`, `unreadCount` and `markAllRead`, as the caller, for the caller's own
|
|
369
|
+
notifications. Pages are newest first (`createdAt` desc, `id` asc) from the
|
|
370
|
+
`notifications_by_recipient(_type)` indexes (in FeltKit's contract with Services' contract version 4):
|
|
371
|
+
a page reads about `limit` records. A cursor works only for the walk that issued it. With `unread` a page
|
|
372
|
+
may be short or empty and still carry `nextCursor`. `unreadCount` stops at `max` (`complete: false`).
|
|
373
|
+
`markAllRead` marks at most 1,000 per call, each as `markRead` does, and is not atomic. A Services
|
|
374
|
+
release without them: `FAILED_PRECONDITION` naming it. Artifacts: `UNAVAILABLE`.
|
|
375
|
+
- Files belong to the workspace they were uploaded in (`metadata["feltkit.tenant"]`, set by
|
|
376
|
+
FeltKit): a caller with `files.read` reads the files of its own workspace, or, working in none,
|
|
377
|
+
those uploaded in none; any other is NOT_FOUND. Per-resource access is the application's: a function checks the resource
|
|
332
378
|
and issues a **file link** (`files.link`, `files.uploadLink`), and the link is the authority for
|
|
333
379
|
that one transfer. Download links last 5 minutes by default (at most 1 hour) and may be reused
|
|
334
380
|
until then. Upload links are single use, create the file as the issuing principal (the role
|
|
335
381
|
snapshot taken at issue), with the metadata the function fixed, and within its `maxBytes`. Only
|
|
336
382
|
the SHA-256 of a link token is stored (`_feltkit_file_links` on the `feltkit.files` handle).
|
|
337
|
-
Links are not revoked when membership changes; they expire.
|
|
383
|
+
Links are not revoked when membership changes; they expire. A link serves only the content it was
|
|
384
|
+
issued for: if the record comes to name other bytes (another checksum), the link is refused.
|
|
385
|
+
- **Cacheable file links** (`files.link(id, { cache: true })`, opt-in; FRAME-GAP-01). By default a
|
|
386
|
+
download is `Cache-Control: private, no-store` and every call is a new URL. With `cache`:
|
|
387
|
+
- **Same URL in a window.** Time is cut into windows of half the link's lifetime
|
|
388
|
+
(`expiresInSeconds`, default 3600 with `cache`, at most 3600). Within one window, the same caller
|
|
389
|
+
(principal and workspace) asking for the same file, content (checksum and storage key), variant and
|
|
390
|
+
disposition gets the same URL; `stableUntil` says when the next call will be a new one. Each URL
|
|
391
|
+
lives until the end of the following window, so it is issued with at least half its lifetime left
|
|
392
|
+
and never lives longer than asked (`expiresAt`).
|
|
393
|
+
- **No cross-principal reuse.** The token is HMAC-SHA256, under a random per-process key that is never
|
|
394
|
+
stored, of that scope; another principal (or the same person in another workspace) gets another URL.
|
|
395
|
+
Nothing a URL contains is derived from the bytes alone, so identical bytes in two workspaces never
|
|
396
|
+
share an address. Only the token's digest is stored, as for every link. A restart changes the key:
|
|
397
|
+
URLs issued after it are new (one more download each), never weaker.
|
|
398
|
+
- **Headers.** `Cache-Control: private, max-age=<seconds until expiresAt>, immutable` and a strong
|
|
399
|
+
`ETag` (the SHA-256 of the bytes served). `If-None-Match` answers `304` only after the link was
|
|
400
|
+
redeemed (valid, unexpired, the file still exists with the same content). `private`: never a
|
|
401
|
+
shared cache.
|
|
402
|
+
- **The tradeoff, bounded.** A copy a browser already holds is shown until its `max-age` runs out,
|
|
403
|
+
even if the file is removed or the caller loses access meanwhile: at most `expiresInSeconds`
|
|
404
|
+
(≤ 1 hour) after the link was issued. New downloads through the link stop at once (removed file,
|
|
405
|
+
changed content, expiry: `404`). Use the default (`no-store`) for content whose access must end
|
|
406
|
+
the moment it is revoked, or a shorter `expiresInSeconds`.
|
|
407
|
+
- **Image variants** (`services.files.variants`, `files.link(id, { variant })`; FRAME-GAP-06).
|
|
408
|
+
- **Declared, fixed set.** `variants: { w640: { width: 640 }, avatar64: { width: 64, height: 64, fit:
|
|
409
|
+
"cover" } }`: `width`/`height` 1-4096, `fit` `inside` (default: fits the box) or `cover` (fills it,
|
|
410
|
+
centre-cropped), `format` `auto` (default: PNG when the result has transparency, else JPEG), `jpeg` or
|
|
411
|
+
`png`, `quality` 1-100 (JPEG, default 80). Checked when the application is declared. Never upscaled.
|
|
412
|
+
A link names a declared variant or is refused (`INVALID_ARGUMENT`).
|
|
413
|
+
- **Authorized exactly as the original.** A variant is reachable only through a link to its file, issued
|
|
414
|
+
by `files.link` after the same checks (`files.read`, the file's workspace, the application's own
|
|
415
|
+
check); it is never a file record of its own.
|
|
416
|
+
- **Derived once,** on the first download through a variant link (concurrent first downloads in a process
|
|
417
|
+
derive once), and kept as derived content in `_feltkit_file_variants`, keyed by the original's storage
|
|
418
|
+
key and the variant's name, with a digest of its spec and codec (a changed declaration derives it again)
|
|
419
|
+
and the SHA-256 of its bytes (verified on every read).
|
|
420
|
+
- **Removed with the original's bytes.** The recorded byte release of `files.remove` (above) removes every
|
|
421
|
+
variant of the bytes it releases (`{ released: true, variantsReleased }`), also when an earlier attempt
|
|
422
|
+
already removed the bytes; a variant derived while its bytes were being released is removed by the
|
|
423
|
+
derivation itself.
|
|
424
|
+
- **Never silent.** JPEG (EXIF orientation applied) and PNG are resized. Any other format, an image over
|
|
425
|
+
`services.files.maxVariantPixels` (default 24,000,000, checked from the header before decoding),
|
|
426
|
+
bytes that do not decode, or an image already within the variant are served as the original:
|
|
427
|
+
`X-FeltKit-Variant: original` and `X-FeltKit-Variant-Reason: …` on the download, and the link's
|
|
428
|
+
`variant: { status: "original", reason }` once known (`pending` before the first download, `ready`
|
|
429
|
+
with `width`, `height`, `contentType` after). A served variant is `X-FeltKit-Variant: <name>`.
|
|
430
|
+
- **Costs.** Codecs are pure JavaScript (`jpeg-js`, `pngjs`): the first download of each file and
|
|
431
|
+
variant decodes on the server's event loop (roughly 50-150 ms per megapixel).
|
|
432
|
+
- **AppBoundry artifacts:** `files.link` (variants and cacheable links included) is refused
|
|
433
|
+
(`UNAVAILABLE`), as before; `feltkit build --target appboundry` warns that variants are not served.
|
|
434
|
+
- **Removing a file does not strand its bytes, and does not release bytes another live file uses,**
|
|
435
|
+
except in one documented window (below: a reference made the instant after the removal, and a
|
|
436
|
+
stop before the bytes are put back), which is recorded, not hidden. A file is
|
|
437
|
+
Services' metadata record and FeltKit's bytes, in separate commits. `files.remove`:
|
|
438
|
+
1. records the release of the bytes in the outbox (`_feltkit_outbox`, effect `files.release`)
|
|
439
|
+
before anything is deleted;
|
|
440
|
+
2. soft-deletes the metadata as the caller (Services authorizes `files.delete` and audits it);
|
|
441
|
+
refused or failed, the release is settled `failed` and the bytes are kept;
|
|
442
|
+
3. releases the bytes once the record is gone and no other live record names the same storage
|
|
443
|
+
key (one that does keeps them: `{ released: false, retained: true, referencedBy }`). "No other
|
|
444
|
+
live record" is AppPort Services' answer (`FileService.references`: a bounded lookup on the
|
|
445
|
+
`files_by_storage_key` index, at any number of files); an incomplete or failed answer releases
|
|
446
|
+
nothing. After removing the bytes it asks again, and puts them back if a record was made to name
|
|
447
|
+
them meanwhile (Services' management API takes any `storageKey`): `{ …, raced: true }`.
|
|
448
|
+
|
|
449
|
+
A stop between the steps leaves a pending release that the outbox's recovery performs after a
|
|
450
|
+
restart. A failed release does not undo the removal. A transient failure is retried by the
|
|
451
|
+
outbox's recovery with backoff (at most 5 attempts); a refusal, an unestablished answer or a live
|
|
452
|
+
file is `failed`, with its error, for `feltkit outbox retry`.
|
|
453
|
+
|
|
454
|
+
Not atomic, and said so: the lookup and the byte removal are separate commits in separate
|
|
455
|
+
products. The one remaining window is a record made to name the bytes between their removal and
|
|
456
|
+
the second lookup *and* a stop before they are put back; the next attempt then records it
|
|
457
|
+
(`{ retained: true, referencedBy, bytesMissing: true }`) instead of hiding it. A Services without
|
|
458
|
+
`FileService.references` releases nothing (`FAILED_PRECONDITION`, bytes kept). Releases are idempotent (bytes already gone are `{ released: false }`) and
|
|
459
|
+
read as FeltKit's `file-release` principal (`files.read` only), never with the caller's authority.
|
|
460
|
+
Bytes no live record references (from before this, from Services' management API, which deletes
|
|
461
|
+
metadata only, or from an interrupted upload) are listed and reclaimed, as recorded releases, by
|
|
462
|
+
`feltkit outbox reclaim-files [--release]`; bytes stored in the last hour are excluded.
|
|
338
463
|
|
|
339
464
|
## Accounts, sessions and workspaces
|
|
340
465
|
|
|
@@ -562,7 +687,8 @@ across environments. Nothing is copied from development.
|
|
|
562
687
|
|
|
563
688
|
| Primitive | Guarantee | Verified by |
|
|
564
689
|
|---|---|---|
|
|
565
|
-
| `ctx.authority.decide({ capability, onBehalfOf?, resource?, context? })` | AuthBoundry through the same `authBoundryAuthority` the platform uses. The asking principal is always `feltkit({ authority }).executor`; `onBehalfOf` names the requester, and an allow for it must echo that requester and a `delegation_id`. Fails closed (unconfigured, unreachable, slow, malformed, inexact, missing credential). Credentials are custody references resolved per decision; each decision is in the activity log with its ids, never a credential | `test/application-platform.test.ts` |
|
|
690
|
+
| `ctx.authority.decide({ capability, onBehalfOf?, agent?, resource?, context? })` | AuthBoundry through the same `authBoundryAuthority` the platform uses. The asking principal is always `feltkit({ authority }).executor`; `onBehalfOf` names the requester, and an allow for it must echo that requester and a `delegation_id`. `onBehalfOf` is mapped as `ctx.authority.grants` maps the delegator (FRAME-GAP-11): an application principal id (no `:`, e.g. `"ada"`) goes through `authority.principal` (default `user:<id>`); an AuthBoundry principal (`<type>:<id>`, e.g. `"user:ada"`) is sent unchanged; `{ person }` always maps and `{ principal }` never does, for ids that break that rule. The decision's `onBehalfOf` is the principal asked about. Fails closed (unconfigured, unreachable, slow, malformed, inexact, missing credential). Credentials are custody references resolved per decision; each decision is in the activity log with its ids, never a credential | `test/application-platform.test.ts`, `test/local-authority.test.ts` (both forms against a real local AuthBoundry) |
|
|
691
|
+
| Per-agent delegation (`authority.local`) | Every `app.agent` is an AuthBoundry agent of the application (`agent:<id>`), registered at each start with its own credential in custody; agents registered at run time (`ctx.authority.agents.register`, needs `feltkit.authority.agents`, never by an agent) are registered again too. A grant may name an agent (`grants.grant({ agent })`) and then allows only that agent. **An agent caller decides as itself, always**, with its own credential: a grant to another agent or to the executor never allows it, and naming another agent is a deny. Anyone else decides as the executor unless it names a registered agent. An unregistered agent is a deny. Revoking a grant stops that grant only; revoking an agent stops all of its grants. With a hosted AuthBoundry, agent callers decide as the executor (no per-agent credentials) | `test/local-authority.test.ts` (real local AuthBoundry) |
|
|
566
692
|
| `ctx.integrations.invoke(capability, input)` | A declared integration operation from application code, as the caller, under the operation's own `access`; the input is validated against the operation's declared schema before anything is sent (`INVALID_ARGUMENT`), as AppPort validates a capability call; its credential resolved for the request only; the call recorded before and after; never in results, records or errors; rotation applies to the next call; a removed credential fails the call | `test/application-platform.test.ts` |
|
|
567
693
|
| The agent's catalog (`ctx.agent.catalog()` in actions, `runtime.agent.tools(principal)`; `ctx.agent.tools()` is its allowed subset, shaped as model tools) | Every capability the application and its services offer, not a model's tool list: for each, whether this principal may use it (`allowed`, the policy's decision) and how (`invoke`); for an integration operation, its `integration`, its input schema, and `readiness` (not ready while the base URL or the credential's value is missing, with what to fix; never a value). Permission and readiness are separate answers | `test/application-platform.test.ts` |
|
|
568
694
|
| Integration exposure (`expose: false`, per operation or integration) | The operation is not an AppPort capability: no session can call it on `/appport`, whatever it holds; application code still can, under `access`. A `verify` probe must stay exposed (verification runs it through AppPort), checked when the app is defined | `test/application-platform.test.ts` |
|