@vibesdotdev/workers 1.0.0-rc.3 → 1.0.0-rc.7
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/adapters/database/database-queue.record.descriptor.d.ts +2 -0
- package/dist/adapters/database/database-queue.record.descriptor.d.ts.map +1 -1
- package/dist/adapters/ipc/store/queue-job.record.descriptor.d.ts +2 -0
- package/dist/adapters/ipc/store/queue-job.record.descriptor.d.ts.map +1 -1
- package/dist/adapters/remote/remote-workers.adapter.d.ts +74 -0
- package/dist/adapters/remote/remote-workers.adapter.d.ts.map +1 -0
- package/dist/adapters/remote/remote-workers.adapter.js +178 -0
- package/dist/adapters/remote/remote-workers.adapter.js.map +1 -0
- package/dist/client/operations/dispatch/stream.d.ts.map +1 -1
- package/dist/client/operations/dispatch/stream.js +7 -3
- package/dist/client/operations/dispatch/stream.js.map +1 -1
- package/dist/client/operations/graph.d.ts.map +1 -1
- package/dist/client/operations/graph.js +2 -0
- package/dist/client/operations/graph.js.map +1 -1
- package/dist/client/operations/inline.d.ts.map +1 -1
- package/dist/client/operations/inline.js +12 -7
- package/dist/client/operations/inline.js.map +1 -1
- package/dist/code-execution/runner-adapter/kinds/runner-adapter.kind.d.ts +1 -1
- package/dist/code-execution/runner-adapter/schemas/descriptors.d.ts +1 -1
- package/dist/code-execution/schemas/common.d.ts +2 -2
- package/dist/config/workers.config.descriptor.d.ts +4 -0
- package/dist/config/workers.config.descriptor.d.ts.map +1 -1
- package/dist/config/workers.config.descriptor.js +13 -0
- package/dist/config/workers.config.descriptor.js.map +1 -1
- package/dist/core/queued-invocation.d.ts +2 -0
- package/dist/core/queued-invocation.d.ts.map +1 -1
- package/dist/core/schemas/api.d.ts +8 -2
- package/dist/core/schemas/api.d.ts.map +1 -1
- package/dist/core/supervised-workloads.d.ts +3 -3
- package/dist/dead-letter/dead-letter.schema.d.ts +3 -3
- package/dist/dead-letter/workers.dlq.replay.job.d.ts +1 -1
- package/dist/docs/workers.kinds.docs.descriptor.d.ts.map +1 -1
- package/dist/docs/workers.kinds.docs.descriptor.js +8 -2
- package/dist/docs/workers.kinds.docs.descriptor.js.map +1 -1
- package/dist/execution/thread-host.schemas.d.ts +2 -0
- package/dist/execution/thread-host.schemas.d.ts.map +1 -1
- package/dist/graph/schemas.d.ts +2 -0
- package/dist/graph/schemas.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/kinds/material.d.ts +9 -0
- package/dist/kinds/material.d.ts.map +1 -0
- package/dist/kinds/material.git.d.ts +73 -0
- package/dist/kinds/material.git.d.ts.map +1 -0
- package/dist/kinds/material.git.js +131 -0
- package/dist/kinds/material.git.js.map +1 -0
- package/dist/kinds/material.js +13 -0
- package/dist/kinds/material.js.map +1 -0
- package/dist/kinds/material.stores.d.ts +118 -0
- package/dist/kinds/material.stores.d.ts.map +1 -0
- package/dist/kinds/material.stores.js +76 -0
- package/dist/kinds/material.stores.js.map +1 -0
- package/dist/kinds/schemas/material.d.ts +153 -0
- package/dist/kinds/schemas/material.d.ts.map +1 -0
- package/dist/kinds/schemas/material.js +79 -0
- package/dist/kinds/schemas/material.js.map +1 -0
- package/dist/maintenance/jobs/storage-sync/maintenance.storage-sync.descriptor.d.ts +3 -2
- package/dist/maintenance/jobs/storage-sync/maintenance.storage-sync.descriptor.d.ts.map +1 -1
- package/dist/maintenance/jobs/storage-sync/maintenance.storage-sync.descriptor.js +3 -2
- package/dist/maintenance/jobs/storage-sync/maintenance.storage-sync.descriptor.js.map +1 -1
- package/dist/maintenance/jobs/storage-sync/maintenance.storage-sync.impl.consumer.d.ts +5 -0
- package/dist/maintenance/jobs/storage-sync/maintenance.storage-sync.impl.consumer.d.ts.map +1 -1
- package/dist/maintenance/jobs/storage-sync/maintenance.storage-sync.impl.consumer.js +50 -5
- package/dist/maintenance/jobs/storage-sync/maintenance.storage-sync.impl.consumer.js.map +1 -1
- package/dist/maintenance/jobs/storage-sync/schemas/storage-sync.d.ts +18 -0
- package/dist/maintenance/jobs/storage-sync/schemas/storage-sync.d.ts.map +1 -1
- package/dist/maintenance/jobs/storage-sync/schemas/storage-sync.js +4 -0
- package/dist/maintenance/jobs/storage-sync/schemas/storage-sync.js.map +1 -1
- package/dist/remote/claim-policy.d.ts +33 -0
- package/dist/remote/claim-policy.d.ts.map +1 -0
- package/dist/remote/claim-policy.js +82 -0
- package/dist/remote/claim-policy.js.map +1 -0
- package/dist/remote/http-wire.d.ts +188 -0
- package/dist/remote/http-wire.d.ts.map +1 -0
- package/dist/remote/http-wire.js +71 -0
- package/dist/remote/http-wire.js.map +1 -0
- package/dist/remote/queue-capability.d.ts +2 -0
- package/dist/remote/queue-capability.d.ts.map +1 -1
- package/dist/remote/serve.d.ts +13 -0
- package/dist/remote/serve.d.ts.map +1 -0
- package/dist/remote/serve.js +53 -0
- package/dist/remote/serve.js.map +1 -0
- package/dist/runnable/job/change-source.d.ts.map +1 -1
- package/dist/runnable/job/change-source.js +2 -7
- package/dist/runnable/job/change-source.js.map +1 -1
- package/dist/runnable/job/executor.d.ts.map +1 -1
- package/dist/runnable/job/executor.js +4 -1
- package/dist/runnable/job/executor.js.map +1 -1
- package/dist/runtime/ledger/job-ledger.record.descriptor.d.ts +2 -0
- package/dist/runtime/ledger/job-ledger.record.descriptor.d.ts.map +1 -1
- package/dist/runtime/ledger/job-ledger.record.descriptor.js +3 -1
- package/dist/runtime/ledger/job-ledger.record.descriptor.js.map +1 -1
- package/dist/schemas/cancellation.d.ts +4 -0
- package/dist/schemas/cancellation.d.ts.map +1 -1
- package/dist/schemas/claim.d.ts +4 -0
- package/dist/schemas/claim.d.ts.map +1 -1
- package/dist/schemas/claim.js +9 -1
- package/dist/schemas/claim.js.map +1 -1
- package/dist/schemas/client.d.ts +3 -1
- package/dist/schemas/client.d.ts.map +1 -1
- package/dist/schemas/descriptors.d.ts +31 -0
- package/dist/schemas/descriptors.d.ts.map +1 -1
- package/dist/schemas/descriptors.js +5 -0
- package/dist/schemas/descriptors.js.map +1 -1
- package/dist/workers.cloud.plugin.d.ts.map +1 -1
- package/dist/workers.cloud.plugin.js +2 -1
- package/dist/workers.cloud.plugin.js.map +1 -1
- package/dist/workers.plugin.d.ts.map +1 -1
- package/dist/workers.plugin.js +15 -3
- package/dist/workers.plugin.js.map +1 -1
- package/package.json +96 -32
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { type ArtifactMaterialRef, type CacheMaterialRef, type WorkerMaterial, type WorkerMaterialContext, type WorkerMaterialReceipt } from './schemas/material.ts';
|
|
2
|
+
export declare const cacheMaterialDescriptor: {
|
|
3
|
+
id: string;
|
|
4
|
+
kind: "workers/material";
|
|
5
|
+
materialKinds: ("cache" | "git" | "artifact")[];
|
|
6
|
+
supportsCapture: boolean;
|
|
7
|
+
name?: string | undefined;
|
|
8
|
+
description?: string | undefined;
|
|
9
|
+
tags?: string[] | undefined;
|
|
10
|
+
hardware?: string[] | undefined;
|
|
11
|
+
enabled?: boolean | undefined;
|
|
12
|
+
priority?: number | undefined;
|
|
13
|
+
capabilityId?: string | undefined;
|
|
14
|
+
requiredContext?: string[] | undefined;
|
|
15
|
+
optionalContext?: string[] | undefined;
|
|
16
|
+
config?: unknown;
|
|
17
|
+
retention?: string | {
|
|
18
|
+
reason: string;
|
|
19
|
+
maxAgeDays?: number | undefined;
|
|
20
|
+
maxEntries?: number | undefined;
|
|
21
|
+
maxBytes?: number | undefined;
|
|
22
|
+
cascadeFrom?: string | undefined;
|
|
23
|
+
ageField?: string | undefined;
|
|
24
|
+
enforcedBy?: string | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
maxBytes?: number | undefined;
|
|
27
|
+
maxEntries?: number | undefined;
|
|
28
|
+
};
|
|
29
|
+
export declare const artifactMaterialDescriptor: {
|
|
30
|
+
id: string;
|
|
31
|
+
kind: "workers/material";
|
|
32
|
+
materialKinds: ("cache" | "git" | "artifact")[];
|
|
33
|
+
supportsCapture: boolean;
|
|
34
|
+
name?: string | undefined;
|
|
35
|
+
description?: string | undefined;
|
|
36
|
+
tags?: string[] | undefined;
|
|
37
|
+
hardware?: string[] | undefined;
|
|
38
|
+
enabled?: boolean | undefined;
|
|
39
|
+
priority?: number | undefined;
|
|
40
|
+
capabilityId?: string | undefined;
|
|
41
|
+
requiredContext?: string[] | undefined;
|
|
42
|
+
optionalContext?: string[] | undefined;
|
|
43
|
+
config?: unknown;
|
|
44
|
+
retention?: string | {
|
|
45
|
+
reason: string;
|
|
46
|
+
maxAgeDays?: number | undefined;
|
|
47
|
+
maxEntries?: number | undefined;
|
|
48
|
+
maxBytes?: number | undefined;
|
|
49
|
+
cascadeFrom?: string | undefined;
|
|
50
|
+
ageField?: string | undefined;
|
|
51
|
+
enforcedBy?: string | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
maxBytes?: number | undefined;
|
|
54
|
+
maxEntries?: number | undefined;
|
|
55
|
+
};
|
|
56
|
+
export declare class CacheWorkerMaterial implements WorkerMaterial {
|
|
57
|
+
readonly descriptor: {
|
|
58
|
+
id: string;
|
|
59
|
+
kind: "workers/material";
|
|
60
|
+
materialKinds: ("cache" | "git" | "artifact")[];
|
|
61
|
+
supportsCapture: boolean;
|
|
62
|
+
name?: string | undefined;
|
|
63
|
+
description?: string | undefined;
|
|
64
|
+
tags?: string[] | undefined;
|
|
65
|
+
hardware?: string[] | undefined;
|
|
66
|
+
enabled?: boolean | undefined;
|
|
67
|
+
priority?: number | undefined;
|
|
68
|
+
capabilityId?: string | undefined;
|
|
69
|
+
requiredContext?: string[] | undefined;
|
|
70
|
+
optionalContext?: string[] | undefined;
|
|
71
|
+
config?: unknown;
|
|
72
|
+
retention?: string | {
|
|
73
|
+
reason: string;
|
|
74
|
+
maxAgeDays?: number | undefined;
|
|
75
|
+
maxEntries?: number | undefined;
|
|
76
|
+
maxBytes?: number | undefined;
|
|
77
|
+
cascadeFrom?: string | undefined;
|
|
78
|
+
ageField?: string | undefined;
|
|
79
|
+
enforcedBy?: string | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
maxBytes?: number | undefined;
|
|
82
|
+
maxEntries?: number | undefined;
|
|
83
|
+
};
|
|
84
|
+
restore(input: CacheMaterialRef, context: WorkerMaterialContext): Promise<WorkerMaterialReceipt>;
|
|
85
|
+
}
|
|
86
|
+
export declare class ArtifactWorkerMaterial implements WorkerMaterial {
|
|
87
|
+
readonly descriptor: {
|
|
88
|
+
id: string;
|
|
89
|
+
kind: "workers/material";
|
|
90
|
+
materialKinds: ("cache" | "git" | "artifact")[];
|
|
91
|
+
supportsCapture: boolean;
|
|
92
|
+
name?: string | undefined;
|
|
93
|
+
description?: string | undefined;
|
|
94
|
+
tags?: string[] | undefined;
|
|
95
|
+
hardware?: string[] | undefined;
|
|
96
|
+
enabled?: boolean | undefined;
|
|
97
|
+
priority?: number | undefined;
|
|
98
|
+
capabilityId?: string | undefined;
|
|
99
|
+
requiredContext?: string[] | undefined;
|
|
100
|
+
optionalContext?: string[] | undefined;
|
|
101
|
+
config?: unknown;
|
|
102
|
+
retention?: string | {
|
|
103
|
+
reason: string;
|
|
104
|
+
maxAgeDays?: number | undefined;
|
|
105
|
+
maxEntries?: number | undefined;
|
|
106
|
+
maxBytes?: number | undefined;
|
|
107
|
+
cascadeFrom?: string | undefined;
|
|
108
|
+
ageField?: string | undefined;
|
|
109
|
+
enforcedBy?: string | undefined;
|
|
110
|
+
} | undefined;
|
|
111
|
+
maxBytes?: number | undefined;
|
|
112
|
+
maxEntries?: number | undefined;
|
|
113
|
+
};
|
|
114
|
+
restore(input: ArtifactMaterialRef, context: WorkerMaterialContext): Promise<WorkerMaterialReceipt>;
|
|
115
|
+
}
|
|
116
|
+
export declare const cacheMaterial: CacheWorkerMaterial;
|
|
117
|
+
export declare const artifactMaterial: ArtifactWorkerMaterial;
|
|
118
|
+
//# sourceMappingURL=material.stores.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"material.stores.d.ts","sourceRoot":"","sources":["../../src/kinds/material.stores.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;CAOlC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;CAOrC,CAAC;AAmBH,qBAAa,mBAAoB,YAAW,cAAc;IACzD,QAAQ,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;MAA2B;IAExC,OAAO,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAwBtG;AAED,qBAAa,sBAAuB,YAAW,cAAc;IAC5D,QAAQ,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;MAA8B;IAE3C,OAAO,CACZ,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;CA4BjC;AAED,eAAO,MAAM,aAAa,qBAA4B,CAAC;AACvD,eAAO,MAAM,gBAAgB,wBAA+B,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getRuntimePath } from '@vibesdotdev/paths';
|
|
2
|
+
import { WorkerMaterialDescriptorSchema } from "./schemas/material.js";
|
|
3
|
+
import { workersMaterialRefusal } from "./schemas/material.js";
|
|
4
|
+
export const cacheMaterialDescriptor = WorkerMaterialDescriptorSchema.parse({
|
|
5
|
+
id: 'workers.material.cache',
|
|
6
|
+
kind: 'workers/material',
|
|
7
|
+
name: 'Cache material',
|
|
8
|
+
description: 'Restore a content-addressed CI cache entry into a job workspace.',
|
|
9
|
+
materialKinds: ['cache'],
|
|
10
|
+
supportsCapture: false
|
|
11
|
+
});
|
|
12
|
+
export const artifactMaterialDescriptor = WorkerMaterialDescriptorSchema.parse({
|
|
13
|
+
id: 'workers.material.artifact',
|
|
14
|
+
kind: 'workers/material',
|
|
15
|
+
name: 'Artifact material',
|
|
16
|
+
description: 'Restore an immutable CI artifact by digest into a job workspace.',
|
|
17
|
+
materialKinds: ['artifact'],
|
|
18
|
+
supportsCapture: false
|
|
19
|
+
});
|
|
20
|
+
async function writeBytes(context, relative, bytes) {
|
|
21
|
+
if (!context.fs) {
|
|
22
|
+
throw workersMaterialRefusal('workers-material-unavailable', 'The material claimant provides no filesystem.', {
|
|
23
|
+
path: relative
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const paths = await getRuntimePath(context.runtime);
|
|
27
|
+
const absolute = paths.resolve(context.workspace, relative);
|
|
28
|
+
await context.fs.mkdir(paths.dirname(absolute), { recursive: true });
|
|
29
|
+
await context.fs.writeFile(absolute, bytes);
|
|
30
|
+
return absolute;
|
|
31
|
+
}
|
|
32
|
+
export class CacheWorkerMaterial {
|
|
33
|
+
descriptor = cacheMaterialDescriptor;
|
|
34
|
+
async restore(input, context) {
|
|
35
|
+
if (input.kind !== 'cache') {
|
|
36
|
+
throw workersMaterialRefusal('workers-material-ref-invalid', 'The cache material received a non-cache ref.', {
|
|
37
|
+
kind: input.kind
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (context.trust.untrusted && input.sensitivity === 'trusted-only') {
|
|
41
|
+
throw workersMaterialRefusal('workers-material-trust-refused', 'An untrusted ref cannot read a trusted-only cache.', { key: input.key });
|
|
42
|
+
}
|
|
43
|
+
if (!context.cacheStore) {
|
|
44
|
+
throw workersMaterialRefusal('workers-material-unavailable', 'The material claimant provides no cache store.', {
|
|
45
|
+
key: input.key
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const entry = await context.cacheStore.get(input.key);
|
|
49
|
+
const path = await writeBytes(context, input.path ?? '.forge-ci/cache', entry.bytes);
|
|
50
|
+
return entry.entries === undefined
|
|
51
|
+
? { kind: 'cache', digest: entry.digest, path, bytes: entry.bytes.byteLength }
|
|
52
|
+
: { kind: 'cache', digest: entry.digest, path, bytes: entry.bytes.byteLength, entries: entry.entries };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class ArtifactWorkerMaterial {
|
|
56
|
+
descriptor = artifactMaterialDescriptor;
|
|
57
|
+
async restore(input, context) {
|
|
58
|
+
if (input.kind !== 'artifact') {
|
|
59
|
+
throw workersMaterialRefusal('workers-material-ref-invalid', 'The artifact material received a non-artifact ref.', { kind: input.kind });
|
|
60
|
+
}
|
|
61
|
+
if (!context.artifactStore) {
|
|
62
|
+
throw workersMaterialRefusal('workers-material-unavailable', 'The material claimant provides no artifact store.', { artifactId: input.artifactId });
|
|
63
|
+
}
|
|
64
|
+
const entry = await context.artifactStore.get(input.artifactId);
|
|
65
|
+
if (entry.digest.toLowerCase() !== input.digest.toLowerCase()) {
|
|
66
|
+
throw workersMaterialRefusal('workers-material-digest-mismatch', `Artifact ${input.artifactId} returned ${entry.digest} instead of ${input.digest}.`, { expected: input.digest, actual: entry.digest });
|
|
67
|
+
}
|
|
68
|
+
const path = await writeBytes(context, input.path ?? '.forge-ci/artifacts', entry.bytes);
|
|
69
|
+
return entry.entries === undefined
|
|
70
|
+
? { kind: 'artifact', digest: entry.digest, path, bytes: entry.bytes.byteLength }
|
|
71
|
+
: { kind: 'artifact', digest: entry.digest, path, bytes: entry.bytes.byteLength, entries: entry.entries };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export const cacheMaterial = new CacheWorkerMaterial();
|
|
75
|
+
export const artifactMaterial = new ArtifactWorkerMaterial();
|
|
76
|
+
//# sourceMappingURL=material.stores.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"material.stores.js","sourceRoot":"","sources":["../../src/kinds/material.stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACp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CAAC,KAAK,CAAC,UAAU,EAAE;YACjF,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAC5G,CAAC;CACD;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,mBAAmB,EAAE,CAAC;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import type { CacheByteStore } from '@vibesdotdev/infra-core/kinds';
|
|
3
|
+
import { CapabilityError, type RuntimeRef } from '@vibesdotdev/kernel';
|
|
4
|
+
export declare const WORKERS_MATERIAL_KIND = "workers/material";
|
|
5
|
+
/** A repository-relative path a material may write or capture. */
|
|
6
|
+
export declare const MaterialPathSchema: z.ZodString;
|
|
7
|
+
export declare const GitMaterialRefSchema: z.ZodObject<{
|
|
8
|
+
kind: z.ZodLiteral<"git">;
|
|
9
|
+
repositoryId: z.ZodString;
|
|
10
|
+
cloneUrl: z.ZodURL;
|
|
11
|
+
sha: z.ZodString;
|
|
12
|
+
path: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type GitMaterialRef = z.infer<typeof GitMaterialRefSchema>;
|
|
15
|
+
export declare const CacheMaterialRefSchema: z.ZodObject<{
|
|
16
|
+
kind: z.ZodLiteral<"cache">;
|
|
17
|
+
key: z.ZodString;
|
|
18
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
19
|
+
sensitivity: z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
"public-reproducible": "public-reproducible";
|
|
21
|
+
"trusted-only": "trusted-only";
|
|
22
|
+
}>>;
|
|
23
|
+
path: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type CacheMaterialRef = z.infer<typeof CacheMaterialRefSchema>;
|
|
26
|
+
export declare const ArtifactMaterialRefSchema: z.ZodObject<{
|
|
27
|
+
kind: z.ZodLiteral<"artifact">;
|
|
28
|
+
artifactId: z.ZodString;
|
|
29
|
+
digest: z.ZodString;
|
|
30
|
+
producerAttemptId: z.ZodOptional<z.ZodString>;
|
|
31
|
+
path: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type ArtifactMaterialRef = z.infer<typeof ArtifactMaterialRefSchema>;
|
|
34
|
+
export declare const MaterialRefSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
35
|
+
kind: z.ZodLiteral<"git">;
|
|
36
|
+
repositoryId: z.ZodString;
|
|
37
|
+
cloneUrl: z.ZodURL;
|
|
38
|
+
sha: z.ZodString;
|
|
39
|
+
path: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
41
|
+
kind: z.ZodLiteral<"cache">;
|
|
42
|
+
key: z.ZodString;
|
|
43
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
44
|
+
sensitivity: z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
"public-reproducible": "public-reproducible";
|
|
46
|
+
"trusted-only": "trusted-only";
|
|
47
|
+
}>>;
|
|
48
|
+
path: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
50
|
+
kind: z.ZodLiteral<"artifact">;
|
|
51
|
+
artifactId: z.ZodString;
|
|
52
|
+
digest: z.ZodString;
|
|
53
|
+
producerAttemptId: z.ZodOptional<z.ZodString>;
|
|
54
|
+
path: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>], "kind">;
|
|
56
|
+
export type MaterialRef = z.infer<typeof MaterialRefSchema>;
|
|
57
|
+
export declare const MaterialOutputSchema: z.ZodObject<{
|
|
58
|
+
kind: z.ZodLiteral<"artifact">;
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
paths: z.ZodArray<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type MaterialOutput = z.infer<typeof MaterialOutputSchema>;
|
|
63
|
+
export declare const WorkerMaterialDescriptorSchema: z.ZodObject<{
|
|
64
|
+
id: z.ZodString;
|
|
65
|
+
name: z.ZodOptional<z.ZodString>;
|
|
66
|
+
description: z.ZodOptional<z.ZodString>;
|
|
67
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
+
hardware: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
capabilityId: z.ZodOptional<z.ZodString>;
|
|
72
|
+
requiredContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
|
+
optionalContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
74
|
+
config: z.ZodOptional<z.ZodUnknown>;
|
|
75
|
+
retention: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
76
|
+
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
maxEntries: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
cascadeFrom: z.ZodOptional<z.ZodString>;
|
|
80
|
+
ageField: z.ZodOptional<z.ZodString>;
|
|
81
|
+
reason: z.ZodString;
|
|
82
|
+
enforcedBy: z.ZodOptional<z.ZodString>;
|
|
83
|
+
}, z.core.$strip>]>>;
|
|
84
|
+
kind: z.ZodLiteral<"workers/material">;
|
|
85
|
+
materialKinds: z.ZodArray<z.ZodEnum<{
|
|
86
|
+
cache: "cache";
|
|
87
|
+
git: "git";
|
|
88
|
+
artifact: "artifact";
|
|
89
|
+
}>>;
|
|
90
|
+
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
91
|
+
maxEntries: z.ZodOptional<z.ZodNumber>;
|
|
92
|
+
supportsCapture: z.ZodDefault<z.ZodBoolean>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
export type WorkerMaterialDescriptor = z.infer<typeof WorkerMaterialDescriptorSchema>;
|
|
95
|
+
export declare const WorkerMaterialTrustSchema: z.ZodObject<{
|
|
96
|
+
untrusted: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
promoteQuarantine: z.ZodDefault<z.ZodBoolean>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
export type WorkerMaterialTrust = z.infer<typeof WorkerMaterialTrustSchema>;
|
|
100
|
+
export interface WorkerMaterialStoreEntry {
|
|
101
|
+
readonly digest: string;
|
|
102
|
+
readonly bytes: Uint8Array;
|
|
103
|
+
readonly entries?: number;
|
|
104
|
+
}
|
|
105
|
+
/** The claimant's artifact-store port; the `ci/artifacts` owner satisfies it structurally. */
|
|
106
|
+
export interface WorkerMaterialArtifactStore {
|
|
107
|
+
get(artifactId: string): Promise<WorkerMaterialStoreEntry & {
|
|
108
|
+
readonly name: string;
|
|
109
|
+
}>;
|
|
110
|
+
put(input: {
|
|
111
|
+
name: string;
|
|
112
|
+
bytes: Uint8Array;
|
|
113
|
+
}): Promise<WorkerMaterialStoreEntry & {
|
|
114
|
+
readonly artifactId: string;
|
|
115
|
+
}>;
|
|
116
|
+
}
|
|
117
|
+
export interface WorkerMaterialFilesystem {
|
|
118
|
+
mkdir(path: string, options?: {
|
|
119
|
+
recursive?: boolean;
|
|
120
|
+
}): Promise<void>;
|
|
121
|
+
writeFile(path: string, bytes: Uint8Array): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
export interface WorkerMaterialContext {
|
|
124
|
+
readonly runtime: RuntimeRef;
|
|
125
|
+
readonly jobId: string;
|
|
126
|
+
readonly attemptId: string;
|
|
127
|
+
/** The job's declared workspace root; never an ambient home or another job's directory. */
|
|
128
|
+
readonly workspace: string;
|
|
129
|
+
readonly trust: WorkerMaterialTrust;
|
|
130
|
+
/** Claimant-supplied credential/environment values; never serialized into the ref. */
|
|
131
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
132
|
+
/** Claimant-owned store ports; the material never constructs a provider. */
|
|
133
|
+
readonly cacheStore?: CacheByteStore;
|
|
134
|
+
readonly artifactStore?: WorkerMaterialArtifactStore;
|
|
135
|
+
readonly fs?: WorkerMaterialFilesystem;
|
|
136
|
+
readonly signal?: AbortSignal;
|
|
137
|
+
}
|
|
138
|
+
export interface WorkerMaterialReceipt {
|
|
139
|
+
readonly kind: MaterialRef['kind'];
|
|
140
|
+
/** Content digest the implementation verified after restore/capture. */
|
|
141
|
+
readonly digest: string;
|
|
142
|
+
/** Absolute destination or source path inside the job workspace. */
|
|
143
|
+
readonly path: string;
|
|
144
|
+
/** Present when the material has a byte/entry count (archives); a git commit is identified by its SHA. */
|
|
145
|
+
readonly bytes?: number;
|
|
146
|
+
readonly entries?: number;
|
|
147
|
+
}
|
|
148
|
+
export interface WorkerMaterial {
|
|
149
|
+
restore(input: MaterialRef, context: WorkerMaterialContext): Promise<WorkerMaterialReceipt>;
|
|
150
|
+
capture?(input: MaterialOutput, context: WorkerMaterialContext): Promise<WorkerMaterialReceipt>;
|
|
151
|
+
}
|
|
152
|
+
export declare function workersMaterialRefusal(reason: 'workers-material-unavailable' | 'workers-material-ref-invalid' | 'workers-material-cap-exceeded' | 'workers-material-digest-mismatch' | 'workers-material-trust-refused' | 'workers-material-capture-refused', message: string, details: Record<string, string | number | boolean | string[]>): CapabilityError;
|
|
153
|
+
//# sourceMappingURL=material.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"material.d.ts","sourceRoot":"","sources":["../../../src/kinds/schemas/material.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,eAA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AAC,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0GAA0G;IAC1G,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC5F,OAAO,CAAC,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAChG;AAED,wBAAgB,sBAAsB,CACrC,MAAM,EACH,8BAA8B,GAC9B,8BAA8B,GAC9B,+BAA+B,GAC/B,kCAAkC,GAClC,gCAAgC,GAChC,kCAAkC,EACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC,GAC3D,eAAe,CAUjB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { CapabilityError } from '@vibesdotdev/kernel';
|
|
3
|
+
import { RuntimeDescriptorSchema } from '@vibesdotdev/kernel/schemas/descriptor';
|
|
4
|
+
export const WORKERS_MATERIAL_KIND = 'workers/material';
|
|
5
|
+
/** A repository-relative path a material may write or capture. */
|
|
6
|
+
export const MaterialPathSchema = z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(512)
|
|
10
|
+
.refine((path) => !path.startsWith('/') &&
|
|
11
|
+
path !== '.' &&
|
|
12
|
+
!path.split('/').includes('..') &&
|
|
13
|
+
path !== '.git' &&
|
|
14
|
+
!path.startsWith('.git/') &&
|
|
15
|
+
/^[A-Za-z0-9._/-]+$/.test(path), 'expected a safe repository-relative material path');
|
|
16
|
+
export const GitMaterialRefSchema = z.object({
|
|
17
|
+
kind: z.literal('git'),
|
|
18
|
+
repositoryId: z.string().min(1),
|
|
19
|
+
/** The canonical source URL; the claimant supplies the credential separately. */
|
|
20
|
+
cloneUrl: z.url(),
|
|
21
|
+
/** Full immutable commit SHA; a branch or tag is never execution authority. */
|
|
22
|
+
sha: z.string().regex(/^[0-9a-f]{40}$/i, 'expected a full commit SHA'),
|
|
23
|
+
/** Checkout destination under the job workspace; omitted means the workspace root. */
|
|
24
|
+
path: MaterialPathSchema.optional()
|
|
25
|
+
});
|
|
26
|
+
export const CacheMaterialRefSchema = z.object({
|
|
27
|
+
kind: z.literal('cache'),
|
|
28
|
+
/** The canonical cache task hash, not a mutable branch or label. */
|
|
29
|
+
key: z.string().min(1).max(128).regex(/^[a-z0-9][a-z0-9._-]*$/, 'expected a cache task key'),
|
|
30
|
+
namespace: z.string().min(1).max(128).optional(),
|
|
31
|
+
sensitivity: z.enum(['public-reproducible', 'trusted-only']).optional(),
|
|
32
|
+
/** Destination file under the job workspace; omitted means the CI cache directory. */
|
|
33
|
+
path: MaterialPathSchema.optional()
|
|
34
|
+
});
|
|
35
|
+
export const ArtifactMaterialRefSchema = z.object({
|
|
36
|
+
kind: z.literal('artifact'),
|
|
37
|
+
artifactId: z.string().min(1),
|
|
38
|
+
/** The content digest the producing attempt reported. */
|
|
39
|
+
digest: z.string().regex(/^[0-9a-f]{64}$/i, 'expected a SHA-256 artifact digest'),
|
|
40
|
+
producerAttemptId: z.string().min(1).optional(),
|
|
41
|
+
/** Destination file under the job workspace; omitted means the CI artifact path. */
|
|
42
|
+
path: MaterialPathSchema.optional()
|
|
43
|
+
});
|
|
44
|
+
export const MaterialRefSchema = z.discriminatedUnion('kind', [
|
|
45
|
+
GitMaterialRefSchema,
|
|
46
|
+
CacheMaterialRefSchema,
|
|
47
|
+
ArtifactMaterialRefSchema
|
|
48
|
+
]);
|
|
49
|
+
export const MaterialOutputSchema = z.object({
|
|
50
|
+
kind: z.literal('artifact'),
|
|
51
|
+
name: z.string().min(1).max(128).regex(/^[a-z0-9][a-z0-9._-]*$/, 'expected an artifact name'),
|
|
52
|
+
paths: z.array(MaterialPathSchema).min(1).max(64)
|
|
53
|
+
});
|
|
54
|
+
export const WorkerMaterialDescriptorSchema = RuntimeDescriptorSchema.extend({
|
|
55
|
+
kind: z.literal(WORKERS_MATERIAL_KIND),
|
|
56
|
+
/** Material refs this implementation can restore. */
|
|
57
|
+
materialKinds: z.array(z.enum(['git', 'cache', 'artifact'])).min(1),
|
|
58
|
+
/** Hard caps the implementation enforces before writing. */
|
|
59
|
+
maxBytes: z.number().int().positive().optional(),
|
|
60
|
+
maxEntries: z.number().int().positive().optional(),
|
|
61
|
+
/** Whether this implementation can capture declared outputs. */
|
|
62
|
+
supportsCapture: z.boolean().default(false)
|
|
63
|
+
});
|
|
64
|
+
export const WorkerMaterialTrustSchema = z.object({
|
|
65
|
+
untrusted: z.boolean().default(false),
|
|
66
|
+
/** A trusted ref may promote a quarantine cache only after the control plane admits it. */
|
|
67
|
+
promoteQuarantine: z.boolean().default(false)
|
|
68
|
+
});
|
|
69
|
+
export function workersMaterialRefusal(reason, message, details) {
|
|
70
|
+
const code = reason === 'workers-material-ref-invalid' || reason === 'workers-material-cap-exceeded'
|
|
71
|
+
? 'INVALID_INPUT'
|
|
72
|
+
: reason === 'workers-material-trust-refused' || reason === 'workers-material-capture-refused'
|
|
73
|
+
? 'PERMISSION_DENIED'
|
|
74
|
+
: reason === 'workers-material-digest-mismatch'
|
|
75
|
+
? 'CONFLICT'
|
|
76
|
+
: 'UNAVAILABLE';
|
|
77
|
+
return new CapabilityError(message, code, { reason, retryable: false, details });
|
|
78
|
+
}
|
|
79
|
+
//# sourceMapp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rC,MAMqC,EACrC,OAAe,EACf,OAA6D;IAE7D,MAAM,IAAI,GACT,MAAM,KAAK,8BAA8B,IAAI,MAAM,KAAK,+BAA+B;QACtF,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,MAAM,KAAK,gCAAgC,IAAI,MAAM,KAAK,kCAAkC;YAC7F,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,MAAM,KAAK,kCAAkC;gBAC9C,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,aAAa,CAAC;IACpB,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* maintenance.storage-sync Job Descriptor
|
|
3
3
|
*
|
|
4
|
-
* Scheduled job that
|
|
5
|
-
* Runs every 5 minutes when
|
|
4
|
+
* Scheduled job that runs declared local adapter migrations, then syncs local
|
|
5
|
+
* storage manifests to/from cloud. Runs every 5 minutes when the host enables
|
|
6
|
+
* the schedule.
|
|
6
7
|
*/
|
|
7
8
|
import type { JobDescriptor } from '@vibesdotdev/kernel/kinds';
|
|
8
9
|
export type { StorageSyncJobData, StorageSyncJobResult, ManifestSyncResult } from './schemas/storage-sync.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance.storage-sync.descriptor.d.ts","sourceRoot":"","sources":["../../../../src/maintenance/jobs/storage-sync/maintenance.storage-sync.descriptor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"maintenance.storage-sync.descriptor.d.ts","sourceRoot":"","sources":["../../../../src/maintenance/jobs/storage-sync/maintenance.storage-sync.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI/D,YAAY,EACX,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,wBAAwB,eAyBnC,CAAC;AAEH,eAAe,wBAAwB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* maintenance.storage-sync Job Descriptor
|
|
3
3
|
*
|
|
4
|
-
* Scheduled job that
|
|
5
|
-
* Runs every 5 minutes when
|
|
4
|
+
* Scheduled job that runs declared local adapter migrations, then syncs local
|
|
5
|
+
* storage manifests to/from cloud. Runs every 5 minutes when the host enables
|
|
6
|
+
* the schedule.
|
|
6
7
|
*/
|
|
7
8
|
import { createRuntimeAsset } from '@vibesdotdev/kernel';
|
|
8
9
|
import { storageSyncJobDataSchema, storageSyncJobResultSchema } from "./schemas/storage-sync.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance.storage-sync.descriptor.js","sourceRoot":"","sources":["../../../../src/maintenance/jobs/storage-sync/maintenance.storage-sync.descriptor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"maintenance.storage-sync.descriptor.js","sourceRoot":"","sources":["../../../../src/maintenance/jobs/storage-sync/maintenance.storage-sync.descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AASjG,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,CAAgB;IACzE,IAAI,EAAE,aAAa;IACnB,EAAE,EAAE,0BAA0B;IAC9B,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,gDAAgD;IAE7D,KAAK,EAAE,kBAAkB;IACzB,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,aAAa;IACvB,2EAA2E;IAC3E,4EAA4E;IAC5E,kEAAkE;IAClE,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE;IAEjE,OAAO,EAAE;QACR,KAAK,EAAE,wBAAwB;QAC/B,MAAM,EAAE,0BAA0B;KAClC;IAED,QAAQ,EAAE,CAAC,UAAU,CAAC;IAEtB,IAAI,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC;IACjD,OAAO,EAAE,IAAI;CACb,CAAC,CAAC;AAEH,eAAe,wBAAwB,CAAC"}
|
|
@@ -20,6 +20,11 @@ export declare class MaintenanceStorageSyncJob implements JobImplementation<Stor
|
|
|
20
20
|
handle(context: JobExecutionContext<StorageSyncJobData>): Promise<StorageSyncJobResult>;
|
|
21
21
|
private emptyResult;
|
|
22
22
|
private runSync;
|
|
23
|
+
/**
|
|
24
|
+
* Local adapter migration before cloud sync. Sync state carries the last
|
|
25
|
+
* selected adapter per manifest, so a stable store costs no document read.
|
|
26
|
+
*/
|
|
27
|
+
private runMigrations;
|
|
23
28
|
private getEligibleManifests;
|
|
24
29
|
private getEligibleBridges;
|
|
25
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance.storage-sync.impl.consumer.d.ts","sourceRoot":"","sources":["../../../../src/maintenance/jobs/storage-sync/maintenance.storage-sync.impl.consumer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,KAAK,EACX,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"maintenance.storage-sync.impl.consumer.d.ts","sourceRoot":"","sources":["../../../../src/maintenance/jobs/storage-sync/maintenance.storage-sync.impl.consumer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,KAAK,EACX,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,2BAA2B,CAAC;AAYnC,qBAAa,yBAA0B,YAAW,iBAAiB,CAClE,kBAAkB,EAClB,oBAAoB,CACpB;IACA,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAG,WAAW,CAAU;IACrC,QAAQ,CAAC,SAAS,EAAG,QAAQ,CAAU;IAEvC,OAAO,CAAC,OAAO,CAAe;IAE9B,OAAO,KAAK,MAAM,GAEjB;gBAEW,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,YAAY,CAAA;KAAE;IAMnE,MAAM,CAAC,OAAO,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiE7F,OAAO,CAAC,WAAW;YAsBL,OAAO;IAoJrB;;;OAGG;YACW,aAAa;YA0Bb,oBAAoB;YAYpB,kBAAkB;CAahC;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { settle } from "../../../core/settle.js";
|
|
8
8
|
import { getLogger } from '@vibesdotdev/logging';
|
|
9
9
|
import { syncManifest } from '@vibesdotdev/storage/sync/sync-manifest';
|
|
10
|
+
import { runDeclaredStorageMigrations } from '@vibesdotdev/storage/sync/migrate-declared';
|
|
10
11
|
import { SyncBridge } from '@vibesdotdev/storage/sync/sync-bridge';
|
|
11
12
|
import { resolveSyncTarget } from '@vibesdotdev/storage/sync/resolve-sync-target';
|
|
12
13
|
const LOG_PREFIX = '[maintenance.storage-sync]';
|
|
@@ -28,6 +29,19 @@ export class MaintenanceStorageSyncJob {
|
|
|
28
29
|
const { dryRun, force, manifestIds } = context.data;
|
|
29
30
|
const startTime = Date.now();
|
|
30
31
|
this.logger.info(`${LOG_PREFIX} Starting storage sync`, { dryRun, force });
|
|
32
|
+
// Local adapter migrations run even when cloud sync has no targets: a
|
|
33
|
+
// config change is local state, not a network operation. Failures are
|
|
34
|
+
// reported in the result and never stop the cloud pass.
|
|
35
|
+
const migrationOutcome = await settle(() => this.runMigrations(dryRun, manifestIds));
|
|
36
|
+
const migrations = migrationOutcome.ok
|
|
37
|
+
? migrationOutcome.value
|
|
38
|
+
: { results: [], receipts: {}, errors: 1 };
|
|
39
|
+
if (!migrationOutcome.ok) {
|
|
40
|
+
const message = migrationOutcome.caught instanceof Error
|
|
41
|
+
? migrationOutcome.caught.message
|
|
42
|
+
: migrationOutcome.caught.description;
|
|
43
|
+
this.logger.warn(`${LOG_PREFIX} Local adapter migration sweep failed`, { error: message });
|
|
44
|
+
}
|
|
31
45
|
const runOutcome = await settle(async () => {
|
|
32
46
|
const eligibleManifests = await this.getEligibleManifests(manifestIds);
|
|
33
47
|
const eligibleBridges = await this.getEligibleBridges(manifestIds);
|
|
@@ -37,13 +51,14 @@ export class MaintenanceStorageSyncJob {
|
|
|
37
51
|
bridges: eligibleBridges.length
|
|
38
52
|
});
|
|
39
53
|
if (eligibleManifests.length === 0 && eligibleBridges.length === 0) {
|
|
40
|
-
return this.emptyResult(dryRun, syncEnabled, startTime);
|
|
54
|
+
return this.emptyResult(dryRun, syncEnabled, startTime, migrations);
|
|
41
55
|
}
|
|
42
56
|
return await this.runSync(eligibleManifests, eligibleBridges, {
|
|
43
57
|
dryRun,
|
|
44
58
|
syncEnabled,
|
|
45
59
|
startTime,
|
|
46
|
-
force
|
|
60
|
+
force,
|
|
61
|
+
migrations
|
|
47
62
|
});
|
|
48
63
|
});
|
|
49
64
|
if (runOutcome.ok) {
|
|
@@ -61,12 +76,14 @@ export class MaintenanceStorageSyncJob {
|
|
|
61
76
|
conflicts: 0,
|
|
62
77
|
errors: 1,
|
|
63
78
|
results: [{ manifestId: '*', action: 'error', message: rootMsg }],
|
|
79
|
+
migrations: migrations.results,
|
|
80
|
+
migrationErrors: migrations.errors,
|
|
64
81
|
durationMs: Date.now() - startTime
|
|
65
82
|
};
|
|
66
83
|
}
|
|
67
|
-
emptyResult(dryRun, syncEnabled, startTime) {
|
|
84
|
+
emptyResult(dryRun, syncEnabled, startTime, migrations) {
|
|
68
85
|
return {
|
|
69
|
-
success:
|
|
86
|
+
success: migrations.errors === 0,
|
|
70
87
|
dryRun,
|
|
71
88
|
syncEnabled,
|
|
72
89
|
totalManifests: 0,
|
|
@@ -75,6 +92,8 @@ export class MaintenanceStorageSyncJob {
|
|
|
75
92
|
conflicts: 0,
|
|
76
93
|
errors: 0,
|
|
77
94
|
results: [],
|
|
95
|
+
migrations: migrations.results,
|
|
96
|
+
migrationErrors: migrations.errors,
|
|
78
97
|
durationMs: Date.now() - startTime
|
|
79
98
|
};
|
|
80
99
|
}
|
|
@@ -175,7 +194,7 @@ export class MaintenanceStorageSyncJob {
|
|
|
175
194
|
const errors = results.filter((r) => r.action === 'error').length;
|
|
176
195
|
this.logger.info(`${LOG_PREFIX} Sync complete`, { synced, skipped, conflicts, errors });
|
|
177
196
|
return {
|
|
178
|
-
success: errors === 0,
|
|
197
|
+
success: errors === 0 && opts.migrations.errors === 0,
|
|
179
198
|
dryRun: opts.dryRun,
|
|
180
199
|
syncEnabled: opts.syncEnabled,
|
|
181
200
|
totalManifests: manifests.length + bridges.length,
|
|
@@ -184,9 +203,35 @@ export class MaintenanceStorageSyncJob {
|
|
|
184
203
|
conflicts,
|
|
185
204
|
errors,
|
|
186
205
|
results,
|
|
206
|
+
migrations: opts.migrations.results,
|
|
207
|
+
migrationErrors: opts.migrations.errors,
|
|
187
208
|
durationMs: Date.now() - opts.startTime
|
|
188
209
|
};
|
|
189
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Local adapter migration before cloud sync. Sync state carries the last
|
|
213
|
+
* selected adapter per manifest, so a stable store costs no document read.
|
|
214
|
+
*/
|
|
215
|
+
async runMigrations(dryRun, manifestIds) {
|
|
216
|
+
const { loadSyncState, saveSyncState } = await import('@vibesdotdev/storage/sync/sync-state.consumer');
|
|
217
|
+
const syncState = await loadSyncState(this.runtime);
|
|
218
|
+
const run = await runDeclaredStorageMigrations(this.runtime, {
|
|
219
|
+
dryRun,
|
|
220
|
+
manifestIds,
|
|
221
|
+
receipts: syncState.adapterReceipts ?? {}
|
|
222
|
+
});
|
|
223
|
+
if (!dryRun) {
|
|
224
|
+
syncState.adapterReceipts = run.receipts;
|
|
225
|
+
await saveSyncState(syncState, this.runtime);
|
|
226
|
+
}
|
|
227
|
+
if (run.results.length > 0) {
|
|
228
|
+
this.logger.info(`${LOG_PREFIX} Local adapter migration results`, {
|
|
229
|
+
results: run.results.length,
|
|
230
|
+
errors: run.errors
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return run;
|
|
234
|
+
}
|
|
190
235
|
async getEligibleManifests(filterIds) {
|
|
191
236
|
const descriptors = this.runtime.query('storage/manifest').descriptors();
|
|
192
237
|
return descriptors
|