@feltdb/feltkit 0.3.11 → 0.3.13
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/README.md +4 -3
- package/dist/app.d.ts +98 -3
- package/dist/app.js +63 -0
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.d.ts +39 -1
- package/dist/appboundry/build.js +57 -6
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +46 -5
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/appboundry/host.d.ts +24 -5
- package/dist/appboundry/host.js +234 -141
- package/dist/appboundry/host.js.map +1 -1
- package/dist/appboundry/runtime.d.ts +44 -0
- package/dist/appboundry/runtime.js +99 -0
- package/dist/appboundry/runtime.js.map +1 -0
- package/dist/cli/entry.d.ts +1 -0
- package/dist/cli/entry.js +4 -0
- package/dist/cli/entry.js.map +1 -0
- package/dist/cli/main.d.ts +5 -0
- package/dist/cli/main.js +550 -13
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/test-reporter.d.ts +9 -0
- package/dist/cli/test-reporter.js +26 -0
- package/dist/cli/test-reporter.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -1
- package/dist/dashboard/assets/index-BSnW2DC-.js +15 -0
- package/dist/dashboard/assets/{index-91I1zDK-.css → index-BXTNQAg1.css} +1 -1
- package/dist/dashboard/index.html +3 -3
- package/dist/docs.d.ts +12 -0
- package/dist/docs.js +42 -0
- package/dist/docs.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/platform/changes.d.ts +340 -0
- package/dist/platform/changes.js +355 -0
- package/dist/platform/changes.js.map +1 -0
- package/dist/platform/deployments.d.ts +653 -0
- package/dist/platform/deployments.js +532 -0
- package/dist/platform/deployments.js.map +1 -0
- package/dist/platform/operations.d.ts +74 -0
- package/dist/platform/operations.js +198 -0
- package/dist/platform/operations.js.map +1 -0
- package/dist/platform/platform.d.ts +78 -0
- package/dist/platform/platform.js +264 -0
- package/dist/platform/platform.js.map +1 -0
- package/dist/platform/server.d.ts +25 -0
- package/dist/platform/server.js +165 -0
- package/dist/platform/server.js.map +1 -0
- package/dist/platform/source.d.ts +27 -0
- package/dist/platform/source.js +142 -0
- package/dist/platform/source.js.map +1 -0
- package/dist/runtime/activity.d.ts +25 -0
- package/dist/runtime/activity.js +38 -12
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/agent.d.ts +16 -0
- package/dist/runtime/agent.js +92 -28
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/backup-environment.d.ts +32 -0
- package/dist/runtime/backup-environment.js +92 -0
- package/dist/runtime/backup-environment.js.map +1 -0
- package/dist/runtime/backup.d.ts +129 -0
- package/dist/runtime/backup.js +344 -0
- package/dist/runtime/backup.js.map +1 -0
- package/dist/runtime/capabilities.js +4 -2
- package/dist/runtime/capabilities.js.map +1 -1
- package/dist/runtime/changes.js +2 -2
- package/dist/runtime/changes.js.map +1 -1
- package/dist/runtime/contract.js +4 -3
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/data.d.ts +36 -5
- package/dist/runtime/data.js +165 -55
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/decisions.js +2 -1
- package/dist/runtime/decisions.js.map +1 -1
- package/dist/runtime/instance.js +17 -0
- package/dist/runtime/instance.js.map +1 -1
- package/dist/runtime/integrations.js +14 -6
- package/dist/runtime/integrations.js.map +1 -1
- package/dist/runtime/loader.js +28 -4
- package/dist/runtime/loader.js.map +1 -1
- package/dist/runtime/migration-context.d.ts +25 -0
- package/dist/runtime/migration-context.js +69 -0
- package/dist/runtime/migration-context.js.map +1 -0
- package/dist/runtime/outbox.d.ts +6 -82
- package/dist/runtime/outbox.js +14 -59
- package/dist/runtime/outbox.js.map +1 -1
- package/dist/runtime/readiness.js +18 -1
- package/dist/runtime/readiness.js.map +1 -1
- package/dist/runtime/runtime.d.ts +84 -8
- package/dist/runtime/runtime.js +372 -131
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services.d.ts +41 -5
- package/dist/runtime/services.js +49 -4
- package/dist/runtime/services.js.map +1 -1
- package/dist/runtime/sessions.js +4 -3
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/state-contract.d.ts +167 -0
- package/dist/runtime/state-contract.js +438 -0
- package/dist/runtime/state-contract.js.map +1 -0
- package/dist/runtime/transactions.d.ts +199 -0
- package/dist/runtime/transactions.js +246 -0
- package/dist/runtime/transactions.js.map +1 -0
- package/dist/schema.d.ts +13 -1
- package/dist/schema.js +21 -2
- package/dist/schema.js.map +1 -1
- package/dist/server/admin.d.ts +3 -2
- package/dist/server/admin.js +62 -10
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.d.ts +6 -1
- package/dist/server/index.js +90 -9
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp.js +1 -1
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/project.d.ts +5 -0
- package/dist/server/project.js +13 -2
- package/dist/server/project.js.map +1 -1
- package/dist/testing/index.d.ts +10 -3
- package/dist/testing/index.js +33 -7
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-OPERATIONS.md +515 -0
- package/docs/APPBOUNDRY.md +240 -0
- package/docs/ARCHITECTURE.md +126 -0
- package/docs/BACKUP.md +115 -0
- package/docs/GUARANTEES.md +457 -0
- package/docs/PATH-TO-PRODUCTION.md +117 -0
- package/docs/README.md +15 -0
- package/docs/SECURITY.md +182 -0
- package/docs/TRANSACTIONS.md +216 -0
- package/docs/UPSTREAM-GAPS.md +270 -0
- package/docs/WHY-FELTKIT.md +64 -0
- package/docs/assets/feltkit-logo-dark.png +0 -0
- package/docs/assets/feltkit-logo.png +0 -0
- package/package.json +10 -8
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +3 -3
- package/skills/feltkit-agent/SKILL.md +9 -5
- package/skills/feltkit-build/SKILL.md +16 -4
- package/skills/feltkit-data/SKILL.md +20 -3
- package/skills/feltkit-services/SKILL.md +13 -7
- package/dist/dashboard/assets/index-BhFOquA7.js +0 -15
- package/dist/dashboard/theme.js +0 -11
package/dist/testing/index.js
CHANGED
|
@@ -9,7 +9,12 @@
|
|
|
9
9
|
* await t.close();
|
|
10
10
|
*
|
|
11
11
|
* Calls go through the same runtime path as HTTP requests: argument validation,
|
|
12
|
-
* authorization, atomic commit, activity recording.
|
|
12
|
+
* authorization, atomic commit, activity recording. A caller from `as()` is signed in, as
|
|
13
|
+
* every caller is in production: it holds a session, so durable work it starts (a job it
|
|
14
|
+
* queued, an after-commit effect, a schedule) runs as it, re-authorized, exactly as there.
|
|
15
|
+
* `as(who, { session: false })` is a caller with no session, to test what that refuses.
|
|
16
|
+
*
|
|
17
|
+
* const ran = await t.runtime.runServices(); // { jobs, deliveries, scheduled, failed: { jobs, deliveries } }
|
|
13
18
|
*/
|
|
14
19
|
import { resolve } from "node:path";
|
|
15
20
|
import { FeltKitError } from "../errors.js";
|
|
@@ -34,11 +39,30 @@ export async function createTestApp(options = {}) {
|
|
|
34
39
|
throw new Error(`"${who}" is not a dev user. Declare it in feltkit({ dev: { users } }) or pass a principal object.`);
|
|
35
40
|
return { id: user.id, type: user.type ?? "user", roles: user.roles, ...(user.name ? { displayName: user.name } : {}) };
|
|
36
41
|
};
|
|
37
|
-
|
|
42
|
+
// One session per principal and runtime state, issued on the caller's first call. A principal
|
|
43
|
+
// whose roles the app does not declare gets none (its calls are refused as they would be).
|
|
44
|
+
const sessions = new Map();
|
|
45
|
+
const signIn = (principal) => {
|
|
46
|
+
const key = JSON.stringify([principal.id, principal.type, [...principal.roles].sort()]);
|
|
47
|
+
let issued = sessions.get(key);
|
|
48
|
+
if (!issued) {
|
|
49
|
+
issued = runtime.issueSession(principal, { kind: "test", via: "test" }).then(() => undefined, (error) => {
|
|
50
|
+
if (error instanceof FeltKitError && error.code === "INVALID_ARGUMENT" && /Unknown role/.test(error.message))
|
|
51
|
+
return;
|
|
52
|
+
sessions.delete(key);
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
55
|
+
sessions.set(key, issued);
|
|
56
|
+
}
|
|
57
|
+
return issued;
|
|
58
|
+
};
|
|
59
|
+
const caller = (principal, options = {}) => {
|
|
38
60
|
const run = async (name, args) => {
|
|
61
|
+
if (principal && options.session !== false)
|
|
62
|
+
await signIn(principal);
|
|
39
63
|
const result = await runtime.call(name, args ?? {}, { principal, via: "test" });
|
|
40
64
|
if (!result.ok)
|
|
41
|
-
throw new FeltKitError(result.error.code, result.error.message, { details: result.error.details, ...(result.error.hint ? { hint: result.error.hint } : {}) });
|
|
65
|
+
throw new FeltKitError(result.error.code, result.error.message, { details: result.error.details, ...(result.error.hint ? { hint: result.error.hint } : {}), ...(result.error.retryable ? { retryable: true } : {}) });
|
|
42
66
|
return result.value;
|
|
43
67
|
};
|
|
44
68
|
return {
|
|
@@ -53,7 +77,7 @@ export async function createTestApp(options = {}) {
|
|
|
53
77
|
},
|
|
54
78
|
query: anonymous.query,
|
|
55
79
|
mutation: anonymous.mutation,
|
|
56
|
-
as: (who) => caller(principalFor(who)),
|
|
80
|
+
as: (who, options) => caller(principalFor(who), options),
|
|
57
81
|
async restart() {
|
|
58
82
|
await runtime.close();
|
|
59
83
|
project = await loadSources(projectDir);
|
|
@@ -71,11 +95,13 @@ export async function createTestApp(options = {}) {
|
|
|
71
95
|
*
|
|
72
96
|
* The artifact runs in an in-memory reference host (`appboundry-guest/1`), loaded only from
|
|
73
97
|
* `manifest.json` and `module.wasm`. It is for verification, not serving: no HTTP, no
|
|
74
|
-
* persistence
|
|
98
|
+
* persistence unless `stateDir` is given (FeltDB local state, so the next version of the
|
|
99
|
+
* artifact can be opened on the same records: its schema is installed only when they satisfy
|
|
100
|
+
* it). `configuration` seeds the Configuration service's variables. Close it when done.
|
|
75
101
|
*/
|
|
76
102
|
export async function createArtifactTestApp(path, options = {}) {
|
|
77
103
|
const { ArtifactHost } = await import("../appboundry/host.js");
|
|
78
|
-
const host =
|
|
104
|
+
const host = await ArtifactHost.open(resolve(path), options);
|
|
79
105
|
const principalFor = (who) => {
|
|
80
106
|
if (typeof who !== "string")
|
|
81
107
|
return { id: who.id, type: who.type ?? "user", roles: who.roles, ...(who.displayName ? { displayName: who.displayName } : {}) };
|
|
@@ -89,6 +115,6 @@ export async function createArtifactTestApp(path, options = {}) {
|
|
|
89
115
|
mutation: (fn, args) => host.call(fn.name, args ?? {}, principal),
|
|
90
116
|
});
|
|
91
117
|
const anonymous = caller(null);
|
|
92
|
-
return { host, query: anonymous.query, mutation: anonymous.mutation, as: (who) => caller(principalFor(who)), close:
|
|
118
|
+
return { host, query: anonymous.query, mutation: anonymous.mutation, as: (who) => caller(principalFor(who)), close: () => host.close() };
|
|
93
119
|
}
|
|
94
120
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA
|
|
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;AAE5C,OAAO,EAAE,kBAAkB,EAA0B,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAsBrE,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,UAAgE,EAAE;IACpG,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAA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,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;AAC3I,CAAC"}
|
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
# Agent-native development and operations
|
|
2
|
+
|
|
3
|
+
Status: the design is from a read-only inventory of FeltKit, AppPort, AuthBoundry and Resolver
|
|
4
|
+
(all on `main` as of 2026-11-03). **PRs 1–3 are implemented** (§6, §7, §8); the rest is planned. §5
|
|
5
|
+
records the owner's decisions; §9 records where PRs 4–6 stand and what blocks them.
|
|
6
|
+
|
|
7
|
+
**Correction (2026-11-03).** PRs 1–3 were tested on small projects only. With more than 1,000 records
|
|
8
|
+
in a collection, `change.verify` (it backs up and restores the development state) and every deployment
|
|
9
|
+
cutover (it backs up the production volume) failed on FeltDB 0.20.0, and on 0.18.0 the application
|
|
10
|
+
itself returned at most 100 records from `find` and `count`. Fixed with the paged reads and streamed
|
|
11
|
+
backup described in docs/UPSTREAM-GAPS.md ("Review 2026-11-03"). `test/platform-large-state.test.ts`
|
|
12
|
+
runs `change.verify`, `change.apply` and `deploy.apply` against 1,001 development and production
|
|
13
|
+
records, and checks the production data after each cutover.
|
|
14
|
+
|
|
15
|
+
The rule this design keeps: **the agent is a consumer of FeltKit, not the owner of the
|
|
16
|
+
application.** FeltKit owns the application's state, capabilities, authority, deployment and
|
|
17
|
+
evidence. A model supplies reasoning and proposed changes. A proposal is not authorization; a tool
|
|
18
|
+
response is not proof; **a deployment receipt is proof.**
|
|
19
|
+
|
|
20
|
+
## 1. Inventory: what exists to reuse
|
|
21
|
+
|
|
22
|
+
### FeltKit
|
|
23
|
+
|
|
24
|
+
| Need | Exists | Where |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| Agent principals | `Principal { type: "user" \| "agent" \| "service" }`, agent sessions (`feltkit session create --type agent`), revocable by reference, checked on every request | `runtime/authority.ts`, `runtime/sessions.ts` |
|
|
27
|
+
| Per-call authority | `Authority.authorize()` returns a `Decision` (decisionId, policyVersion), recorded in activity. Roles resolve to permissions on every call | `runtime/authority.ts`, `runtime/activity.ts` |
|
|
28
|
+
| Propose, approve (people only), execute, evidence | `AgentHost`: proposals, approval by a `user` only, execution as the task owner, checkpoints with FeltDB-verified evidence, handoffs | `runtime/agent.ts` |
|
|
29
|
+
| AppPort and MCP for **application** capabilities | Functions as AppPort capabilities (authority before input), `/appport`, `/mcp` (bearer token per request) | `runtime/capabilities.ts`, `server/mcp.ts` |
|
|
30
|
+
| Operator access to production | Signed one-time grants, then `operator` sessions; `feltkit.operations.read\|write` | `server/operators.ts` |
|
|
31
|
+
| Inspect, schema, build, migrate, backup | `inspect --json`, `doctor --json`, `schemaPlan/History`, `build()` (`BuildResult`, schema hash), `migrate --json`, `backup` | `cli/main.ts`, `server/project.ts`, `runtime/state-contract.ts` |
|
|
32
|
+
| Deploy | `deploy()` builds, boots, checks health and the manifest, writes `.feltkit/deploy`; `vercel` / `cloudflare` / `fly` push | `cli/deploy.ts`, `runtime/targets.ts` |
|
|
33
|
+
|
|
34
|
+
**Missing in FeltKit:**
|
|
35
|
+
- None of the development or operations steps (inspect, test, build, deploy, migrate) is an AppPort
|
|
36
|
+
capability or MCP tool; they are CLI only. `test` and `deploy` have no `--json`. *(PR 1: inspect,
|
|
37
|
+
schema, test and build are capabilities; `test --json` and `build --json` exist.)*
|
|
38
|
+
- **No deployment revision, change set, receipt or deploy actor.** `.feltkit/deployment.json` is one
|
|
39
|
+
overwritten file with no artifact hash.
|
|
40
|
+
- `tools/list` shows every capability, not only the ones the caller may call. *(PR 1: the platform's
|
|
41
|
+
`/mcp` lists only what the profile grants; an application's `/mcp` is unchanged.)*
|
|
42
|
+
- A session's roles are fixed when it is issued: a role change applies only after the session is
|
|
43
|
+
revoked.
|
|
44
|
+
- No Resolver code.
|
|
45
|
+
|
|
46
|
+
### AppPort (`/home/user/appport`)
|
|
47
|
+
|
|
48
|
+
**Reuse:**
|
|
49
|
+
- Capability manifest (`appport/1`): typed `inputSchema`/`outputSchema`, `authorization` scopes,
|
|
50
|
+
`effect` (observation or consequential), idempotency.
|
|
51
|
+
- The integration descriptor (`appport.integration/1`): `preconditions`, `failures` (retry
|
|
52
|
+
semantics), `approval { required, approver }`, `effects`, `verify`.
|
|
53
|
+
- `capabilityDigest` and `contractDigest` (`sha256:`) for pinning, in AppPort's canonical-contract
|
|
54
|
+
registry (`@appport/core`). The manifest an application serves does not carry them.
|
|
55
|
+
- `Authorizer` called **on every request**, which returns a `decisionId`.
|
|
56
|
+
- MCP projection with identity per call; idempotency claims.
|
|
57
|
+
|
|
58
|
+
**Missing in AppPort:**
|
|
59
|
+
- An `agent` principal type and an on-behalf-of chain (`delegationId` exists but is unused).
|
|
60
|
+
- `policyVersion` on decisions, receipts, and a CLI for discovering or invoking capabilities.
|
|
61
|
+
- An AuthBoundry adapter.
|
|
62
|
+
|
|
63
|
+
### AuthBoundry (`/home/user/authboundry`, a Rust service with an HTTP JS SDK)
|
|
64
|
+
|
|
65
|
+
**Reuse (implemented and tested):**
|
|
66
|
+
- Delegations `{delegator, delegate, capabilities, application scope, expiry}`. Revocation takes
|
|
67
|
+
effect at the next decision, with no decision cache; a delegation carries no authority once its
|
|
68
|
+
delegator has lost it.
|
|
69
|
+
- Agent principals (active, suspended, revoked) and agent credentials (scoped, renewable; replaying
|
|
70
|
+
an old credential revokes the whole family).
|
|
71
|
+
- Agent runs under a delegation.
|
|
72
|
+
- Durable evidence for every decision, denials included; an audit-write failure is a deny.
|
|
73
|
+
- `createAuthBoundryAuthorizer` (an AppPort `Authorizer`) and `enforce({..., execute})`.
|
|
74
|
+
|
|
75
|
+
**Missing in AuthBoundry:**
|
|
76
|
+
- Per-environment scope (environments are metadata only).
|
|
77
|
+
- Resource attributes evaluated on the application path.
|
|
78
|
+
- A change-set or revision field (only a free-form `context` of up to 16 keys).
|
|
79
|
+
- A durable lookup of a decision by id (`explain` filters a list; the decisions endpoint sees only
|
|
80
|
+
the latest 100).
|
|
81
|
+
- An adapter for the `ServiceAuthorizer` protocol.
|
|
82
|
+
- Approval of a pending action.
|
|
83
|
+
- **Its README marks it not production-ready.** FeltKit and AppPort Services do not call it today.
|
|
84
|
+
|
|
85
|
+
### Resolver (`/home/user/rkendel1/resolver`, an AppPort application)
|
|
86
|
+
|
|
87
|
+
**Reuse (implemented and tested):**
|
|
88
|
+
- `ref://` names of five kinds: model, secret, endpoint, value, agent.
|
|
89
|
+
- Revisions with actor and reason, pin, rollback, and revoke. A revoked reference answers
|
|
90
|
+
`NOT_FOUND` with `resolver.revoked`, pinned or not.
|
|
91
|
+
- Watch (names only, then re-resolve with the caller's own authority), and per-key grants
|
|
92
|
+
(`read`, `reveal`, `write`, `admin`), denied by default.
|
|
93
|
+
- `ResolverClient.model(ref)` returns the provider, model and endpoint, plus `apiKey` through a
|
|
94
|
+
separate `reveal`, which is audited.
|
|
95
|
+
- An in-process runtime for tests (`createResolverRuntime({ state: { memory: true } })`).
|
|
96
|
+
|
|
97
|
+
**Missing in Resolver:**
|
|
98
|
+
- **Nothing is published to npm** (all three packages are 0.1.0, and `npm view` returns 404).
|
|
99
|
+
- **Resolver hands plaintext to whatever key may reveal**, so FeltKit must keep that key and the
|
|
100
|
+
model call inside its trusted runtime.
|
|
101
|
+
- It pins `@appport/services` 0.9.1 and `@feltdb/core` 0.16.1, older than FeltKit's.
|
|
102
|
+
|
|
103
|
+
## 2. Architecture (no parallel systems)
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
agent (Claude Code, Codex, Stack-Agent…)
|
|
107
|
+
│ CLI `feltkit op <capability>` │ MCP /mcp │ AppPort /appport
|
|
108
|
+
└──────────────┬───────────────────┴─────────────────────┘
|
|
109
|
+
FeltKit platform operations (one registry: typed input/output,
|
|
110
|
+
preconditions, effect, authority, approval) ── AppPort manifest `dev.feltkit.platform`
|
|
111
|
+
│ per-call authority: FeltKit Authority now, AuthBoundry adapter when configured
|
|
112
|
+
│ evidence: activity + receipts in the platform store (FeltDB)
|
|
113
|
+
project workspace (isolated per change set) · build · test · deploy executors
|
|
114
|
+
│
|
|
115
|
+
application runtime(s): FeltDB state · AppPort app capabilities · AppBoundry artifacts
|
|
116
|
+
│ references, not values
|
|
117
|
+
Resolver (ref://…) for models, secrets, endpoints, values, agents
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- **One operations registry.** Each operation is defined once: `s` schemas for input and output,
|
|
121
|
+
an AppPort capability (effect, authorization scopes), and an integration descriptor
|
|
122
|
+
(preconditions, failures, approval). CLI, MCP and AppPort are adapters over the same handler, so
|
|
123
|
+
nothing is "agent-only".
|
|
124
|
+
- **Platform store.** One FeltDB store per workspace root holds change sets, deployment revisions
|
|
125
|
+
and receipts. It is not another project database: application state stays in each environment's
|
|
126
|
+
FeltDB.
|
|
127
|
+
- **Authority profiles** are permission sets on the existing authority. They are not a new system.
|
|
128
|
+
|
|
129
|
+
| Profile | Permissions |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `inspect` | `feltkit.platform.read` |
|
|
132
|
+
| `develop` | inspect, plus `feltkit.changes.write` (its own change sets' workspaces only) |
|
|
133
|
+
| `deploy` | develop, plus `feltkit.deploy:<application>/<environment>` |
|
|
134
|
+
|
|
135
|
+
The decision is made **at execution** (sessions are checked on every request, and delegations
|
|
136
|
+
in AuthBoundry at the next decision), so revocation stops an agent that is already connected.
|
|
137
|
+
- **Change set lifecycle** (durable records in the platform store):
|
|
138
|
+
|
|
139
|
+
| State | What happens |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `proposed` | Bound to an application and to the deployment revision it starts from |
|
|
142
|
+
| `implementing` | An isolated workspace copy is created; the agent edits only there |
|
|
143
|
+
| `verified` | Build, tests, contract and migration plan run by FeltKit, not the model. Records the workspace tree digest, artifact digest, test results and migration plan |
|
|
144
|
+
| `authorized` | A per-environment decision recorded as AppPort/AuthBoundry evidence |
|
|
145
|
+
| `applied` | Deployed only if the tree and artifact digests still equal the verified ones; refused if the target moved past the base revision |
|
|
146
|
+
| `proven` | A receipt: artifact digest, revision, actor, delegating principal, decision ids, target and outcome. It is written only after the deployed health check and manifest check pass |
|
|
147
|
+
|
|
148
|
+
A failed deploy produces a `failed` record with its evidence. It never produces a receipt.
|
|
149
|
+
- **Resolver.** FeltKit stores `ref://…` references; resolution happens inside FeltKit's process
|
|
150
|
+
(reveal keys never reach an agent). Each use records the reference and the revision it resolved.
|
|
151
|
+
Resolver keeps configuration and secrets; AuthBoundry/AppPort keep what an agent may do.
|
|
152
|
+
|
|
153
|
+
## 3. Capability catalog (`dev.feltkit.platform`, version 1)
|
|
154
|
+
|
|
155
|
+
| Capability | Effect | Authority | Preconditions and notes |
|
|
156
|
+
|---|---|---|---|
|
|
157
|
+
| `project.inspect` | observation | inspect | structure, functions, collections, contract hash, deployment revisions, readiness |
|
|
158
|
+
| `project.create` | consequential | develop | target directory new; returns workspace path |
|
|
159
|
+
| `schema.inspect` | observation | inspect | collections, fields, indexes, references; installed vs declared contract and plan |
|
|
160
|
+
| `schema.change` | consequential | develop | change set open; edits `feltkit/app.ts` in its workspace; returns plan (and migration needed) |
|
|
161
|
+
| `function.create` / `function.update` | consequential | develop | change set open; typed module edits in its workspace; build-checked |
|
|
162
|
+
| `test.run` | observation* | develop | in a workspace; structured results (each test, failure output) |
|
|
163
|
+
| `build.run` | observation* | develop | in a workspace; artifact digest |
|
|
164
|
+
| `change.propose` | consequential | develop | project, environment, files; base source revision (PR 2) |
|
|
165
|
+
| `change.inspect` | observation | inspect | the change set, its files, staleness, verification, receipt, history (PR 2) |
|
|
166
|
+
| `change.verify` | consequential | develop | FeltKit-run build, tests, contract and migration check; records digests (PR 2) |
|
|
167
|
+
| `deploy.plan` | observation | deploy | verified change set; impact: schema changes, migrations, target |
|
|
168
|
+
| `deploy.apply` / `change.apply` | consequential | deploy | verified, unchanged digests; target still at base revision; approval when required. Returns a receipt (`change.apply`: PR 2) |
|
|
169
|
+
| `runtime.inspect` | observation | inspect | deployed health, readiness, schema status, revision |
|
|
170
|
+
| `runtime.logs` | observation | inspect | activity and failures (no payloads), outbox |
|
|
171
|
+
|
|
172
|
+
\* No effect on the application. They write only verification evidence.
|
|
173
|
+
|
|
174
|
+
## 4. Delivery: a sequence of PRs, each independently useful and tested
|
|
175
|
+
|
|
176
|
+
| # | PR | Proves |
|
|
177
|
+
|---|---|---|
|
|
178
|
+
| 1 | Operations registry and catalog; `project.inspect`, `schema.inspect`, `test.run`, `build.run`; CLI `feltkit op`, MCP and AppPort adapters over one handler; profiles on the existing authority; activity evidence | An agent discovers the operations, sees the authority each needs, and runs them through all three adapters with the same results; a missing permission is refused per call; revocation applies mid-session |
|
|
179
|
+
| 2 | Change sets and isolated workspaces; `change.propose`, `schema.change`, `function.*`, `change.verify` (digests) | Edits only in the workspace; verification is independent of the model; a workspace edited after verification is detected |
|
|
180
|
+
| 3 | Deployment revisions and receipts; `deploy.plan`, `deploy.apply`, `change.apply` to a **local production environment** first, then the existing platform targets | Receipt only after deployed health; a failed deploy gives no receipt; a stale base revision is refused; no deploy permission means refused, and the change stays verified and awaits approval |
|
|
181
|
+
| 4 | AuthBoundry adapter (delegations, agent credentials) behind the same authority boundary; upstream asks: environment scope and decision lookup by id | Delegated authority per environment; revoking a delegation stops the next operation |
|
|
182
|
+
| 5 | Resolver references for models, credentials, endpoints and values; resolution and revisions recorded | A credential is never in the agent's context; revocation stops the next resolve; rebinding without a redeploy |
|
|
183
|
+
| 6 | The invoice acceptance scenario, end to end, through two agent clients (CLI and MCP) | Build, operate, evolve (second approval over $10,000), and the boundary checks |
|
|
184
|
+
|
|
185
|
+
## 5. Decisions (settled by the owner, 2026-11-03)
|
|
186
|
+
|
|
187
|
+
1. **Authority in PRs 1–3: FeltKit's existing authority.** Sessions are checked per call and
|
|
188
|
+
revocable. The inspect, develop and deploy profiles are permission sets on it. The AuthBoundry
|
|
189
|
+
adapter comes in PR 4, with the upstream asks (environment scope, decision lookup by id).
|
|
190
|
+
2. **Resolver: published first.** `@appport/resolver-client` (and the server package, for tests) is
|
|
191
|
+
published before FeltKit's Resolver PR, which then takes a normal semver range.
|
|
192
|
+
3. **First deployment target: a local production environment** (`feltkit start` on a volume). The
|
|
193
|
+
platform targets (Vercel, Cloudflare, Fly) follow, since they need real credentials.
|
|
194
|
+
|
|
195
|
+
## 6. PR 1: what exists, and its limits
|
|
196
|
+
|
|
197
|
+
**Implemented** (`packages/sdk/src/platform/`, tests in `test/platform-operations.test.ts`):
|
|
198
|
+
|
|
199
|
+
- **The operations**: `project.inspect`, `schema.inspect`, `test.run`, `build.run`, each defined
|
|
200
|
+
once in `operations.ts`. Each has typed input and output, its effect, the permission it requires,
|
|
201
|
+
and an integration descriptor (purpose, effects, approval, failures).
|
|
202
|
+
- **One AppPort application, `dev.feltkit.platform`.** The CLI (`feltkit op`), AppPort over HTTP
|
|
203
|
+
(`/appport`) and MCP (`/mcp`, from `feltkit platform serve`) dispatch through its one
|
|
204
|
+
`handleRequest`. The tests show the three answer `schema.inspect` identically.
|
|
205
|
+
- **Authority**:
|
|
206
|
+
- FeltKit's `Authority`, with the profiles as roles: `inspect` holds `feltkit.platform.read`;
|
|
207
|
+
`develop` adds `feltkit.platform.develop`; `owner` holds everything.
|
|
208
|
+
- It is checked on every call, and before input validation.
|
|
209
|
+
- A refusal carries a `dec_…` decision id.
|
|
210
|
+
- Platform sessions are FeltKit's session store, so a revoked one is refused at its next request,
|
|
211
|
+
however long the agent has been connected.
|
|
212
|
+
- **Evidence**: every invocation goes into the platform's activity log, allowed or refused. Each
|
|
213
|
+
entry has the principal, capability, transport, required permission, decision id, policy
|
|
214
|
+
version, outcome and duration. Input values are not recorded, only their keys.
|
|
215
|
+
- **State**: one FeltDB store, `<root>/.feltkit-platform/state`, holding sessions and activity. It
|
|
216
|
+
is the platform's own; application state stays in each project's environments.
|
|
217
|
+
- The store has one owning process. While `platform serve` runs, the CLI reaches it through
|
|
218
|
+
`.feltkit-platform/server.json`: its URL and an owner session, mode 0600, revoked when the
|
|
219
|
+
server stops.
|
|
220
|
+
- **Executors**: the work is FeltKit's own CLI (`inspect --json`, `migrate --dry-run --json`,
|
|
221
|
+
`test --json`, `build --json`), run in a child process in the project's directory. The
|
|
222
|
+
platform never imports a project's code.
|
|
223
|
+
- `test --json` reports through a `node:test` reporter: each test's outcome, duration, and on
|
|
224
|
+
failure its message, expected and actual values.
|
|
225
|
+
- `build --json` reports the bundle's SHA-256 and the schema hash.
|
|
226
|
+
|
|
227
|
+
**Limits (known, not hidden):**
|
|
228
|
+
|
|
229
|
+
- **A child process is not a sandbox.** `test.run` and `build.run` execute the project's code with
|
|
230
|
+
the operating-system user's permissions. A `develop` profile is therefore a grant to run code on
|
|
231
|
+
this machine. Isolation (a container or a separate user) is the workspace's job and arrives with
|
|
232
|
+
change-set workspaces (PR 2).
|
|
233
|
+
- **Projects are named relative to the root.** A name outside it, or one into
|
|
234
|
+
`.feltkit-platform`, is refused. A symlink inside the root that points outside it is not
|
|
235
|
+
resolved and checked.
|
|
236
|
+
- **`project.inspect` and `schema.inspect` open the project's development environment.** They read
|
|
237
|
+
it directly when no server runs, or go through `feltkit dev`'s admin API when one does, as the
|
|
238
|
+
CLI does for a person. So `project.inspect` reflects that environment at that moment
|
|
239
|
+
(timestamps, recent activity), not only the source.
|
|
240
|
+
- **There is no `deploy` profile yet**, and no capability changes an application. Those arrive
|
|
241
|
+
with change sets (PR 2) and deployment receipts (PR 3).
|
|
242
|
+
- **No capability digests in the served manifest.** AppPort computes `capabilityDigest` in its
|
|
243
|
+
canonical-contract registry only; pinning a platform contract waits for that to reach served
|
|
244
|
+
manifests.
|
|
245
|
+
- **The decision id of a refusal is FeltKit's own.** AppPort's authorizer issues the id of an
|
|
246
|
+
allowed call. AuthBoundry's durable decisions replace both in PR 4.
|
|
247
|
+
|
|
248
|
+
## 7. PR 2: change sets, and their limits
|
|
249
|
+
|
|
250
|
+
**Implemented** (`packages/sdk/src/platform/changes.ts`, `source.ts`; tests in
|
|
251
|
+
`test/platform-changes.test.ts`):
|
|
252
|
+
|
|
253
|
+
- **A change set is the change itself**: the files it writes (UTF-8 content, or null to delete),
|
|
254
|
+
for one project and one environment. It is stored in the platform's FeltDB store
|
|
255
|
+
(`feltkit.platform.changes`) with:
|
|
256
|
+
- **its base revision:** `rev_` and the SHA-256 of the project's source tree. Source means every
|
|
257
|
+
regular file except dot-entries, `node_modules`, `dist` and `feltkit/_generated`.
|
|
258
|
+
- **its content digest:** SHA-256 over its files in path order.
|
|
259
|
+
|
|
260
|
+
The platform computes both; neither comes from the caller. The content is immutable: a revised
|
|
261
|
+
change is a new proposal.
|
|
262
|
+
- **Paths:** project-relative source only, at most 200 files and 2 MB. Writes refuse a symbolic link
|
|
263
|
+
and any parent that resolves outside the project. This closes, for writes, the symlink gap noted
|
|
264
|
+
in §6.
|
|
265
|
+
- **Transitions:**
|
|
266
|
+
|
|
267
|
+
| From | To |
|
|
268
|
+
|---|---|
|
|
269
|
+
| `proposed` | `verifying` |
|
|
270
|
+
| `verifying` | `verified` or `verification_failed` |
|
|
271
|
+
| `verified` or `apply_failed` | `applying` |
|
|
272
|
+
| `applying` | `applied` or `apply_failed` |
|
|
273
|
+
|
|
274
|
+
- Each transition is one FeltDB transaction: the change record moves from the version it was
|
|
275
|
+
read at (`ifVersion`, so two concurrent transitions cannot both win), and an event is appended
|
|
276
|
+
to `feltkit.platform.change-events` with `requireAbsent`. Events are never rewritten.
|
|
277
|
+
- Refusals that change nothing (stale, unverified, wrong target, altered content) are events too.
|
|
278
|
+
- Each event names the caller, the request and the authority decision.
|
|
279
|
+
- **Verification**:
|
|
280
|
+
- It runs in `<root>/.feltkit-platform/workspaces/<id>`: a copy of the project's source with
|
|
281
|
+
`node_modules` linked, and the change written.
|
|
282
|
+
- It runs `feltkit build --json`, then `feltkit test --json`, then a schema plan:
|
|
283
|
+
1. `feltkit backup create --env development` of the project (calls pause if its dev server
|
|
284
|
+
runs);
|
|
285
|
+
2. that backup restored into the workspace;
|
|
286
|
+
3. `feltkit migrate --dry-run --json` there.
|
|
287
|
+
|
|
288
|
+
With no development state, the plan is against an empty environment.
|
|
289
|
+
- It passes only when the build succeeded, no test failed, and the plan is not `blocked`.
|
|
290
|
+
- The record holds what each command returned (test counts, each failure's expected and actual
|
|
291
|
+
values, the bundle and schema digests, the plan's status and changes). It is bound to the
|
|
292
|
+
content digest, the base revision and the workspace's resulting revision.
|
|
293
|
+
- **Apply**:
|
|
294
|
+
1. It requires `feltkit.platform.deploy` and `feltkit.platform.deploy:<project>/<environment>`,
|
|
295
|
+
which only the `deploy:<project>/<environment>` profile (or `owner`) holds.
|
|
296
|
+
2. It refuses when:
|
|
297
|
+
- the request names another project or environment than the change set's;
|
|
298
|
+
- the change set is not verified;
|
|
299
|
+
- the stored content's recomputed digest is not what was verified;
|
|
300
|
+
- the content is not the `expectedContentDigest` the caller reviewed;
|
|
301
|
+
- the project is not at the base revision;
|
|
302
|
+
- the project's existing artifact is for another deploy target.
|
|
303
|
+
3. It records the previous content of every path it will write, then writes the files.
|
|
304
|
+
4. It checks that the project is now at exactly the verified resulting revision.
|
|
305
|
+
5. It runs `feltkit deploy --target container --json`, the existing lifecycle: build, boot the
|
|
306
|
+
production build against isolated state, check health, the AppPort endpoint and the frontend,
|
|
307
|
+
and only then replace `.feltkit/deploy`.
|
|
308
|
+
6. The receipt is written only when deploy returned with its health check passed. It holds the
|
|
309
|
+
change, base and resulting revisions, content digest, verification, the artifact's bundle
|
|
310
|
+
SHA-256, the health result, who applied it, and the decision ids.
|
|
311
|
+
7. Any failure restores the recorded files, records `apply_failed` with the reason and whether
|
|
312
|
+
the source is back at the base revision, and writes no receipt.
|
|
313
|
+
- **Retries**:
|
|
314
|
+
- A proposal with the same `idempotencyKey` returns the same change set; the same key with
|
|
315
|
+
other content is refused.
|
|
316
|
+
- A repeated apply of an applied change set returns its receipt without deploying again.
|
|
317
|
+
- Concurrent verifications or applies: one wins, the other gets `CONFLICT`.
|
|
318
|
+
- **Interruption**: a platform that stopped mid-transition leaves `verifying` or `applying`. The
|
|
319
|
+
next start recovers before any change operation runs:
|
|
320
|
+
- a verification becomes `verification_failed` (`verification.interrupted`);
|
|
321
|
+
- an apply is rolled back from its recorded previous content and becomes `apply_failed`
|
|
322
|
+
(`apply.interrupted`, with whether the source was restored).
|
|
323
|
+
|
|
324
|
+
**Limits (known, not hidden):**
|
|
325
|
+
|
|
326
|
+
- **Child processes are not an OS security sandbox.** Verification runs the change's own build
|
|
327
|
+
and test code, and apply runs `feltkit deploy`, which boots it. Both run as the operating-system
|
|
328
|
+
user, with that user's files and network. `develop` can therefore run arbitrary code on this
|
|
329
|
+
machine through `change.verify`. A container or a separate OS user is the deployment's job and
|
|
330
|
+
is not provided here.
|
|
331
|
+
- *(Superseded by PR 3, §8:* apply now deploys through local production deployments. A release
|
|
332
|
+
directory per deployment means nothing running is replaced under it, and the receipt proves
|
|
333
|
+
the running process passed live verification.*)*
|
|
334
|
+
- **One environment:** `production` as the local `container` target. A project whose artifact is
|
|
335
|
+
for another target is refused. Hosted targets need credentials (§5).
|
|
336
|
+
- **The schema plan uses development data, not production's.** Production applies its migrations
|
|
337
|
+
when the artifact starts (FeltKit's activation refuses drift).
|
|
338
|
+
- **The platform store is the authority.** The platform recomputes the content digest from the
|
|
339
|
+
stored files, so an inconsistent edit of the store is caught (tested). But anyone who can write
|
|
340
|
+
`<root>/.feltkit-platform` as the OS user can forge a consistent record. File permissions are
|
|
341
|
+
the boundary.
|
|
342
|
+
- **Base-revision staleness is checked against the source tree only.** State and configuration
|
|
343
|
+
(`.env*`) are not part of the revision.
|
|
344
|
+
- **No approval step.** Apply is authorized by the deploy profile alone; `delegatedBy` in the
|
|
345
|
+
receipt is null until AuthBoundry delegations (PR 4). A refusal's decision id, and an allowed
|
|
346
|
+
call's when AppPort's reference is absent from a handler's error, are FeltKit's own `dec_…`.
|
|
347
|
+
- **History.** Every event of a change set is listed (read in FeltDB pages; until 2026-11-03 it
|
|
348
|
+
stopped at 1,000).
|
|
349
|
+
|
|
350
|
+
## 8. PR 3: local production deployments and runtime operations
|
|
351
|
+
|
|
352
|
+
### Inventory: what existed, and what was reused
|
|
353
|
+
|
|
354
|
+
| Mechanism | What it does | In PR 3 |
|
|
355
|
+
|---|---|---|
|
|
356
|
+
| `feltkit start` (`startProduction`) | Loads `.feltkit/build/functions.mjs` and resolves the production environment (`FELTKIT_STATE_DIR` for local state). Opens its port early, starts the runtime, writes `runtime.json`, and closes cleanly on SIGTERM. Applies the declared schema at start (`migrate: auto`): a change FeltDB would refuse stops it before it serves. | **The production process**, unchanged, plus the bundle digest it loaded. Migrations are applied only by this existing mechanism. |
|
|
357
|
+
| `feltkit deploy` | Builds, boots the build against a temporary state directory, checks `/_feltkit/health`, the AppPort manifest and the frontend, then writes an artifact. The default `.feltkit/deploy` is replaced in place (even under a running server); `--out` never overwrites. | **The candidate build and artifact verification**, with `--out` into a new release directory per deployment. The in-place default is not used. |
|
|
358
|
+
| Container build | The artifact carries a Dockerfile and docker-compose with the state on a volume. The same artifact runs with plain Node. | Local production runs the artifact with Node. Docker is not used. |
|
|
359
|
+
| Persistent state | Local production state defaults to `<project>/.feltkit/production/state`. Its secrets (API-key verifier, auth secret) are kept beside it. | **The persistent volume**, the same place `feltkit start` and `feltkit backup --env production` use. |
|
|
360
|
+
| Health | `/_feltkit/health` is liveness only: status, application and environment. The deploy check boots against isolated state. Neither proves which artifact runs, on which state. | **Added `/_feltkit/deployment`** (below). The isolated boot check is recorded as *artifact* verification only. |
|
|
361
|
+
| Backup and restore | `backup create` reads a stopped environment directly. `restore` writes only into a new, empty environment, after verifying the file. | **The pre-deployment backup**, and the restore when rolling back. |
|
|
362
|
+
| Server lifecycle | Nothing supervises a production process. `runtime.json` records the pid. | Unchanged: no supervisor (see the limits). |
|
|
363
|
+
| PR 2's apply | Writes the files, deploys, and on failure restores the source. Idempotent, fenced, and recovered at start. | Kept. It now deploys through local production deployments, and the receipt includes the deployment's. |
|
|
364
|
+
|
|
365
|
+
### The lifecycle (`deployments.ts`)
|
|
366
|
+
|
|
367
|
+
`deploy.apply` deploys the project's current source after its tests pass. `change.apply` deploys
|
|
368
|
+
a verified change set, as in §7. Both go through one lifecycle:
|
|
369
|
+
|
|
370
|
+
1. **Plan.** One fenced transaction marks the environment `deploying` and creates the deployment
|
|
371
|
+
record. A second deployment at the same time gets `CONFLICT`.
|
|
372
|
+
2. **Candidate.**
|
|
373
|
+
- It is built into `<project>/.feltkit/releases/<deployment>` with `feltkit deploy --target
|
|
374
|
+
container --out … --json`. This records the artifact verification: the isolated boot check
|
|
375
|
+
and the bundle SHA-256.
|
|
376
|
+
- The source must still be at the revision being deployed.
|
|
377
|
+
- A failure here touches nothing that is running.
|
|
378
|
+
3. **Cutover.**
|
|
379
|
+
- The running release stops (SIGTERM, then SIGKILL after 15 s), because only one process can
|
|
380
|
+
own the volume.
|
|
381
|
+
- The volume is backed up into the release directory (`feltkit backup create --env
|
|
382
|
+
production`).
|
|
383
|
+
4. **Start.**
|
|
384
|
+
- The candidate runs as a detached `feltkit start` on the volume, on the environment's port
|
|
385
|
+
(127.0.0.1).
|
|
386
|
+
- It gets `FELTKIT_DEPLOYMENT_ID`, `FELTKIT_DEPLOYMENT_REVISION` and a random
|
|
387
|
+
`FELTKIT_DEPLOYMENT_TOKEN`.
|
|
388
|
+
- Its output goes to the release's `server.log`.
|
|
389
|
+
5. **Live verification.** The candidate is polled at `/_feltkit/deployment` (token required)
|
|
390
|
+
until it is ready, it exits, or the readiness timeout passes (60 s by default). Then nine
|
|
391
|
+
checks against what the process itself reports:
|
|
392
|
+
- **ready:** it reports `ready`;
|
|
393
|
+
- **application:** the application the artifact was built for;
|
|
394
|
+
- **environment:** production;
|
|
395
|
+
- **deployment:** the deployment id;
|
|
396
|
+
- **revision:** the source revision;
|
|
397
|
+
- **artifact:** the SHA-256 of the bundle the process loaded equals the release's;
|
|
398
|
+
- **state.location:** its state is local, at the volume;
|
|
399
|
+
- **state.access:** it read back the start record it wrote to that state;
|
|
400
|
+
- **schema:** its schema is current.
|
|
401
|
+
6. **Commit** in one transaction:
|
|
402
|
+
- the deployment becomes `live`, with its receipt;
|
|
403
|
+
- the environment's active deployment becomes this one;
|
|
404
|
+
- the previous deployment becomes `superseded`.
|
|
405
|
+
7. **Otherwise roll back.** The candidate is stopped and no receipt is written.
|
|
406
|
+
- The previous release is started again on the volume and verified (its deployment id,
|
|
407
|
+
revision and bundle).
|
|
408
|
+
- If it cannot run there, for example because the candidate migrated the state first, the
|
|
409
|
+
volume is moved aside (never deleted). The pre-deployment backup is restored into a fresh
|
|
410
|
+
volume, and the previous release is started and verified again.
|
|
411
|
+
- If that fails too, the environment is **`degraded`**: no active deployment, with the
|
|
412
|
+
reason, every attempt, and `rollback.failed` in the history.
|
|
413
|
+
- A failed *first* deployment moves the state it created aside, so production has no state,
|
|
414
|
+
as before.
|
|
415
|
+
|
|
416
|
+
Interrupted deployments are handled by the next platform start. A deployment still `deploying`
|
|
417
|
+
is failed with `feltkit.INTERRUPTED`: its candidate is stopped and the rollback above runs. PR
|
|
418
|
+
2's recovery rolls back the change set's files.
|
|
419
|
+
|
|
420
|
+
**Idempotency.** `deploy.apply` of the revision that is running and still verifies returns that
|
|
421
|
+
deployment's receipt and deploys nothing. A repeated `change.apply` returns the change's receipt.
|
|
422
|
+
|
|
423
|
+
### Receipts and evidence
|
|
424
|
+
|
|
425
|
+
A receipt (`kind: local-production-deployment`) holds:
|
|
426
|
+
- the project, environment, deployment id, change-set id, and source revision and content
|
|
427
|
+
digest;
|
|
428
|
+
- **`artifact`**: the release, the bundle SHA-256, the schema hash, and the *isolated-boot*
|
|
429
|
+
verification;
|
|
430
|
+
- **`live`**: the *live* verification (time and the nine checks), the pid, URL, start time,
|
|
431
|
+
application, and state location;
|
|
432
|
+
- `health`: the status and time;
|
|
433
|
+
- **`migration`**: the schema before and after, and whether a migration was applied;
|
|
434
|
+
- `previous`: the deployment it replaced;
|
|
435
|
+
- `authorizedBy`: the principal and decision id.
|
|
436
|
+
|
|
437
|
+
What a receipt means, in its own words: *"The expected artifact was running and passed these
|
|
438
|
+
checks at verifiedAt. It is not a guarantee of future availability."*
|
|
439
|
+
|
|
440
|
+
Failed, rolled-back and degraded deployments are durable records with their stage, error,
|
|
441
|
+
checks, rollback outcome and every step in `feltkit.platform.deployment-events`. They have no
|
|
442
|
+
receipt.
|
|
443
|
+
|
|
444
|
+
### Runtime operations
|
|
445
|
+
|
|
446
|
+
| Operation | Permission | Returns |
|
|
447
|
+
|---|---|---|
|
|
448
|
+
| `runtime.inspect` | read (inspect profile) | The active deployment, checked now: what the process reports, whether it matches the record, health, schema, state location, and the last result |
|
|
449
|
+
| `deploy.status` | read | The environment's status, any deployment in progress, the latest deployment with its whole history, and the last 20 deployments (the newest 20 by start time, ordered by FeltDB; until 2026-11-03 the newest of the first 1,000 read) |
|
|
450
|
+
| `runtime.logs` | `feltkit.platform.logs` (develop and deploy profiles; not inspect) | At most 500 lines from the last 64 KB of a deployment's `server.log` |
|
|
451
|
+
| `deploy.apply` | the `deploy:<project>/<environment>` scope | Runs the project's tests, then the lifecycle above |
|
|
452
|
+
|
|
453
|
+
Every call goes through PR 1's authority: inspection never implies deployment authority, and a
|
|
454
|
+
revoked session is refused at its next call.
|
|
455
|
+
|
|
456
|
+
### Tests (`test/platform-deployments.test.ts`, against real processes)
|
|
457
|
+
|
|
458
|
+
- **First deployment:** the receipt's artifact and live verification, the process answering, the
|
|
459
|
+
token-guarded report, `runtime.inspect` matching, the history, and bounded logs.
|
|
460
|
+
- **Persistence:** data persists across a platform restart (the process keeps running), a
|
|
461
|
+
process stop (redeployed, data intact), and a change applied to the running deployment.
|
|
462
|
+
- **Migration:** a migration applied at start against production records, recorded in the
|
|
463
|
+
receipt.
|
|
464
|
+
- **Failed start:** a candidate that fails to start leaves the previous one running, its data
|
|
465
|
+
intact and the source restored. The candidate's output is in `runtime.logs`.
|
|
466
|
+
- **Readiness timeout:** the hung candidate is stopped and rolled back.
|
|
467
|
+
- **Wrong artifact:** a release altered after its digest was taken is refused. It had migrated
|
|
468
|
+
the volume, so the pre-deployment backup was restored and the migrated volume kept aside.
|
|
469
|
+
- **Blocked migration:** a migration production data blocks fails the candidate, and the state
|
|
470
|
+
is unchanged.
|
|
471
|
+
- **Degraded:** an inaccessible volume, with rollback impossible, leaves production degraded with
|
|
472
|
+
no receipt. Repairing the volume and deploying again recovers it.
|
|
473
|
+
- **Interrupted:** an interrupted deployment and change are rolled back at the next start.
|
|
474
|
+
- **Retries and races:** a replayed apply deploys nothing; of two concurrent deployments, one
|
|
475
|
+
wins.
|
|
476
|
+
- **Authority:** inspection versus logs versus deploy, the deploy scope, and revocation.
|
|
477
|
+
|
|
478
|
+
### Limits and operational risks (known, not hidden)
|
|
479
|
+
|
|
480
|
+
- **No supervisor.** A production process that crashes, or a machine that restarts, is not
|
|
481
|
+
restarted. The state survives on the volume, and `runtime.inspect` shows `stopped`;
|
|
482
|
+
`deploy.apply` starts the same revision again as a new, verified deployment. A service manager
|
|
483
|
+
(systemd, launchd, a container restart policy) is not provided.
|
|
484
|
+
- **Downtime during cutover.** One process can own a local volume, so the old process stops
|
|
485
|
+
before the candidate starts (seconds), and again during a rollback.
|
|
486
|
+
- **Restoring the backup can discard writes.** If the candidate accepted writes before failing
|
|
487
|
+
and the previous release could not run on that volume, those writes are in the moved-aside
|
|
488
|
+
volume, not in the restored one. The receipt and the record say which happened.
|
|
489
|
+
- **The operator key is per release.** It lives in the release's runtime directory, so a grant
|
|
490
|
+
signed for one release is not accepted after the next deployment unless `FELTKIT_OPERATOR_KEY`
|
|
491
|
+
is set. The verifier and auth secrets are beside the volume and persist.
|
|
492
|
+
- **Local only:** 127.0.0.1, one port per environment, `production` only. No cloud targets; the
|
|
493
|
+
deployment record is target-shaped (`kind`, release, checks) so that others can be added.
|
|
494
|
+
- **Not cleaned up:** release directories, pre-deployment backups and moved-aside volumes are
|
|
495
|
+
kept, and nothing removes them yet.
|
|
496
|
+
- **Probe tokens:** they are kept in the platform store, never shown by any operation, and a new
|
|
497
|
+
one is used for each start.
|
|
498
|
+
- **`deploy.apply` runs the project's tests in place, not in a workspace.** A refusal because
|
|
499
|
+
tests fail is in the activity log, not a deployment record. `change.apply` relies on the change
|
|
500
|
+
set's own verification (§7).
|
|
501
|
+
- **Child processes are not an OS security sandbox.** Builds, tests and the production process
|
|
502
|
+
run as the OS user.
|
|
503
|
+
|
|
504
|
+
## 9. PRs 4–6: where they stand (2026-11-03)
|
|
505
|
+
|
|
506
|
+
Checked against npm on 2026-11-03. Nothing here is implemented.
|
|
507
|
+
|
|
508
|
+
| PR | Precondition | State | Blocks it |
|
|
509
|
+
|---|---|---|---|
|
|
510
|
+
| 4: AuthBoundry adapter | A published AuthBoundry with delegations and agent credentials; the upstream asks (environment scope, decision lookup by id) | `@authboundry/core` **1.15.3**, published 2026-09-21, license `UNLICENSED`. The §1 inventory read AuthBoundry's `main`, six weeks newer; whether delegations, agent credentials and runs under a delegation are in 1.15.3 is **unverified**. Neither upstream ask is addressed. AppPort 1.5.0 adds no `agent` principal type, on-behalf-of chain or `policyVersion` | (1) a published AuthBoundry release containing what §1 lists, verified against FeltKit; (2) a license FeltKit can depend on; (3) the two asks, or an explicit decision to ship without them |
|
|
511
|
+
| 5: Resolver references | §5.2: Resolver published first | **Met in part.** `@appport/resolver-client`, `@appport/resolver` and `@appport/resolver-core` 0.1.0 were published 2026-11-03. None declares a license. `@appport/resolver` (the server, needed for FeltKit's tests) pins `@appport/services` **0.9.1** and `@feltdb/core` **0.18.0** exactly: Services 0.9.1 predates the peer dependency (0.11.0), so it installs its own FeltDB, the two-copy problem FeltKit's release gate refuses. `resolver-client` depends on `@appport/sdk` 1.4.0 and `resolver-core` only | (1) a Resolver server release that takes `@feltdb/core` and `@appport/services` as peer or floating dependencies; (2) a declared license; (3) §5's other conditions (multi-instance sync verified on a FeltDB server) |
|
|
512
|
+
| 6: invoice acceptance scenario | PRs 4 and 5 | Not started | PRs 4 and 5 |
|
|
513
|
+
|
|
514
|
+
Before any of these: keep the PR 1–3 suite green at scale (`test/platform-large-state.test.ts`), and
|
|
515
|
+
adopt a new FeltDB release only once `npm run test:all` passes on it.
|