@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.
Files changed (146) hide show
  1. package/README.md +4 -3
  2. package/dist/app.d.ts +98 -3
  3. package/dist/app.js +63 -0
  4. package/dist/app.js.map +1 -1
  5. package/dist/appboundry/build.d.ts +39 -1
  6. package/dist/appboundry/build.js +57 -6
  7. package/dist/appboundry/build.js.map +1 -1
  8. package/dist/appboundry/guest.js +46 -5
  9. package/dist/appboundry/guest.js.map +1 -1
  10. package/dist/appboundry/host.d.ts +24 -5
  11. package/dist/appboundry/host.js +234 -141
  12. package/dist/appboundry/host.js.map +1 -1
  13. package/dist/appboundry/runtime.d.ts +44 -0
  14. package/dist/appboundry/runtime.js +99 -0
  15. package/dist/appboundry/runtime.js.map +1 -0
  16. package/dist/cli/entry.d.ts +1 -0
  17. package/dist/cli/entry.js +4 -0
  18. package/dist/cli/entry.js.map +1 -0
  19. package/dist/cli/main.d.ts +5 -0
  20. package/dist/cli/main.js +550 -13
  21. package/dist/cli/main.js.map +1 -1
  22. package/dist/cli/test-reporter.d.ts +9 -0
  23. package/dist/cli/test-reporter.js +26 -0
  24. package/dist/cli/test-reporter.js.map +1 -0
  25. package/dist/client/index.d.ts +3 -0
  26. package/dist/client/index.js +3 -0
  27. package/dist/client/index.js.map +1 -1
  28. package/dist/dashboard/assets/index-BSnW2DC-.js +15 -0
  29. package/dist/dashboard/assets/{index-91I1zDK-.css → index-BXTNQAg1.css} +1 -1
  30. package/dist/dashboard/index.html +3 -3
  31. package/dist/docs.d.ts +12 -0
  32. package/dist/docs.js +42 -0
  33. package/dist/docs.js.map +1 -0
  34. package/dist/errors.d.ts +15 -0
  35. package/dist/errors.js +9 -0
  36. package/dist/errors.js.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/platform/changes.d.ts +340 -0
  40. package/dist/platform/changes.js +355 -0
  41. package/dist/platform/changes.js.map +1 -0
  42. package/dist/platform/deployments.d.ts +653 -0
  43. package/dist/platform/deployments.js +532 -0
  44. package/dist/platform/deployments.js.map +1 -0
  45. package/dist/platform/operations.d.ts +74 -0
  46. package/dist/platform/operations.js +198 -0
  47. package/dist/platform/operations.js.map +1 -0
  48. package/dist/platform/platform.d.ts +78 -0
  49. package/dist/platform/platform.js +264 -0
  50. package/dist/platform/platform.js.map +1 -0
  51. package/dist/platform/server.d.ts +25 -0
  52. package/dist/platform/server.js +165 -0
  53. package/dist/platform/server.js.map +1 -0
  54. package/dist/platform/source.d.ts +27 -0
  55. package/dist/platform/source.js +142 -0
  56. package/dist/platform/source.js.map +1 -0
  57. package/dist/runtime/activity.d.ts +25 -0
  58. package/dist/runtime/activity.js +38 -12
  59. package/dist/runtime/activity.js.map +1 -1
  60. package/dist/runtime/agent.d.ts +16 -0
  61. package/dist/runtime/agent.js +92 -28
  62. package/dist/runtime/agent.js.map +1 -1
  63. package/dist/runtime/backup-environment.d.ts +32 -0
  64. package/dist/runtime/backup-environment.js +92 -0
  65. package/dist/runtime/backup-environment.js.map +1 -0
  66. package/dist/runtime/backup.d.ts +129 -0
  67. package/dist/runtime/backup.js +344 -0
  68. package/dist/runtime/backup.js.map +1 -0
  69. package/dist/runtime/capabilities.js +4 -2
  70. package/dist/runtime/capabilities.js.map +1 -1
  71. package/dist/runtime/changes.js +2 -2
  72. package/dist/runtime/changes.js.map +1 -1
  73. package/dist/runtime/contract.js +4 -3
  74. package/dist/runtime/contract.js.map +1 -1
  75. package/dist/runtime/data.d.ts +36 -5
  76. package/dist/runtime/data.js +165 -55
  77. package/dist/runtime/data.js.map +1 -1
  78. package/dist/runtime/decisions.js +2 -1
  79. package/dist/runtime/decisions.js.map +1 -1
  80. package/dist/runtime/instance.js +17 -0
  81. package/dist/runtime/instance.js.map +1 -1
  82. package/dist/runtime/integrations.js +14 -6
  83. package/dist/runtime/integrations.js.map +1 -1
  84. package/dist/runtime/loader.js +28 -4
  85. package/dist/runtime/loader.js.map +1 -1
  86. package/dist/runtime/migration-context.d.ts +25 -0
  87. package/dist/runtime/migration-context.js +69 -0
  88. package/dist/runtime/migration-context.js.map +1 -0
  89. package/dist/runtime/outbox.d.ts +6 -82
  90. package/dist/runtime/outbox.js +14 -59
  91. package/dist/runtime/outbox.js.map +1 -1
  92. package/dist/runtime/readiness.js +18 -1
  93. package/dist/runtime/readiness.js.map +1 -1
  94. package/dist/runtime/runtime.d.ts +84 -8
  95. package/dist/runtime/runtime.js +372 -131
  96. package/dist/runtime/runtime.js.map +1 -1
  97. package/dist/runtime/services.d.ts +41 -5
  98. package/dist/runtime/services.js +49 -4
  99. package/dist/runtime/services.js.map +1 -1
  100. package/dist/runtime/sessions.js +4 -3
  101. package/dist/runtime/sessions.js.map +1 -1
  102. package/dist/runtime/state-contract.d.ts +167 -0
  103. package/dist/runtime/state-contract.js +438 -0
  104. package/dist/runtime/state-contract.js.map +1 -0
  105. package/dist/runtime/transactions.d.ts +199 -0
  106. package/dist/runtime/transactions.js +246 -0
  107. package/dist/runtime/transactions.js.map +1 -0
  108. package/dist/schema.d.ts +13 -1
  109. package/dist/schema.js +21 -2
  110. package/dist/schema.js.map +1 -1
  111. package/dist/server/admin.d.ts +3 -2
  112. package/dist/server/admin.js +62 -10
  113. package/dist/server/admin.js.map +1 -1
  114. package/dist/server/index.d.ts +6 -1
  115. package/dist/server/index.js +90 -9
  116. package/dist/server/index.js.map +1 -1
  117. package/dist/server/mcp.js +1 -1
  118. package/dist/server/mcp.js.map +1 -1
  119. package/dist/server/project.d.ts +5 -0
  120. package/dist/server/project.js +13 -2
  121. package/dist/server/project.js.map +1 -1
  122. package/dist/testing/index.d.ts +10 -3
  123. package/dist/testing/index.js +33 -7
  124. package/dist/testing/index.js.map +1 -1
  125. package/docs/AGENT-OPERATIONS.md +515 -0
  126. package/docs/APPBOUNDRY.md +240 -0
  127. package/docs/ARCHITECTURE.md +126 -0
  128. package/docs/BACKUP.md +115 -0
  129. package/docs/GUARANTEES.md +457 -0
  130. package/docs/PATH-TO-PRODUCTION.md +117 -0
  131. package/docs/README.md +15 -0
  132. package/docs/SECURITY.md +182 -0
  133. package/docs/TRANSACTIONS.md +216 -0
  134. package/docs/UPSTREAM-GAPS.md +270 -0
  135. package/docs/WHY-FELTKIT.md +64 -0
  136. package/docs/assets/feltkit-logo-dark.png +0 -0
  137. package/docs/assets/feltkit-logo.png +0 -0
  138. package/package.json +10 -8
  139. package/skills/.claude-plugin/marketplace.json +1 -1
  140. package/skills/.claude-plugin/plugin.json +3 -3
  141. package/skills/feltkit-agent/SKILL.md +9 -5
  142. package/skills/feltkit-build/SKILL.md +16 -4
  143. package/skills/feltkit-data/SKILL.md +20 -3
  144. package/skills/feltkit-services/SKILL.md +13 -7
  145. package/dist/dashboard/assets/index-BhFOquA7.js +0 -15
  146. package/dist/dashboard/theme.js +0 -11
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
2
  <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rkendel1/feltkit/main/docs/assets/feltkit-logo-dark.png">
4
- <img src="https://raw.githubusercontent.com/rkendel1/feltkit/main/docs/assets/feltkit-logo.png" alt="FeltKit" width="160">
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/npm/@feltdb/feltkit/docs/assets/feltkit-logo-dark.png">
4
+ <img src="https://cdn.jsdelivr.net/npm/@feltdb/feltkit/docs/assets/feltkit-logo.png" alt="FeltKit" width="160">
5
5
  </picture>
6
6
  </p>
7
7
 
@@ -27,4 +27,5 @@ Built on [`@feltdb/core`](https://www.npmjs.com/package/@feltdb/core),
27
27
  [`@appport/services`](https://www.npmjs.com/package/@appport/services). Every component
28
28
  of a FeltKit application shares one FeltDB instance per environment.
29
29
 
30
- Documentation: https://github.com/rkendel1/concave#readme
30
+ Documentation: shipped with the package. In a project, run `npx feltkit docs` (or read
31
+ `node_modules/@feltdb/feltkit/docs/`); online: <https://cdn.jsdelivr.net/npm/@feltdb/feltkit/docs/README.md>.
package/dist/app.d.ts CHANGED
@@ -150,12 +150,62 @@ export interface FeltKitOptions {
150
150
  retain?: number;
151
151
  };
152
152
  }
153
+ /** A stored record as a migration sees it: whatever it holds now, with its id. */
154
+ export type StoredRecord = Record<string, unknown> & {
155
+ id: string;
156
+ };
157
+ /**
158
+ * What a migration works with. Reads see the migration's own earlier writes. Writes are
159
+ * staged and committed together with the new schema, or not at all. A collection is a
160
+ * definition or a name (a collection your schema no longer declares is reached by name).
161
+ */
162
+ export interface MigrationContext {
163
+ /** Every record of a collection, as stored (without `__version`). */
164
+ records(collection: CollectionDefinition | string): Promise<StoredRecord[]>;
165
+ /**
166
+ * Rewrite every record of a collection: return the record's new fields (it replaces the
167
+ * stored record), `null` to delete it, or `undefined` to leave it. Returns how many changed.
168
+ */
169
+ update(collection: CollectionDefinition | string, change: (record: StoredRecord) => Record<string, unknown> | null | undefined | Promise<Record<string, unknown> | null | undefined>): Promise<number>;
170
+ /** Create or replace one record. */
171
+ put(collection: CollectionDefinition | string, id: string, fields: Record<string, unknown>): void;
172
+ /** Delete one record. */
173
+ delete(collection: CollectionDefinition | string, id: string): void;
174
+ }
175
+ export interface MigrationDefinition {
176
+ readonly name: string;
177
+ readonly run: (m: MigrationContext) => void | Promise<void>;
178
+ }
179
+ /** A unique constraint: no two records hold the same values in `fields`. */
180
+ export type UniqueDeclaration = readonly string[] | {
181
+ readonly fields: readonly string[];
182
+ readonly sparse?: boolean;
183
+ readonly name?: string;
184
+ };
185
+ export interface CollectionOptions {
186
+ description?: string;
187
+ /**
188
+ * Unique constraints, enforced by FeltDB at commit (a duplicate is CONFLICT). A missing
189
+ * value counts as null and two nulls collide, unless `sparse: true`.
190
+ */
191
+ unique?: ReadonlyArray<UniqueDeclaration>;
192
+ /** Query indexes FeltDB uses for `ctx.db.query` (no constraint). */
193
+ indexes?: ReadonlyArray<{
194
+ readonly name?: string;
195
+ readonly fields: readonly string[];
196
+ }>;
197
+ }
153
198
  export interface CollectionDefinition<S extends ShapeInput = ShapeInput> {
154
199
  readonly [COLLECTION]: true;
155
200
  readonly name: string;
156
201
  readonly shape: S;
157
202
  readonly schema: Schema;
158
203
  readonly description?: string;
204
+ readonly unique?: ReadonlyArray<UniqueDeclaration>;
205
+ readonly indexes?: ReadonlyArray<{
206
+ readonly name?: string;
207
+ readonly fields: readonly string[];
208
+ }>;
159
209
  /** Type-only marker. */
160
210
  readonly $doc?: Doc<S>;
161
211
  }
@@ -252,6 +302,24 @@ export interface FunctionConfig<Kind extends FunctionKind, A extends ShapeInput,
252
302
  description?: string;
253
303
  /** Publish this function as an AppPort capability (discoverable by agents and other apps). */
254
304
  capability?: CapabilityExposure | string;
305
+ /**
306
+ * Mutations only, opt-in: when the commit is refused because another mutation advanced a
307
+ * `ctx.db.sequence` this one drew from, re-run the handler (at most `sequenceConflicts` more
308
+ * times) instead of answering CONFLICT. Only an attempt that used no `ctx.services` is re-run
309
+ * (`ctx.afterCommit` is part of the transaction). Opting in states that the handler is safe to
310
+ * run again: FeltKit cannot see effects it makes outside FeltKit (a fetch). See docs/TRANSACTIONS.md.
311
+ */
312
+ retry?: {
313
+ sequenceConflicts: number;
314
+ };
315
+ /**
316
+ * Mutations only. `"required"`: an agent, service or API key may never run it directly, on any
317
+ * interface (HTTP, AppPort, MCP, a job it queued). It may discover it and propose it
318
+ * (`feltkit_agent_propose`); the proposal runs only after a person approves it, as the
319
+ * proposer, with the proposer's own permissions (`access` still applies to it and to the
320
+ * approver). People call it directly. See docs/GUARANTEES.md (Agents).
321
+ */
322
+ approval?: "required";
255
323
  handler: (ctx: Kind extends "query" ? QueryCtx : MutationCtx, args: Simplify<InferShape<A>>) => R | Promise<R>;
256
324
  }
257
325
  export interface FunctionDefinition<Kind extends FunctionKind = FunctionKind, Args = any, Result = any> {
@@ -265,6 +333,12 @@ export interface FunctionDefinition<Kind extends FunctionKind = FunctionKind, Ar
265
333
  readonly capability?: Required<Pick<CapabilityExposure, "name" | "version">> & {
266
334
  description?: string;
267
335
  };
336
+ /** Opt-in re-execution on sequence contention (mutations). */
337
+ readonly retry?: {
338
+ readonly sequenceConflicts: number;
339
+ };
340
+ /** Non-person callers need an approved proposal (mutations). */
341
+ readonly approval?: "required";
268
342
  readonly handler: (ctx: any, args: any) => unknown;
269
343
  readonly app: FeltKitApp;
270
344
  /** Type-only markers. */
@@ -275,16 +349,37 @@ export type QueryDefinition<Args = any, Result = any> = FunctionDefinition<"quer
275
349
  export type MutationDefinition<Args = any, Result = any> = FunctionDefinition<"mutation", Args, Result>;
276
350
  type Handler<Kind extends FunctionKind, R> = (ctx: Kind extends "query" ? QueryCtx : MutationCtx) => R | Promise<R>;
277
351
  export declare class FeltKitApp {
352
+ #private;
278
353
  readonly [APP] = true;
279
354
  readonly options: Readonly<FeltKitOptions>;
280
355
  readonly collections: Map<string, CollectionDefinition<ShapeInput>>;
281
356
  readonly integrations: Map<string, IntegrationDefinition<Record<string, IntegrationOperation>>>;
357
+ /** Data migrations, in declaration order (see `migration`). */
358
+ readonly migrations: MigrationDefinition[];
282
359
  constructor(options: FeltKitOptions);
283
360
  get name(): string;
361
+ /**
362
+ * The application's version: `feltkit({ version })`, else the project's package.json
363
+ * `version` (set by the loader), else "0.0.0". Reported by inspect, MCP, AppPort and backups.
364
+ */
365
+ get version(): string;
366
+ /** @internal The loader records the project's package.json version. */
367
+ useProjectVersion(version: string | undefined): void;
284
368
  /** Declare a collection of records stored in the application's FeltDB instance. */
285
- collection<S extends ShapeInput>(name: string, shape: S, options?: {
286
- description?: string;
287
- }): CollectionDefinition<S>;
369
+ collection<S extends ShapeInput>(name: string, shape: S, options?: CollectionOptions): CollectionDefinition<S>;
370
+ /**
371
+ * A data migration: code that rewrites stored records so they satisfy the schema your
372
+ * collections now declare (a new required field, a changed type, a removed field or
373
+ * collection). It runs once, in the same FeltDB transaction that installs the new schema:
374
+ * if any record would still violate it, nothing is written and the previous schema and
375
+ * data stay as they were. Applied by `feltkit migrate` (and by `feltkit dev` when you save).
376
+ *
377
+ * app.migration("tasks get a priority", (m) =>
378
+ * m.update(tasks, (task) => ({ ...task, priority: "normal" })));
379
+ *
380
+ * The name is its identity: never rename or edit a migration once it ran somewhere.
381
+ */
382
+ migration(name: string, run: (m: MigrationContext) => void | Promise<void>): MigrationDefinition;
288
383
  /**
289
384
  * Connect an existing HTTP API. Each operation becomes an AppPort capability named
290
385
  * `<integration>.<operation>`, with its effect, the permission that may invoke it,
package/dist/app.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { validateName } from "@appport/protocol";
2
2
  import { RESERVED_FIELDS, shapeToObjectSchema } from "./schema.js";
3
+ import { checkRetryPolicy } from "./runtime/transactions.js";
3
4
  const APP = Symbol.for("feltkit.app");
4
5
  const COLLECTION = Symbol.for("feltkit.collection");
5
6
  const FUNCTION = Symbol.for("feltkit.function");
@@ -41,6 +42,8 @@ export class FeltKitApp {
41
42
  options;
42
43
  collections = new Map();
43
44
  integrations = new Map();
45
+ /** Data migrations, in declaration order (see `migration`). */
46
+ migrations = [];
44
47
  constructor(options) {
45
48
  if (!options || typeof options.name !== "string" || !/^[a-z][a-z0-9-]{0,62}$/.test(options.name)) {
46
49
  throw new TypeError(`feltkit({ name }) needs a lowercase name of letters, digits, and dashes (got ${JSON.stringify(options?.name)}).`);
@@ -109,6 +112,19 @@ export class FeltKitApp {
109
112
  get name() {
110
113
  return this.options.name;
111
114
  }
115
+ #projectVersion;
116
+ /**
117
+ * The application's version: `feltkit({ version })`, else the project's package.json
118
+ * `version` (set by the loader), else "0.0.0". Reported by inspect, MCP, AppPort and backups.
119
+ */
120
+ get version() {
121
+ return this.options.version ?? this.#projectVersion ?? "0.0.0";
122
+ }
123
+ /** @internal The loader records the project's package.json version. */
124
+ useProjectVersion(version) {
125
+ if (typeof version === "string" && version)
126
+ this.#projectVersion = version;
127
+ }
112
128
  /** Declare a collection of records stored in the application's FeltDB instance. */
113
129
  collection(name, shape, options = {}) {
114
130
  if (!/^[a-z][a-zA-Z0-9_]{0,62}$/.test(name)) {
@@ -123,16 +139,52 @@ export class FeltKitApp {
123
139
  if (field in shape)
124
140
  throw new TypeError(`Collection "${name}" may not declare "${field}"; FeltDB manages it.`);
125
141
  }
142
+ const known = (fields, what) => {
143
+ if (!Array.isArray(fields) || !fields.length)
144
+ throw new TypeError(`Collection "${name}": each ${what} needs a non-empty list of fields.`);
145
+ for (const field of fields)
146
+ if (!(field in shape))
147
+ throw new TypeError(`Collection "${name}": ${what} names "${field}", which the collection does not declare.`);
148
+ };
149
+ for (const unique of options.unique ?? [])
150
+ known(Array.isArray(unique) ? unique : unique.fields, "unique constraint");
151
+ for (const index of options.indexes ?? [])
152
+ known(index.fields, "index");
126
153
  const definition = {
127
154
  [COLLECTION]: true,
128
155
  name,
129
156
  shape,
130
157
  schema: shapeToObjectSchema(shape),
131
158
  ...(options.description ? { description: options.description } : {}),
159
+ ...(options.unique?.length ? { unique: options.unique.map((u) => (Array.isArray(u) ? [...u] : { ...u })) } : {}),
160
+ ...(options.indexes?.length ? { indexes: options.indexes.map((i) => ({ ...i, fields: [...i.fields] })) } : {}),
132
161
  };
133
162
  this.collections.set(name, definition);
134
163
  return definition;
135
164
  }
165
+ /**
166
+ * A data migration: code that rewrites stored records so they satisfy the schema your
167
+ * collections now declare (a new required field, a changed type, a removed field or
168
+ * collection). It runs once, in the same FeltDB transaction that installs the new schema:
169
+ * if any record would still violate it, nothing is written and the previous schema and
170
+ * data stay as they were. Applied by `feltkit migrate` (and by `feltkit dev` when you save).
171
+ *
172
+ * app.migration("tasks get a priority", (m) =>
173
+ * m.update(tasks, (task) => ({ ...task, priority: "normal" })));
174
+ *
175
+ * The name is its identity: never rename or edit a migration once it ran somewhere.
176
+ */
177
+ migration(name, run) {
178
+ if (typeof name !== "string" || !name.trim() || name.length > 200)
179
+ throw new TypeError("app.migration() needs a name (1-200 characters): it is the migration's identity.");
180
+ if (typeof run !== "function")
181
+ throw new TypeError(`app.migration("${name}") needs a function.`);
182
+ if (this.migrations.some((m) => m.name === name))
183
+ throw new TypeError(`Migration "${name}" is declared twice.`);
184
+ const definition = Object.freeze({ name, run });
185
+ this.migrations.push(definition);
186
+ return definition;
187
+ }
136
188
  /**
137
189
  * Connect an existing HTTP API. Each operation becomes an AppPort capability named
138
190
  * `<integration>.<operation>`, with its effect, the permission that may invoke it,
@@ -207,9 +259,20 @@ export class FeltKitApp {
207
259
  ...((exposure.description ?? config.description) ? { description: exposure.description ?? config.description } : {}),
208
260
  };
209
261
  }
262
+ const retry = checkRetryPolicy(config.retry, kind);
263
+ if (config.approval !== undefined) {
264
+ if (config.approval !== "required")
265
+ throw new TypeError(`approval must be "required" (or omitted); got ${JSON.stringify(config.approval)}.`);
266
+ if (kind !== "mutation")
267
+ throw new TypeError("approval: \"required\" applies to mutations: a query changes nothing, so there is nothing to approve.");
268
+ if (config.access === "public")
269
+ throw new TypeError("approval: \"required\" needs an access permission: an approval never grants one, and a public function has none to check.");
270
+ }
210
271
  return Object.freeze({
211
272
  [FUNCTION]: true,
212
273
  kind,
274
+ ...(retry ? { retry: Object.freeze(retry) } : {}),
275
+ ...(config.approval ? { approval: config.approval } : {}),
213
276
  args,
214
277
  argsSchema: shapeToObjectSchema(args),
215
278
  ...(config.returns ? { returns: config.returns } : {}),
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAA6D,MAAM,aAAa,CAAC;AAG9H,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACtC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC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I,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC9I,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,+BAA+B,CAAC;IAClG,OAAO,sHAAsH,OAAO,EAAE,CAAC;AACzI,CAAC"}
@@ -1,6 +1,9 @@
1
1
  import type { FeltKitApp } from "../app.js";
2
+ import type { LoadedProject } from "../runtime/runtime.js";
2
3
  import { GUEST_ABI } from "./guest.js";
3
4
  export declare const ARTIFACT_FORMAT = "appboundry.app/1";
5
+ /** How an artifact lists its migrations (manifest `state.migrations`). */
6
+ export declare const MIGRATIONS_FORMAT = "appboundry.migrations/1";
4
7
  /** Host interfaces the program uses, with the version of each. */
5
8
  export declare const HOST_INTERFACES: {
6
9
  readonly collections: 1;
@@ -8,6 +11,14 @@ export declare const HOST_INTERFACES: {
8
11
  readonly identity: 1;
9
12
  readonly web: 1;
10
13
  };
14
+ /**
15
+ * Optional host interfaces, required only by an artifact that uses them: `migrations@1`
16
+ * (app.migration()) and `transactions@1` (ctx.db.sequence, ctx.afterCommit; docs/TRANSACTIONS.md).
17
+ */
18
+ export type OptionalInterfaces = {
19
+ migrations?: 1;
20
+ transactions?: 1;
21
+ };
11
22
  export interface AppBoundryBuildResult {
12
23
  path: string;
13
24
  manifest: ArtifactManifest;
@@ -18,7 +29,7 @@ export interface ArtifactManifest {
18
29
  format: typeof ARTIFACT_FORMAT;
19
30
  runtime: {
20
31
  abi: typeof GUEST_ABI;
21
- interfaces: typeof HOST_INTERFACES;
32
+ interfaces: typeof HOST_INTERFACES & OptionalInterfaces;
22
33
  };
23
34
  producer: {
24
35
  name: "feltkit";
@@ -52,12 +63,32 @@ export interface ArtifactManifest {
52
63
  name: string;
53
64
  version: number;
54
65
  };
66
+ retry?: {
67
+ sequenceConflicts: number;
68
+ };
55
69
  }>;
56
70
  collections: Array<{
57
71
  name: string;
58
72
  schema: unknown;
59
73
  description?: string;
60
74
  }>;
75
+ /**
76
+ * The FeltDB state contract the collections compile to (s.ref references, unique
77
+ * constraints, indexes), at version 1. The host installs it, and evolves the store to a new
78
+ * artifact's contract only when every stored record satisfies it (see docs/APPBOUNDRY.md).
79
+ */
80
+ state: {
81
+ contract: unknown;
82
+ /**
83
+ * The application's `app.migration()`s, in declaration order: the order a host runs the
84
+ * pending ones in, inside the evolution that installs the contract. Their code is in the
85
+ * program (guest invocation `{ migration: name }`, host interface migrations@1).
86
+ */
87
+ migrations?: {
88
+ format: typeof MIGRATIONS_FORMAT;
89
+ order: string[];
90
+ };
91
+ };
61
92
  identity: {
62
93
  roles: Record<string, string[]>;
63
94
  devUsers: Array<{
@@ -94,6 +125,13 @@ export interface ArtifactManifest {
94
125
  export declare function enginePath(): string;
95
126
  /** Uses of FeltKit features an artifact cannot provide, with their source location. */
96
127
  export declare function unsupportedUses(projectDir: string, app: FeltKitApp): string[];
128
+ /**
129
+ * Whether the application uses ctx.db.sequence or ctx.afterCommit (or opts a mutation into
130
+ * sequence retries): such an artifact requires the host interface transactions@1. Found the way
131
+ * unsupported uses are, in the backend sources without comments and strings; the guest also asks
132
+ * the host for those operations by name, so a host without the interface refuses them.
133
+ */
134
+ export declare function usesTransactions(projectDir: string, project: LoadedProject): boolean;
97
135
  /**
98
136
  * Compile a built project (after `build()`: .feltkit/build/functions.mjs and dist/client)
99
137
  * into `<outDir>/<name>.app`.
@@ -23,10 +23,13 @@ import { dirname, extname, join, relative, resolve } from "node:path";
23
23
  import { fileURLToPath } from "node:url";
24
24
  import { FeltKitError } from "../errors.js";
25
25
  import { capabilityDefinition } from "../runtime/capabilities.js";
26
+ import { compileStateContract } from "../runtime/state-contract.js";
26
27
  import { backendModules, loadBundle } from "../runtime/loader.js";
27
28
  import { GUEST_ABI } from "./guest.js";
28
29
  import { appendCustomSection, customSections, PROGRAM_SECTION } from "./wasm.js";
29
30
  export const ARTIFACT_FORMAT = "appboundry.app/1";
31
+ /** How an artifact lists its migrations (manifest `state.migrations`). */
32
+ export const MIGRATIONS_FORMAT = "appboundry.migrations/1";
30
33
  /** Host interfaces the program uses, with the version of each. */
31
34
  export const HOST_INTERFACES = { collections: 1, services: 1, identity: 1, web: 1 };
32
35
  const HERE = dirname(fileURLToPath(import.meta.url));
@@ -42,6 +45,7 @@ export function enginePath() {
42
45
  function codeOnly(source) {
43
46
  return source.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|`(?:\\[\s\S]|[^\\`])*`|"(?:\\.|[^\\"\n])*"|'(?:\\.|[^\\'\n])*'/g, (match) => match.replace(/[^\n]/g, " "));
44
47
  }
48
+ const APPROVAL_WHY = 'approval: "required" is enforced by FeltKit\'s agent lifecycle (proposals and approvals), which an artifact does not run: an agent or service could call the mutation directly. Run this application with FeltKit, or remove the requirement before building for AppBoundry.';
45
49
  const AGENT_WHY = "ctx.agent starts work for FeltKit's agent, which runs in the FeltKit server, not in an artifact. Keep agent work in a FeltKit deployment, or remove it before building for AppBoundry.";
46
50
  const UNSAFE_WHY = "ctx.unsafe.feltdb writes FeltDB directly, around the host's validation and transactions. An artifact's state is reached only through ctx.db; use ctx.db instead.";
47
51
  const LOCALE_WHY = (what) => `${what} depends on locale data (Intl), which the artifact's guest engine does not include: it would format or compare differently than under feltkit dev and feltkit test, so the artifact refuses it at run time. Format in the frontend, or with explicit code (toFixed, your own digit grouping, < and > for ordering).`;
@@ -59,20 +63,34 @@ function contextNames(code) {
59
63
  return names;
60
64
  }
61
65
  const escape = (name) => name.replace(/[$]/g, "\\$");
66
+ /**
67
+ * Every backend source file the artifact can contain: the function modules and the
68
+ * `feltkit/_*.ts` helpers they import (the loader skips those as function modules, but they
69
+ * are bundled), in subdirectories too. Not `_generated/`, tests, or declaration files.
70
+ */
71
+ function backendSources(projectDir) {
72
+ const root = join(resolve(projectDir), "feltkit");
73
+ backendModules(projectDir); // the same "no feltkit/ directory" error
74
+ const walk = (dir) => readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
75
+ const path = join(dir, entry.name);
76
+ if (entry.isDirectory())
77
+ return entry.name === "_generated" || entry.name === "node_modules" || entry.name.startsWith(".") ? [] : walk(path);
78
+ return /\.(ts|mts|js|mjs)$/.test(entry.name) && !entry.name.endsWith(".d.ts") && !/\.(test|spec)\.[mc]?[jt]s$/.test(entry.name) ? [path] : [];
79
+ });
80
+ return walk(root).sort().map((path) => ({ path }));
81
+ }
62
82
  /** Uses of FeltKit features an artifact cannot provide, with their source location. */
63
83
  export function unsupportedUses(projectDir, app) {
64
84
  const problems = [];
65
- for (const module of backendModules(projectDir)) {
85
+ for (const module of backendSources(projectDir)) {
66
86
  const code = codeOnly(readFileSync(module.path, "utf8"));
67
87
  const context = [...contextNames(code)].map(escape).join("|");
68
88
  // Only the handler context's `agent` and `unsafe`: `roles.agent` or `req.agent` is not a use.
69
89
  const checks = [
70
90
  [new RegExp(`(?<![\\w$.])(?:${context})\\s*\\.\\s*unsafe\\b`, "g"), UNSAFE_WHY],
71
91
  [new RegExp(`(?<![\\w$.])(?:${context})\\s*\\.\\s*agent\\b`, "g"), AGENT_WHY],
72
- [new RegExp(`(?<![\\w$.])(?:${context})\\s*\\.\\s*afterCommit\\b`, "g"), "ctx.afterCommit records effects in a FeltKit outbox performed by the FeltKit server after commit; the AppBoundry host has no outbox yet. Use ctx.services.* in an artifact, or keep this application on a FeltKit server."],
73
92
  [/\bhandler\s*(?::\s*(?:async\s*)?(?:function\s*\w*\s*)?)?\(\s*\{[^}]*\bunsafe\b/g, UNSAFE_WHY],
74
93
  [/\bhandler\s*(?::\s*(?:async\s*)?(?:function\s*\w*\s*)?)?\(\s*\{[^}]*\bagent\b/g, AGENT_WHY],
75
- [/\bdb\s*\.\s*sequence\s*\(/g, "ctx.db.sequence() is a FeltKit-managed counter committed with the mutation; the AppBoundry host has no sequence operation yet. Keep this application on a FeltKit server, or order by your own field."],
76
94
  [/(?<![\w$.])Intl\s*\./g, LOCALE_WHY("Intl")],
77
95
  [/\.\s*(toLocaleString|toLocaleDateString|toLocaleTimeString)\s*\(/g, LOCALE_WHY("toLocaleString()")],
78
96
  [/\.\s*localeCompare\s*\(/g, LOCALE_WHY("localeCompare()")],
@@ -85,6 +103,13 @@ export function unsupportedUses(projectDir, app) {
85
103
  }
86
104
  }
87
105
  }
106
+ // Strings are blanked in `code`, so this one reads the source without its comments.
107
+ for (const module of backendSources(projectDir)) {
108
+ const source = readFileSync(module.path, "utf8").replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, (match) => match.replace(/[^\n]/g, " "));
109
+ for (const match of source.matchAll(/\bapproval\s*:\s*["'`]required["'`]/g)) {
110
+ problems.push(`${relative(projectDir, module.path)}:${source.slice(0, match.index).split("\n").length}: ${APPROVAL_WHY}`);
111
+ }
112
+ }
88
113
  if (app.integrations.size) {
89
114
  problems.push(`app.integration(${[...app.integrations.keys()].map((n) => JSON.stringify(n)).join(", ")}): integrations call external HTTP APIs, and an artifact has no network access. Run this application with FeltKit, or remove the integration.`);
90
115
  }
@@ -93,6 +118,21 @@ export function unsupportedUses(projectDir, app) {
93
118
  }
94
119
  return problems;
95
120
  }
121
+ /**
122
+ * Whether the application uses ctx.db.sequence or ctx.afterCommit (or opts a mutation into
123
+ * sequence retries): such an artifact requires the host interface transactions@1. Found the way
124
+ * unsupported uses are, in the backend sources without comments and strings; the guest also asks
125
+ * the host for those operations by name, so a host without the interface refuses them.
126
+ */
127
+ export function usesTransactions(projectDir, project) {
128
+ if ([...project.functions.values()].some((fn) => fn.retry))
129
+ return true;
130
+ return backendSources(projectDir).some((module) => {
131
+ const code = codeOnly(readFileSync(module.path, "utf8"));
132
+ // Conservative: any `afterCommit` or `.sequence(` (a false positive only requires a newer host).
133
+ return /\bafterCommit\b/.test(code) || /\.\s*sequence\s*\(/.test(code);
134
+ });
135
+ }
96
136
  function contentType(path) {
97
137
  const types = {
98
138
  ".html": "text/html; charset=utf-8",
@@ -196,6 +236,9 @@ async function verifyModule(module, project) {
196
236
  const built = [...project.functions.entries()].map(([name, fn]) => `${name}/${fn.kind}`).sort().join(",");
197
237
  if (inGuest !== built)
198
238
  throw new FeltKitError("INTERNAL", `The compiled program defines different functions than the build:\n guest: ${inGuest}\n build: ${built}`);
239
+ const migrations = project.app.migrations.map((m) => m.name).join(",");
240
+ if ((described.migrations ?? []).join(",") !== migrations)
241
+ throw new FeltKitError("INTERNAL", `The compiled program declares different migrations than the build:\n guest: ${(described.migrations ?? []).join(",")}\n build: ${migrations}`);
199
242
  }
200
243
  function servicesManifest(app) {
201
244
  const config = app.options.services ?? {};
@@ -237,6 +280,7 @@ function functionsManifest(project) {
237
280
  args: fn.argsSchema.toJSONSchema(),
238
281
  ...(fn.returns ? { returns: fn.returns.toJSONSchema() } : {}),
239
282
  ...(fn.capability ? { capability: { name: fn.capability.name, version: fn.capability.version } } : {}),
283
+ ...(fn.retry ? { retry: { sequenceConflicts: fn.retry.sequenceConflicts } } : {}),
240
284
  }));
241
285
  }
242
286
  async function appportContract(project) {
@@ -247,7 +291,7 @@ async function appportContract(project) {
247
291
  throw new Error("contract only");
248
292
  }));
249
293
  const application = createApplication({
250
- application: { id: app.name, name: app.name, version: app.options.version ?? "0.0.0", ...(app.options.description ? { description: app.options.description } : {}) },
294
+ application: { id: app.name, name: app.name, version: app.version, ...(app.options.description ? { description: app.options.description } : {}) },
251
295
  capabilities,
252
296
  });
253
297
  return JSON.parse(JSON.stringify(await application.manifest()));
@@ -305,12 +349,19 @@ export async function buildAppBoundry(projectDirInput, options) {
305
349
  const writable = [...project.functions.values()].some((fn) => fn.kind === "mutation");
306
350
  const manifest = {
307
351
  format: ARTIFACT_FORMAT,
308
- runtime: { abi: GUEST_ABI, interfaces: HOST_INTERFACES },
352
+ runtime: {
353
+ abi: GUEST_ABI,
354
+ interfaces: { ...HOST_INTERFACES, ...(app.migrations.length ? { migrations: 1 } : {}), ...(usesTransactions(projectDir, project) ? { transactions: 1 } : {}) },
355
+ },
309
356
  producer: { name: "feltkit", version: options.producerVersion },
310
- application: { id: app.name, name: app.name, version: app.options.version ?? "0.0.0", ...(app.options.description ? { description: app.options.description } : {}) },
357
+ application: { id: app.name, name: app.name, version: app.version, ...(app.options.description ? { description: app.options.description } : {}) },
311
358
  module: { path: "module.wasm", sha256: sha256(module), size: module.byteLength, imports: [], program: { section: PROGRAM_SECTION, sha256: sha256(program), size: program.byteLength } },
312
359
  functions: functionsManifest(project),
313
360
  collections,
361
+ state: {
362
+ contract: compileStateContract(app, 1, { services: false }).document,
363
+ ...(app.migrations.length ? { migrations: { format: MIGRATIONS_FORMAT, order: app.migrations.map((m) => m.name) } } : {}),
364
+ },
314
365
  identity: {
315
366
  roles: Object.fromEntries(Object.entries(app.options.roles ?? {}).map(([role, permissions]) => [role, [...permissions]])),
316
367
  devUsers: (app.options.dev?.users ?? []).map((u) => ({ id: u.id, name: u.name ?? u.id, roles: [...u.roles], type: u.type ?? "user" })),