@fungi.computer/puffball 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-api.js +9 -9
- package/dist/app-backend-binding-vocabulary.d.ts +33 -5
- package/dist/app-backend-binding-vocabulary.js +33 -5
- package/dist/app-backend-bindings.d.ts +1 -1
- package/dist/app-declaration.d.ts +1 -1
- package/dist/app-vocabulary.d.ts +27 -6
- package/dist/app-vocabulary.js +1 -0
- package/dist/cloudflare.d.ts +61 -0
- package/dist/cloudflare.js +88 -0
- package/dist/internal/app-release-schema.d.ts +6 -5
- package/dist/internal/public-website-authority.d.ts +3 -4
- package/docs/api/app-backend-binding-vocabulary.md +224 -188
- package/docs/api/app-backend-bindings.md +5 -5
- package/docs/api/app-event-facts.md +1 -1
- package/docs/api/app-method-runtime.md +8 -6
- package/docs/api/background-replay.md +51 -45
- package/docs/api/cloudflare.md +122 -0
- package/docs/api/git-representation.md +1 -1
- package/docs/api/inbox.md +1 -1
- package/docs/api/index.md +49 -4
- package/package.json +4 -4
package/dist/app-api.js
CHANGED
|
@@ -4,13 +4,17 @@ import { isAppApiMethodName } from "./app-method-runtime.js";
|
|
|
4
4
|
export { appApiReservedMethodNames } from "./app-method-runtime.js";
|
|
5
5
|
/** Public method names, including grouped operations such as desktop.arrange. A name cannot also be a group (`files` with `files.read`). */
|
|
6
6
|
export const appApiMethodNameSchema = Schema.String.check(Schema.makeFilter(isAppApiMethodName));
|
|
7
|
+
/** Distinguish containers only after the owning JSON decoder has succeeded. */
|
|
8
|
+
function isJsonContainer(value) {
|
|
9
|
+
return value !== null && typeof value === "object";
|
|
10
|
+
}
|
|
7
11
|
function withinDepth(value, depth = 0) {
|
|
8
12
|
if (depth > 16)
|
|
9
13
|
return false;
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
if (isJsonContainer(value))
|
|
15
|
+
for (const child of Object.values(value))
|
|
16
|
+
if (!withinDepth(child, depth + 1))
|
|
17
|
+
return false;
|
|
14
18
|
return true;
|
|
15
19
|
}
|
|
16
20
|
/** JSON Schema projections are data, bounded before a renderer or compiler reads them. */
|
|
@@ -23,16 +27,12 @@ const method = Schema.Struct({
|
|
|
23
27
|
output: projection,
|
|
24
28
|
pending: Schema.optional(Schema.Literal(true)),
|
|
25
29
|
hidden: Schema.optional(Schema.Literal(true)),
|
|
26
|
-
anonymous: Schema.optional(Schema.Literal(true)),
|
|
27
30
|
present: Schema.optional(Schema.Struct({
|
|
28
31
|
verb: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(32)),
|
|
29
32
|
})),
|
|
30
33
|
effect: Schema.Literals(["read", "write", "external"]),
|
|
31
34
|
requires: Schema.Array(Schema.Literals(appCapabilityIds)).pipe(Schema.check(Schema.makeFilter((values) => new Set(values).size === values.length))),
|
|
32
|
-
})
|
|
33
|
-
(value.effect === "read" && value.requires.length === 0), {
|
|
34
|
-
message: "Anonymous methods must be reads with no required capabilities",
|
|
35
|
-
}));
|
|
35
|
+
});
|
|
36
36
|
/** The build-generated, digest-covered method and event catalog; it grants no authority. */
|
|
37
37
|
export const appApiSchema = Schema.Struct({
|
|
38
38
|
methods: Schema.Record(Schema.String, method).pipe(Schema.check(Schema.makeFilter((methods) => Object.keys(methods).every(Schema.is(appApiMethodNameSchema)), { message: "Invalid App API method name" })), Schema.check(Schema.makeFilter((methods) => Object.keys(methods).length <= 64)), Schema.check(Schema.makeFilter((methods) => {
|
|
@@ -60,6 +60,19 @@ export declare const appBackendBindingKinds: {
|
|
|
60
60
|
readonly APPS: {
|
|
61
61
|
readonly name: "APPS";
|
|
62
62
|
readonly operations: {
|
|
63
|
+
/** Register the calling installation's repository as an App from its
|
|
64
|
+
* exact main manifest. No Computer execution or installation is implied. */
|
|
65
|
+
readonly register: {
|
|
66
|
+
readonly cap: "app.register";
|
|
67
|
+
readonly requires: readonly ["git.repository"];
|
|
68
|
+
readonly effect: "write";
|
|
69
|
+
};
|
|
70
|
+
/** Read the captured installation's registered repository identity. */
|
|
71
|
+
readonly repository: {
|
|
72
|
+
readonly cap: "app.catalog.read";
|
|
73
|
+
readonly requires: readonly ["git.repository"];
|
|
74
|
+
readonly effect: "read";
|
|
75
|
+
};
|
|
63
76
|
readonly build: {
|
|
64
77
|
readonly cap: "app.build";
|
|
65
78
|
readonly requires: readonly ["git.repository", "computer.execute"];
|
|
@@ -120,6 +133,11 @@ export declare const appBackendBindingKinds: {
|
|
|
120
133
|
readonly requires: readonly ["workflow.run", "workflow.arm"];
|
|
121
134
|
readonly effect: "write";
|
|
122
135
|
};
|
|
136
|
+
readonly pauseSchedule: {
|
|
137
|
+
readonly cap: "app.workflow.run";
|
|
138
|
+
readonly requires: readonly ["workflow.run", "workflow.arm"];
|
|
139
|
+
readonly effect: "write";
|
|
140
|
+
};
|
|
123
141
|
readonly schedules: {
|
|
124
142
|
readonly cap: "app.workflow.read";
|
|
125
143
|
readonly requires: readonly ["workflow.run"];
|
|
@@ -228,11 +246,6 @@ export declare const appBackendBindingKinds: {
|
|
|
228
246
|
readonly requires: readonly ["computer.writeFile"];
|
|
229
247
|
readonly effect: "write";
|
|
230
248
|
};
|
|
231
|
-
readonly workflowGitPass: {
|
|
232
|
-
readonly cap: "app.computer.exec";
|
|
233
|
-
readonly requires: readonly ["computer.execute"];
|
|
234
|
-
readonly effect: "write";
|
|
235
|
-
};
|
|
236
249
|
readonly preview: {
|
|
237
250
|
readonly cap: "app.computer.exec";
|
|
238
251
|
readonly requires: readonly ["computer.execute"];
|
|
@@ -283,6 +296,21 @@ export declare const appBackendBindingKinds: {
|
|
|
283
296
|
readonly requires: readonly ["agent.send"];
|
|
284
297
|
readonly effect: "write";
|
|
285
298
|
};
|
|
299
|
+
readonly schedules: {
|
|
300
|
+
readonly cap: "agent.read";
|
|
301
|
+
readonly requires: readonly ["agent.read"];
|
|
302
|
+
readonly effect: "read";
|
|
303
|
+
};
|
|
304
|
+
readonly pauseSchedule: {
|
|
305
|
+
readonly cap: "agent.manage";
|
|
306
|
+
readonly requires: readonly ["agent.manage"];
|
|
307
|
+
readonly effect: "write";
|
|
308
|
+
};
|
|
309
|
+
readonly deleteSchedule: {
|
|
310
|
+
readonly cap: "agent.manage";
|
|
311
|
+
readonly requires: readonly ["agent.manage"];
|
|
312
|
+
readonly effect: "write";
|
|
313
|
+
};
|
|
286
314
|
};
|
|
287
315
|
};
|
|
288
316
|
};
|
|
@@ -49,6 +49,19 @@ export const appBackendBindingKinds = {
|
|
|
49
49
|
APPS: {
|
|
50
50
|
name: "APPS",
|
|
51
51
|
operations: {
|
|
52
|
+
/** Register the calling installation's repository as an App from its
|
|
53
|
+
* exact main manifest. No Computer execution or installation is implied. */
|
|
54
|
+
register: {
|
|
55
|
+
cap: "app.register",
|
|
56
|
+
requires: ["git.repository"],
|
|
57
|
+
effect: "write",
|
|
58
|
+
},
|
|
59
|
+
/** Read the captured installation's registered repository identity. */
|
|
60
|
+
repository: {
|
|
61
|
+
cap: "app.catalog.read",
|
|
62
|
+
requires: ["git.repository"],
|
|
63
|
+
effect: "read",
|
|
64
|
+
},
|
|
52
65
|
build: {
|
|
53
66
|
cap: "app.build",
|
|
54
67
|
requires: ["git.repository", "computer.execute"],
|
|
@@ -109,6 +122,11 @@ export const appBackendBindingKinds = {
|
|
|
109
122
|
requires: ["workflow.run", "workflow.arm"],
|
|
110
123
|
effect: "write",
|
|
111
124
|
},
|
|
125
|
+
pauseSchedule: {
|
|
126
|
+
cap: "app.workflow.run",
|
|
127
|
+
requires: ["workflow.run", "workflow.arm"],
|
|
128
|
+
effect: "write",
|
|
129
|
+
},
|
|
112
130
|
schedules: {
|
|
113
131
|
cap: "app.workflow.read",
|
|
114
132
|
requires: ["workflow.run"],
|
|
@@ -217,11 +235,6 @@ export const appBackendBindingKinds = {
|
|
|
217
235
|
requires: ["computer.writeFile"],
|
|
218
236
|
effect: "write",
|
|
219
237
|
},
|
|
220
|
-
workflowGitPass: {
|
|
221
|
-
cap: "app.computer.exec",
|
|
222
|
-
requires: ["computer.execute"],
|
|
223
|
-
effect: "write",
|
|
224
|
-
},
|
|
225
238
|
preview: {
|
|
226
239
|
cap: "app.computer.exec",
|
|
227
240
|
requires: ["computer.execute"],
|
|
@@ -256,6 +269,21 @@ export const appBackendBindingKinds = {
|
|
|
256
269
|
operations: {
|
|
257
270
|
list: { cap: "agent.list", requires: ["agent.list"], effect: "read" },
|
|
258
271
|
send: { cap: "agent.send", requires: ["agent.send"], effect: "write" },
|
|
272
|
+
schedules: {
|
|
273
|
+
cap: "agent.read",
|
|
274
|
+
requires: ["agent.read"],
|
|
275
|
+
effect: "read",
|
|
276
|
+
},
|
|
277
|
+
pauseSchedule: {
|
|
278
|
+
cap: "agent.manage",
|
|
279
|
+
requires: ["agent.manage"],
|
|
280
|
+
effect: "write",
|
|
281
|
+
},
|
|
282
|
+
deleteSchedule: {
|
|
283
|
+
cap: "agent.manage",
|
|
284
|
+
requires: ["agent.manage"],
|
|
285
|
+
effect: "write",
|
|
286
|
+
},
|
|
259
287
|
},
|
|
260
288
|
},
|
|
261
289
|
};
|
|
@@ -11,7 +11,7 @@ export declare const appBackendShardBindingsSchema: Schema.$Array<Schema.Union<S
|
|
|
11
11
|
readonly name: Schema.Literal<"BACKGROUND" | "GIT" | "EVENTS" | "APPS" | "WORKFLOWS" | "APP_STORAGE" | "MEDIA" | "COMPUTER" | "INBOX" | "AGENTS">;
|
|
12
12
|
readonly operations: Schema.$Array<Schema.Union<Schema.Struct<{
|
|
13
13
|
readonly name: Schema.Literal<string>;
|
|
14
|
-
readonly cap: Schema.Literal<"agent.list" | "agent.send" | "app.events.emit" | "app.background.admit" | "app.git.create" | "app.git.fork" | "app.git.read" | "app.git.write" | "app.git.exchange" | "app.
|
|
14
|
+
readonly cap: Schema.Literal<"agent.list" | "agent.manage" | "agent.read" | "agent.send" | "app.events.emit" | "app.background.admit" | "app.git.create" | "app.git.fork" | "app.git.read" | "app.git.write" | "app.git.exchange" | "app.register" | "app.catalog.read" | "app.build" | "app.select" | "app.fork" | "app.workflow.read" | "app.workflow.run" | "app.storage.read" | "app.storage.write" | "app.media.read" | "app.media.generate" | "app.computer.read" | "app.computer.write" | "app.computer.exec" | "inbox.read" | "inbox.visit">;
|
|
15
15
|
}>[]>>;
|
|
16
16
|
}>[]>>;
|
|
17
17
|
/** Look up an operation within its declared kind; unknown names have no authority. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
2
|
import { type AppDeclaration, type AppDeclaredCommand } from "./app-vocabulary.js";
|
|
3
3
|
export declare const appRoleSchema: Schema.Literals<readonly ["dashboard", "inbox", "files", "media", "sessions", "terminal"]>;
|
|
4
|
-
export declare const appCapabilityIdSchema: Schema.Literals<readonly ["agent.list", "agent.manage", "agent.rename", "agent.avatar", "agent.toolPolicy", "agent.read", "agent.send", "computer.list", "computer.readFile", "computer.writeFile", "computer.execute", "llm.generation", "media.generation", "games:servers", "git.repository", "apps.open", "apps.call", "app.storage", "app.events.emit", "team.workbenchHost", "marketplace.browse", "marketplace.purchase", "workflow.run", "workflow.publish", "workflow.arm", "world", "channels.read", "channels.personal.manage"]>;
|
|
4
|
+
export declare const appCapabilityIdSchema: Schema.Literals<readonly ["approvals", "agent.list", "agent.manage", "agent.rename", "agent.avatar", "agent.toolPolicy", "agent.read", "agent.send", "computer.list", "computer.readFile", "computer.writeFile", "computer.execute", "llm.generation", "media.generation", "games:servers", "git.repository", "apps.open", "apps.call", "app.storage", "app.events.emit", "team.workbenchHost", "marketplace.browse", "marketplace.purchase", "workflow.run", "workflow.publish", "workflow.arm", "world", "channels.read", "channels.personal.manage"]>;
|
|
5
5
|
export declare const appHandlerSchema: Schema.Literals<readonly ["file.open"]>;
|
|
6
6
|
/**
|
|
7
7
|
* One declared command: a Whistle definition's identity and projections.
|
package/dist/app-vocabulary.d.ts
CHANGED
|
@@ -58,26 +58,47 @@ export declare function resolveAppRoles(choices: ReadonlyMap<AppRole, string>, c
|
|
|
58
58
|
* Host capabilities an App may request. A request is never authority; the
|
|
59
59
|
* Team's installation grants decide. Extend this list here.
|
|
60
60
|
*/
|
|
61
|
-
export declare const appCapabilityIds: readonly ["agent.list", "agent.manage", "agent.rename", "agent.avatar", "agent.toolPolicy", "agent.read", "agent.send", "computer.list", "computer.readFile", "computer.writeFile", "computer.execute", "llm.generation", "media.generation", "games:servers", "git.repository", "apps.open", "apps.call", "app.storage", "app.events.emit", "team.workbenchHost", "marketplace.browse", "marketplace.purchase", "workflow.run", "workflow.publish", "workflow.arm", "world", "channels.read", "channels.personal.manage"];
|
|
61
|
+
export declare const appCapabilityIds: readonly ["approvals", "agent.list", "agent.manage", "agent.rename", "agent.avatar", "agent.toolPolicy", "agent.read", "agent.send", "computer.list", "computer.readFile", "computer.writeFile", "computer.execute", "llm.generation", "media.generation", "games:servers", "git.repository", "apps.open", "apps.call", "app.storage", "app.events.emit", "team.workbenchHost", "marketplace.browse", "marketplace.purchase", "workflow.run", "workflow.publish", "workflow.arm", "world", "channels.read", "channels.personal.manage"];
|
|
62
62
|
/** One requestable host capability id. */
|
|
63
63
|
export type AppCapabilityId = (typeof appCapabilityIds)[number];
|
|
64
64
|
/** Backend requests are narrower than the App capabilities a Team approves. */
|
|
65
65
|
export type { AppBackendBinding } from "./app-backend-binding-vocabulary.js";
|
|
66
66
|
import type { AppBackendBinding } from "./app-backend-binding-vocabulary.js";
|
|
67
|
+
/**
|
|
68
|
+
* Effect-free DTO projection of the owning JSON schema; equality is tested.
|
|
69
|
+
* Workers RPC's Serializable mapping unfolds anonymous inline recursion.
|
|
70
|
+
* A named array branch bounds it without expanding an inline array,
|
|
71
|
+
* without importing Effect into this declaration graph.
|
|
72
|
+
* @inline
|
|
73
|
+
*/
|
|
74
|
+
export type AppApiJsonValue = null | boolean | number | string | AppApiJsonArray | AppApiJsonObject;
|
|
75
|
+
/**
|
|
76
|
+
* Named recursive array branch required by the Workers RPC type mapper.
|
|
77
|
+
* @inline
|
|
78
|
+
*/
|
|
79
|
+
export type AppApiJsonArray = {
|
|
80
|
+
readonly [index: number]: AppApiJsonValue;
|
|
81
|
+
readonly length: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Package-internal declaration name; the public root exports AppApi.
|
|
85
|
+
* @inline
|
|
86
|
+
*/
|
|
87
|
+
export type AppApiJsonObject = {
|
|
88
|
+
readonly [key: string]: AppApiJsonValue;
|
|
89
|
+
};
|
|
67
90
|
/** Build-generated method and event metadata. This data-only projection grants no authority. */
|
|
68
91
|
export type AppApi = Readonly<{
|
|
69
92
|
methods: Readonly<Record<string, Readonly<{
|
|
70
93
|
description: string;
|
|
71
|
-
input:
|
|
72
|
-
output:
|
|
94
|
+
input: AppApiJsonObject;
|
|
95
|
+
output: AppApiJsonObject;
|
|
73
96
|
effect: "read" | "write" | "external";
|
|
74
97
|
requires: readonly AppCapabilityId[];
|
|
75
98
|
/** This method may return Agar's shared Pending result while working. */
|
|
76
99
|
pending?: true | undefined;
|
|
77
100
|
/** Omit from Workflow and tool discovery, without changing direct-call authority. */
|
|
78
101
|
hidden?: true | undefined;
|
|
79
|
-
/** Request anonymous read admission; declaration alone grants no authority. */
|
|
80
|
-
anonymous?: true | undefined;
|
|
81
102
|
/** Finished calls read as a person-facing row projected by the App's hidden `present` method. */
|
|
82
103
|
present?: Readonly<{
|
|
83
104
|
verb: string;
|
|
@@ -92,7 +113,7 @@ export type AppApi = Readonly<{
|
|
|
92
113
|
/** Declared event payload schemas; hosts validate emits against the selected Release. */
|
|
93
114
|
events?: Readonly<Record<string, Readonly<{
|
|
94
115
|
description: string;
|
|
95
|
-
payload:
|
|
116
|
+
payload: AppApiJsonObject;
|
|
96
117
|
}>>>;
|
|
97
118
|
}>;
|
|
98
119
|
/** Navigation requests an App can handle for the shell. */
|
package/dist/app-vocabulary.js
CHANGED
package/dist/cloudflare.d.ts
CHANGED
|
@@ -217,6 +217,67 @@ export declare const appArtifactErasureReadbackSchema: Schema.Struct<{
|
|
|
217
217
|
export declare const APP_RELEASE_D1_FRESH_SCHEMA: string;
|
|
218
218
|
/** Create the native registry that joins a Team publisher to one App/source. */
|
|
219
219
|
export declare function createD1TeamAppPublisherRegistry(database: AppReleaseD1Database): TeamAppPublisherRegistry;
|
|
220
|
+
/** One boot result's identity: the Release and the version of the check that judged it. */
|
|
221
|
+
export type ReleaseBootResultKey = Readonly<{
|
|
222
|
+
releaseId: string;
|
|
223
|
+
checkVersion: string;
|
|
224
|
+
}>;
|
|
225
|
+
/** A recorded boot result, opaque JSON owned by the boot gate that wrote it. */
|
|
226
|
+
export type ReleaseBootResultRecord = Readonly<{
|
|
227
|
+
kind: "recorded";
|
|
228
|
+
result: Schema.Json;
|
|
229
|
+
checkedAt: number;
|
|
230
|
+
}>;
|
|
231
|
+
/**
|
|
232
|
+
* One boot result per Release and check version, beside the Release in the
|
|
233
|
+
* global catalog. Whoever checks first (the publisher at submission or a
|
|
234
|
+
* Team's first install) records it; everyone reads it; nobody rechecks.
|
|
235
|
+
* The catalog owns identity and write-once storage; the boot gate owns the
|
|
236
|
+
* result's meaning and parses it on read.
|
|
237
|
+
*
|
|
238
|
+
* Writers are host-run checkers only, recording only definitive outcomes
|
|
239
|
+
* (never an inconclusive or "not checked" run) with sanitized diagnostics;
|
|
240
|
+
* the result covers the UI page check alone, not backend construction.
|
|
241
|
+
*/
|
|
242
|
+
export type ReleaseBootResults = Readonly<{
|
|
243
|
+
/** The recorded result for this Release and check version, if any. */
|
|
244
|
+
read: (key: ReleaseBootResultKey) => Promise<Readonly<{
|
|
245
|
+
kind: "absent";
|
|
246
|
+
}> | ReleaseBootResultRecord>;
|
|
247
|
+
/** Record a result unless one exists; always answers with the stored one. */
|
|
248
|
+
recordIfAbsent: (input: ReleaseBootResultKey & Readonly<{
|
|
249
|
+
result: Schema.Json;
|
|
250
|
+
checkedAt: number;
|
|
251
|
+
}>) => Promise<ReleaseBootResultRecord>;
|
|
252
|
+
}>;
|
|
253
|
+
/** The catalog's write-once boot results, over the same App Release D1. */
|
|
254
|
+
export declare function createD1ReleaseBootResults(database: AppReleaseD1Database): ReleaseBootResults;
|
|
255
|
+
/** The longest a boot capability lease may live: one boot check plus cleanup. */
|
|
256
|
+
export declare const BOOT_CAPABILITY_MAX_LIFETIME_MS = 60000;
|
|
257
|
+
/**
|
|
258
|
+
* The catalog storage behind a host's boot `BootCapabilityStore`: one
|
|
259
|
+
* short-lived row per issued lease, keyed by the token's digest (never the
|
|
260
|
+
* token). The lease itself is opaque JSON owned by the boot capability
|
|
261
|
+
* contract, which parses it on resolve. Expired rows are deleted on resolve
|
|
262
|
+
* and purged on every issue; revoke deletes.
|
|
263
|
+
*/
|
|
264
|
+
export type BootCapabilityRows = Readonly<{
|
|
265
|
+
/** Store one lease; refuses a raw token or a lifetime beyond the maximum. */
|
|
266
|
+
issue: (input: Readonly<{
|
|
267
|
+
tokenDigest: string;
|
|
268
|
+
leaseId: string;
|
|
269
|
+
releaseId: string;
|
|
270
|
+
leaseJson: string;
|
|
271
|
+
expiresAt: number;
|
|
272
|
+
now: number;
|
|
273
|
+
}>) => Promise<void>;
|
|
274
|
+
/** The live lease's JSON for this digest, or `null` when absent or expired. */
|
|
275
|
+
resolve: (tokenDigest: string, now: number) => Promise<string | null>;
|
|
276
|
+
/** Delete one lease once its check is done. */
|
|
277
|
+
revoke: (leaseId: string) => Promise<void>;
|
|
278
|
+
}>;
|
|
279
|
+
/** The catalog's short-lived boot capability rows, over the same App Release D1. */
|
|
280
|
+
export declare function createD1BootCapabilityRows(database: AppReleaseD1Database): BootCapabilityRows;
|
|
220
281
|
/** Create the D1-backed App Release store with private public-website authority. */
|
|
221
282
|
export declare function createD1AppReleaseStore(database: AppReleaseD1Database): PromiseAppReleaseStore & {
|
|
222
283
|
readonly transitionObligations: AppReleaseTransitionObligationStore;
|
package/dist/cloudflare.js
CHANGED
|
@@ -512,6 +512,11 @@ CREATE INDEX app_release_team_publishers_team_idx ON app_release_team_publishers
|
|
|
512
512
|
CREATE TABLE app_release_release_verification_metadata (release_id TEXT PRIMARY KEY REFERENCES app_release_release_verifications(release_id), artifact_digest TEXT NOT NULL, description_json TEXT NOT NULL CHECK(json_valid(description_json))) STRICT;
|
|
513
513
|
CREATE TABLE publisher_template_seed_receipts (template_repository TEXT NOT NULL, seed_revision TEXT NOT NULL, platform_app_id TEXT NOT NULL, source_revision TEXT NOT NULL, source_tree_digest TEXT NOT NULL, recipe_json TEXT CHECK(recipe_json IS NULL OR json_valid(recipe_json)), build_recipe_digest TEXT CHECK(build_recipe_digest IS NULL OR (length(build_recipe_digest) = 71 AND substr(build_recipe_digest, 1, 7) = 'sha256:' AND substr(build_recipe_digest, 8) NOT GLOB '*[^0-9a-f]*')), CHECK((recipe_json IS NULL) = (build_recipe_digest IS NULL)), PRIMARY KEY (template_repository, seed_revision)) STRICT;
|
|
514
514
|
CREATE TABLE publisher_artifacts_repositories (repository_name TEXT PRIMARY KEY CHECK(length(repository_name) BETWEEN 1 AND 128), provider_id TEXT NOT NULL CHECK(length(provider_id) > 0), default_branch TEXT NOT NULL CHECK(default_branch = 'main'), remote TEXT NOT NULL CHECK(length(remote) > 0), parent_repository TEXT REFERENCES publisher_artifacts_repositories(repository_name), CHECK(parent_repository IS NULL OR parent_repository <> repository_name)) STRICT;
|
|
515
|
+
CREATE TABLE app_release_boot_results (release_id TEXT NOT NULL REFERENCES app_release_releases(release_id), check_version TEXT NOT NULL CHECK(length(check_version) BETWEEN 1 AND 64), outcome_json TEXT NOT NULL CHECK(json_valid(outcome_json) AND length(outcome_json) <= 65536), checked_at INTEGER NOT NULL, PRIMARY KEY (release_id, check_version)) STRICT;
|
|
516
|
+
CREATE TRIGGER app_release_boot_results_write_once BEFORE UPDATE ON app_release_boot_results BEGIN SELECT RAISE(ABORT, 'App Release boot results are write-once'); END;
|
|
517
|
+
CREATE TABLE app_release_boot_capabilities (token_digest TEXT PRIMARY KEY CHECK(length(token_digest) = 64 AND token_digest NOT GLOB '*[^0-9a-f]*'), lease_id TEXT NOT NULL UNIQUE CHECK(length(lease_id) BETWEEN 1 AND 128), release_id TEXT NOT NULL REFERENCES app_release_releases(release_id), lease_json TEXT NOT NULL CHECK(json_valid(lease_json) AND length(lease_json) <= 262144), expires_at INTEGER NOT NULL) STRICT;
|
|
518
|
+
CREATE INDEX app_release_boot_capabilities_expiry_idx ON app_release_boot_capabilities(expires_at);
|
|
519
|
+
CREATE TRIGGER app_release_boot_capabilities_write_once BEFORE UPDATE ON app_release_boot_capabilities BEGIN SELECT RAISE(ABORT, 'Boot capability leases are write-once'); END;
|
|
515
520
|
${publicRouteSchemaSql}
|
|
516
521
|
${platformOwnerReplaySchemaSql}
|
|
517
522
|
${buyerReferenceSchemaSql}
|
|
@@ -647,6 +652,89 @@ export function createD1TeamAppPublisherRegistry(database) {
|
|
|
647
652
|
},
|
|
648
653
|
};
|
|
649
654
|
}
|
|
655
|
+
const bootResultRowSchema = Schema.Struct({
|
|
656
|
+
outcome_json: Schema.fromJsonString(Schema.Json),
|
|
657
|
+
checked_at: Schema.Number,
|
|
658
|
+
});
|
|
659
|
+
/** The catalog's write-once boot results, over the same App Release D1. */
|
|
660
|
+
export function createD1ReleaseBootResults(database) {
|
|
661
|
+
const read = async (key) => {
|
|
662
|
+
const row = await database
|
|
663
|
+
.prepare(`SELECT outcome_json, checked_at FROM app_release_boot_results
|
|
664
|
+
WHERE release_id = ? AND check_version = ?`)
|
|
665
|
+
.bind(parseReleaseId(key.releaseId), key.checkVersion)
|
|
666
|
+
.first();
|
|
667
|
+
if (row === null)
|
|
668
|
+
return { kind: "absent" };
|
|
669
|
+
const decoded = Schema.decodeUnknownSync(bootResultRowSchema)(row);
|
|
670
|
+
return {
|
|
671
|
+
kind: "recorded",
|
|
672
|
+
result: decoded.outcome_json,
|
|
673
|
+
checkedAt: decoded.checked_at,
|
|
674
|
+
};
|
|
675
|
+
};
|
|
676
|
+
return {
|
|
677
|
+
read,
|
|
678
|
+
recordIfAbsent: async (input) => {
|
|
679
|
+
await database
|
|
680
|
+
.prepare(`INSERT INTO app_release_boot_results
|
|
681
|
+
(release_id, check_version, outcome_json, checked_at)
|
|
682
|
+
VALUES (?, ?, ?, ?)
|
|
683
|
+
ON CONFLICT (release_id, check_version) DO NOTHING`)
|
|
684
|
+
.bind(parseReleaseId(input.releaseId), input.checkVersion, JSON.stringify(input.result), input.checkedAt)
|
|
685
|
+
.run();
|
|
686
|
+
const stored = await read(input);
|
|
687
|
+
if (stored.kind === "absent")
|
|
688
|
+
throw new Error("The boot result was not recorded");
|
|
689
|
+
return stored;
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
/** The longest a boot capability lease may live: one boot check plus cleanup. */
|
|
694
|
+
export const BOOT_CAPABILITY_MAX_LIFETIME_MS = 60_000;
|
|
695
|
+
const tokenDigestSchema = Schema.String.pipe(Schema.check(Schema.isPattern(/^[0-9a-f]{64}$/u)));
|
|
696
|
+
const bootCapabilityRowSchema = Schema.Struct({ lease_json: Schema.String });
|
|
697
|
+
/** The catalog's short-lived boot capability rows, over the same App Release D1. */
|
|
698
|
+
export function createD1BootCapabilityRows(database) {
|
|
699
|
+
return {
|
|
700
|
+
issue: async (input) => {
|
|
701
|
+
const tokenDigest = Schema.decodeUnknownSync(tokenDigestSchema)(input.tokenDigest);
|
|
702
|
+
if (input.expiresAt <= input.now ||
|
|
703
|
+
input.expiresAt - input.now > BOOT_CAPABILITY_MAX_LIFETIME_MS)
|
|
704
|
+
throw new RangeError("Boot capability lifetime is out of bounds");
|
|
705
|
+
await database.batch([
|
|
706
|
+
database
|
|
707
|
+
.prepare("DELETE FROM app_release_boot_capabilities WHERE expires_at <= ?")
|
|
708
|
+
.bind(input.now),
|
|
709
|
+
database
|
|
710
|
+
.prepare(`INSERT INTO app_release_boot_capabilities
|
|
711
|
+
(token_digest, lease_id, release_id, lease_json, expires_at)
|
|
712
|
+
VALUES (?, ?, ?, ?, ?)`)
|
|
713
|
+
.bind(tokenDigest, input.leaseId, parseReleaseId(input.releaseId), input.leaseJson, input.expiresAt),
|
|
714
|
+
]);
|
|
715
|
+
},
|
|
716
|
+
resolve: async (tokenDigest, now) => {
|
|
717
|
+
const digest = Schema.decodeUnknownSync(tokenDigestSchema)(tokenDigest);
|
|
718
|
+
await database
|
|
719
|
+
.prepare("DELETE FROM app_release_boot_capabilities WHERE token_digest = ? AND expires_at <= ?")
|
|
720
|
+
.bind(digest, now)
|
|
721
|
+
.run();
|
|
722
|
+
const row = await database
|
|
723
|
+
.prepare("SELECT lease_json FROM app_release_boot_capabilities WHERE token_digest = ? AND expires_at > ?")
|
|
724
|
+
.bind(digest, now)
|
|
725
|
+
.first();
|
|
726
|
+
return row === null
|
|
727
|
+
? null
|
|
728
|
+
: Schema.decodeUnknownSync(bootCapabilityRowSchema)(row).lease_json;
|
|
729
|
+
},
|
|
730
|
+
revoke: async (leaseId) => {
|
|
731
|
+
await database
|
|
732
|
+
.prepare("DELETE FROM app_release_boot_capabilities WHERE lease_id = ?")
|
|
733
|
+
.bind(leaseId)
|
|
734
|
+
.run();
|
|
735
|
+
},
|
|
736
|
+
};
|
|
737
|
+
}
|
|
650
738
|
/** Create the D1-backed App Release store with private public-website authority. */
|
|
651
739
|
export function createD1AppReleaseStore(database) {
|
|
652
740
|
const transitionObligations = {
|
|
@@ -1461,13 +1461,12 @@ export declare const decodeReleaseLifecycleStoreResult: (input: unknown, options
|
|
|
1461
1461
|
api?: Readonly<{
|
|
1462
1462
|
methods: Readonly<Record<string, Readonly<{
|
|
1463
1463
|
description: string;
|
|
1464
|
-
input:
|
|
1465
|
-
output:
|
|
1464
|
+
input: import("../app-vocabulary.js").AppApiJsonObject;
|
|
1465
|
+
output: import("../app-vocabulary.js").AppApiJsonObject;
|
|
1466
1466
|
effect: "read" | "write" | "external";
|
|
1467
1467
|
requires: readonly import("../app-vocabulary.js").AppCapabilityId[];
|
|
1468
1468
|
pending?: true | undefined;
|
|
1469
1469
|
hidden?: true | undefined;
|
|
1470
|
-
anonymous?: true | undefined;
|
|
1471
1470
|
present?: Readonly<{
|
|
1472
1471
|
verb: string;
|
|
1473
1472
|
}> | undefined;
|
|
@@ -1479,7 +1478,7 @@ export declare const decodeReleaseLifecycleStoreResult: (input: unknown, options
|
|
|
1479
1478
|
}>;
|
|
1480
1479
|
events?: Readonly<Record<string, Readonly<{
|
|
1481
1480
|
description: string;
|
|
1482
|
-
payload:
|
|
1481
|
+
payload: import("../app-vocabulary.js").AppApiJsonObject;
|
|
1483
1482
|
}>>>;
|
|
1484
1483
|
}>;
|
|
1485
1484
|
displayName?: string | undefined;
|
|
@@ -1518,7 +1517,9 @@ export declare const decodeReleaseLifecycleStoreResult: (input: unknown, options
|
|
|
1518
1517
|
help?: Readonly<{
|
|
1519
1518
|
order?: number | undefined;
|
|
1520
1519
|
}> | undefined;
|
|
1521
|
-
menu
|
|
1520
|
+
menu
|
|
1521
|
+
/** Canonical Effect Schema for a verified immutable artifact snapshot. */
|
|
1522
|
+
?: Readonly<{
|
|
1522
1523
|
order?: number | undefined;
|
|
1523
1524
|
}> | undefined;
|
|
1524
1525
|
palette?: Readonly<{
|
|
@@ -219,13 +219,12 @@ export declare const decodePublicWebsiteAuthorityStoreResult: (input: unknown, o
|
|
|
219
219
|
api?: Readonly<{
|
|
220
220
|
methods: Readonly<Record<string, Readonly<{
|
|
221
221
|
description: string;
|
|
222
|
-
input:
|
|
223
|
-
output:
|
|
222
|
+
input: import("../app-vocabulary.js").AppApiJsonObject;
|
|
223
|
+
output: import("../app-vocabulary.js").AppApiJsonObject;
|
|
224
224
|
effect: "read" | "write" | "external";
|
|
225
225
|
requires: readonly import("../app-vocabulary.js").AppCapabilityId[];
|
|
226
226
|
pending?: true | undefined;
|
|
227
227
|
hidden?: true | undefined;
|
|
228
|
-
anonymous?: true | undefined;
|
|
229
228
|
present?: Readonly<{
|
|
230
229
|
verb: string;
|
|
231
230
|
}> | undefined;
|
|
@@ -237,7 +236,7 @@ export declare const decodePublicWebsiteAuthorityStoreResult: (input: unknown, o
|
|
|
237
236
|
}>;
|
|
238
237
|
events?: Readonly<Record<string, Readonly<{
|
|
239
238
|
description: string;
|
|
240
|
-
payload:
|
|
239
|
+
payload: import("../app-vocabulary.js").AppApiJsonObject;
|
|
241
240
|
}>>>;
|
|
242
241
|
}>;
|
|
243
242
|
displayName?: string | undefined;
|