@mfdaves/okf-mcp 0.9.1 → 0.12.0-rc.1
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/CHANGELOG.md +69 -0
- package/README.md +172 -17
- package/bin/okf-mcp.js +6 -1
- package/okf/okf-mcp/policies/authoring-safety.md +11 -1
- package/package.json +17 -5
- package/server.json +2 -2
- package/src/assets.js +165 -73
- package/src/authoring/candidates.js +391 -0
- package/src/authoring/git-preflight.js +225 -0
- package/src/authoring/git-publish.js +776 -0
- package/src/authoring/live.js +789 -0
- package/src/authoring/paths.js +112 -0
- package/src/authoring/policy-hook.js +221 -0
- package/src/authoring/proposal-policy.js +137 -0
- package/src/authoring/receipts.js +329 -0
- package/src/authoring/render.js +38 -0
- package/src/authoring/shared.js +75 -0
- package/src/authoring/staging.js +216 -0
- package/src/authoring.js +386 -287
- package/src/cache/files.js +147 -0
- package/src/cache/lock.js +201 -0
- package/src/cache/paths.js +197 -0
- package/src/cache/store.js +703 -0
- package/src/catalog-text.js +19 -0
- package/src/cli.js +184 -151
- package/src/computation.js +99 -61
- package/src/context/assemble.js +567 -0
- package/src/context/cli-options.js +88 -0
- package/src/context/score.js +234 -0
- package/src/context/sections.js +274 -0
- package/src/embed/interface.js +160 -0
- package/src/embed/openai.js +715 -0
- package/src/embed/prepare.js +182 -0
- package/src/embed/units.js +96 -0
- package/src/git-source.js +112 -52
- package/src/graph.js +95 -37
- package/src/http-server.js +36 -17
- package/src/index.js +15 -0
- package/src/indexer/assemble.js +566 -0
- package/src/indexer/build.js +290 -0
- package/src/indexer/cache.js +81 -0
- package/src/indexer/edges.js +430 -0
- package/src/indexer/index.js +44 -0
- package/src/indexer/paths.js +178 -0
- package/src/indexer/resolve.js +282 -0
- package/src/indexer/update.js +720 -0
- package/src/indexer.js +3 -1068
- package/src/live-authoring.js +4 -2329
- package/src/markdown.js +21 -16
- package/src/mcp/registry.js +328 -0
- package/src/mcp/resources.js +45 -0
- package/src/mcp/server.js +472 -0
- package/src/mcp/tools/catalog.js +244 -0
- package/src/mcp/tools/computation.js +83 -0
- package/src/mcp/tools/context.js +133 -0
- package/src/mcp/tools/graph.js +167 -0
- package/src/mcp/tools/live-authoring.js +316 -0
- package/src/mcp/tools/migration.js +86 -0
- package/src/mcp/tools/producers.js +79 -0
- package/src/mcp/tools/proposals.js +213 -0
- package/src/mcp/tools/provenance.js +87 -0
- package/src/mcp/tools/remote.js +79 -0
- package/src/mcp/tools/search.js +242 -0
- package/src/mcp-server.js +3 -1611
- package/src/migration.js +431 -253
- package/src/parser.js +245 -130
- package/src/plugins.js +71 -48
- package/src/policy/write-policy.js +713 -0
- package/src/producer-publisher.js +195 -77
- package/src/producers.js +265 -101
- package/src/project.js +277 -93
- package/src/remote.js +96 -61
- package/src/search/cli-options.js +107 -0
- package/src/search/confidence.js +61 -0
- package/src/search/dense.js +304 -0
- package/src/search/embedding-cli.js +57 -0
- package/src/search/embedding-config.js +217 -0
- package/src/search/fusion.js +249 -0
- package/src/search/hybrid.js +526 -0
- package/src/search/languages.js +200 -0
- package/src/search/lexical.js +695 -0
- package/src/search/query.js +620 -0
- package/src/search/stem/among.js +43 -0
- package/src/search/stem/base-stemmer.js +311 -0
- package/src/search/stem/en-regions.js +456 -0
- package/src/search/stem/en-suffixes.js +664 -0
- package/src/search/stem/en-tables.js +176 -0
- package/src/search/stem/en.js +238 -0
- package/src/search/stem/it-regions.js +459 -0
- package/src/search/stem/it-suffixes.js +471 -0
- package/src/search/stem/it-tables.js +257 -0
- package/src/search/stem/it.js +155 -0
- package/src/search-index.js +2 -81
- package/src/search.js +2 -252
- package/src/store.js +134 -81
- package/src/v02.js +301 -105
- package/src/validation.js +24 -20
|
@@ -28,7 +28,8 @@ function canonical(value) {
|
|
|
28
28
|
return encoded === undefined ? "null" : encoded;
|
|
29
29
|
}
|
|
30
30
|
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
31
|
-
return `{${Object.keys(value)
|
|
31
|
+
return `{${Object.keys(value)
|
|
32
|
+
.sort()
|
|
32
33
|
.map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`)
|
|
33
34
|
.join(",")}}`;
|
|
34
35
|
}
|
|
@@ -54,9 +55,7 @@ function stableDigest(content) {
|
|
|
54
55
|
const parsed = generatedMapping(content);
|
|
55
56
|
if (!parsed || parsed.generated.at === undefined) return sha256(content);
|
|
56
57
|
const stable = Object.assign({}, parsed.split.frontmatter, {
|
|
57
|
-
generated: Object.fromEntries(
|
|
58
|
-
Object.entries(parsed.generated).filter(([key]) => key !== "at"),
|
|
59
|
-
),
|
|
58
|
+
generated: Object.fromEntries(Object.entries(parsed.generated).filter(([key]) => key !== "at")),
|
|
60
59
|
});
|
|
61
60
|
return sha256(`${canonical(stable)}\u0000${parsed.split.body}`);
|
|
62
61
|
}
|
|
@@ -66,7 +65,9 @@ function stableDigest(content) {
|
|
|
66
65
|
// manifest lists stays on disk.
|
|
67
66
|
function hasGeneratedProvenance(content) {
|
|
68
67
|
const parsed = generatedMapping(content);
|
|
69
|
-
return Boolean(
|
|
68
|
+
return Boolean(
|
|
69
|
+
parsed && (parsed.generated.by !== undefined || parsed.generated.at !== undefined),
|
|
70
|
+
);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
function isInside(root, target) {
|
|
@@ -75,40 +76,72 @@ function isInside(root, target) {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
function normalizeProducedPath(value) {
|
|
78
|
-
const raw = String(value || "")
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const raw = String(value || "")
|
|
80
|
+
.trim()
|
|
81
|
+
.replace(/\\/g, "/");
|
|
82
|
+
if (
|
|
83
|
+
!raw ||
|
|
84
|
+
raw.startsWith("/") ||
|
|
85
|
+
/^[A-Za-z]:\//.test(raw) ||
|
|
86
|
+
/[\u0000-\u001f\u007f]/.test(raw)
|
|
87
|
+
) {
|
|
88
|
+
throw new ProducerPublicationError(
|
|
89
|
+
"Producer paths must be safe bundle-relative Markdown paths.",
|
|
90
|
+
"invalid_producer_path",
|
|
91
|
+
);
|
|
81
92
|
}
|
|
82
93
|
const parts = raw.split("/");
|
|
83
94
|
if (parts.some((part) => !part || part === "." || part === ".." || part.startsWith("."))) {
|
|
84
|
-
throw new ProducerPublicationError(
|
|
95
|
+
throw new ProducerPublicationError(
|
|
96
|
+
"Producer paths cannot contain empty, hidden, dot, or parent segments.",
|
|
97
|
+
"invalid_producer_path",
|
|
98
|
+
);
|
|
85
99
|
}
|
|
86
100
|
const normalized = path.posix.normalize(raw);
|
|
87
101
|
if (!normalized.toLowerCase().endsWith(".md")) {
|
|
88
|
-
throw new ProducerPublicationError(
|
|
102
|
+
throw new ProducerPublicationError(
|
|
103
|
+
"Producer output files must be Markdown documents.",
|
|
104
|
+
"invalid_producer_path",
|
|
105
|
+
);
|
|
89
106
|
}
|
|
90
107
|
return normalized;
|
|
91
108
|
}
|
|
92
109
|
|
|
93
110
|
function normalizeProducedFiles(files) {
|
|
94
111
|
if (!Array.isArray(files) || files.length === 0) {
|
|
95
|
-
throw new ProducerPublicationError(
|
|
112
|
+
throw new ProducerPublicationError(
|
|
113
|
+
"Producer generate() must return a non-empty files array.",
|
|
114
|
+
"invalid_producer_output",
|
|
115
|
+
);
|
|
96
116
|
}
|
|
97
117
|
const seen = new Set();
|
|
98
|
-
return files
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
return files
|
|
119
|
+
.map((file) => {
|
|
120
|
+
if (!file || typeof file !== "object" || Array.isArray(file)) {
|
|
121
|
+
throw new ProducerPublicationError(
|
|
122
|
+
"Each producer file must be an object.",
|
|
123
|
+
"invalid_producer_output",
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
const relativePath = normalizeProducedPath(file.path);
|
|
127
|
+
if (seen.has(relativePath)) {
|
|
128
|
+
throw new ProducerPublicationError(
|
|
129
|
+
"Producer output paths must be unique.",
|
|
130
|
+
"duplicate_producer_path",
|
|
131
|
+
{ path: relativePath },
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
seen.add(relativePath);
|
|
135
|
+
if (typeof file.content !== "string") {
|
|
136
|
+
throw new ProducerPublicationError(
|
|
137
|
+
"Producer file content must be a string.",
|
|
138
|
+
"invalid_producer_content",
|
|
139
|
+
{ path: relativePath },
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
return { path: relativePath, content: file.content, sha256: sha256(file.content) };
|
|
143
|
+
})
|
|
144
|
+
.sort((left, right) => left.path.localeCompare(right.path));
|
|
112
145
|
}
|
|
113
146
|
|
|
114
147
|
function assertRegularPath(root, relativePath) {
|
|
@@ -124,13 +157,25 @@ function assertRegularPath(root, relativePath) {
|
|
|
124
157
|
throw error;
|
|
125
158
|
}
|
|
126
159
|
if (stat.isSymbolicLink()) {
|
|
127
|
-
throw new ProducerPublicationError(
|
|
160
|
+
throw new ProducerPublicationError(
|
|
161
|
+
"Producer-managed paths cannot traverse symbolic links.",
|
|
162
|
+
"producer_path_symlink",
|
|
163
|
+
{ path: parts.slice(0, index + 1).join("/") },
|
|
164
|
+
);
|
|
128
165
|
}
|
|
129
166
|
if (index < parts.length - 1 && !stat.isDirectory()) {
|
|
130
|
-
throw new ProducerPublicationError(
|
|
167
|
+
throw new ProducerPublicationError(
|
|
168
|
+
"A producer-managed path parent is not a directory.",
|
|
169
|
+
"producer_path_parent_not_directory",
|
|
170
|
+
{ path: parts.slice(0, index + 1).join("/") },
|
|
171
|
+
);
|
|
131
172
|
}
|
|
132
173
|
if (index === parts.length - 1 && !stat.isFile()) {
|
|
133
|
-
throw new ProducerPublicationError(
|
|
174
|
+
throw new ProducerPublicationError(
|
|
175
|
+
"Producer-managed files must be regular files.",
|
|
176
|
+
"producer_path_not_file",
|
|
177
|
+
{ path: relativePath },
|
|
178
|
+
);
|
|
134
179
|
}
|
|
135
180
|
});
|
|
136
181
|
}
|
|
@@ -145,17 +190,35 @@ function readManifest(root, producer) {
|
|
|
145
190
|
content = fs.readFileSync(manifestPath);
|
|
146
191
|
manifest = JSON.parse(content.toString("utf8"));
|
|
147
192
|
} catch {
|
|
148
|
-
throw new ProducerPublicationError(
|
|
193
|
+
throw new ProducerPublicationError(
|
|
194
|
+
"The producer ownership manifest is invalid.",
|
|
195
|
+
"invalid_producer_manifest",
|
|
196
|
+
);
|
|
149
197
|
}
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
198
|
+
if (
|
|
199
|
+
!manifest ||
|
|
200
|
+
manifest.version !== 1 ||
|
|
201
|
+
manifest.producer !== producer.type ||
|
|
202
|
+
manifest.bundle !== producer.bundle ||
|
|
203
|
+
!Array.isArray(manifest.files)
|
|
204
|
+
) {
|
|
205
|
+
throw new ProducerPublicationError(
|
|
206
|
+
"The producer ownership manifest does not match this configured producer.",
|
|
207
|
+
"invalid_producer_manifest",
|
|
208
|
+
);
|
|
153
209
|
}
|
|
154
210
|
const owned = new Map();
|
|
155
211
|
manifest.files.forEach((entry) => {
|
|
156
212
|
const relativePath = normalizeProducedPath(entry && entry.path);
|
|
157
|
-
if (
|
|
158
|
-
|
|
213
|
+
if (
|
|
214
|
+
owned.has(relativePath) ||
|
|
215
|
+
!entry ||
|
|
216
|
+
!/^sha256:[a-f0-9]{64}$/.test(String(entry.sha256 || ""))
|
|
217
|
+
) {
|
|
218
|
+
throw new ProducerPublicationError(
|
|
219
|
+
"The producer ownership manifest contains an invalid file entry.",
|
|
220
|
+
"invalid_producer_manifest",
|
|
221
|
+
);
|
|
159
222
|
}
|
|
160
223
|
owned.set(relativePath, String(entry.sha256));
|
|
161
224
|
});
|
|
@@ -168,11 +231,19 @@ function verifyOwnedFiles(root, owned) {
|
|
|
168
231
|
assertRegularPath(root, relativePath);
|
|
169
232
|
const absolutePath = path.join(root, ...relativePath.split("/"));
|
|
170
233
|
if (!fs.existsSync(absolutePath)) {
|
|
171
|
-
throw new ProducerPublicationError(
|
|
234
|
+
throw new ProducerPublicationError(
|
|
235
|
+
"A producer-owned file changed outside the producer.",
|
|
236
|
+
"producer_owned_file_modified",
|
|
237
|
+
{ path: relativePath },
|
|
238
|
+
);
|
|
172
239
|
}
|
|
173
240
|
const content = fs.readFileSync(absolutePath);
|
|
174
241
|
if (sha256(content) !== expected) {
|
|
175
|
-
throw new ProducerPublicationError(
|
|
242
|
+
throw new ProducerPublicationError(
|
|
243
|
+
"A producer-owned file changed outside the producer.",
|
|
244
|
+
"producer_owned_file_modified",
|
|
245
|
+
{ path: relativePath },
|
|
246
|
+
);
|
|
176
247
|
}
|
|
177
248
|
contents.set(relativePath, content);
|
|
178
249
|
});
|
|
@@ -192,7 +263,11 @@ function inspectPublication(root, producer, files) {
|
|
|
192
263
|
assertRegularPath(root, file.path);
|
|
193
264
|
const absolutePath = path.join(root, ...file.path.split("/"));
|
|
194
265
|
if (fs.existsSync(absolutePath) && !owned.has(file.path)) {
|
|
195
|
-
throw new ProducerPublicationError(
|
|
266
|
+
throw new ProducerPublicationError(
|
|
267
|
+
"Producer output collides with an unowned file.",
|
|
268
|
+
"producer_unowned_collision",
|
|
269
|
+
{ path: file.path },
|
|
270
|
+
);
|
|
196
271
|
}
|
|
197
272
|
if (!owned.has(file.path)) {
|
|
198
273
|
changes.create.push(file.path);
|
|
@@ -202,7 +277,11 @@ function inspectPublication(root, producer, files) {
|
|
|
202
277
|
const current = ownedContents.get(file.path);
|
|
203
278
|
if (owned.get(file.path) === file.sha256) {
|
|
204
279
|
changes.unchanged.push(file.path);
|
|
205
|
-
effective.set(file.path, {
|
|
280
|
+
effective.set(file.path, {
|
|
281
|
+
path: file.path,
|
|
282
|
+
sha256: owned.get(file.path),
|
|
283
|
+
content: file.content,
|
|
284
|
+
});
|
|
206
285
|
return;
|
|
207
286
|
}
|
|
208
287
|
if (current && stableDigest(current.toString("utf8")) === stableDigest(file.content)) {
|
|
@@ -254,7 +333,10 @@ function snapshotFile(absolutePath) {
|
|
|
254
333
|
if (!fs.existsSync(absolutePath)) return { exists: false };
|
|
255
334
|
const stat = fs.lstatSync(absolutePath);
|
|
256
335
|
if (stat.isSymbolicLink() || !stat.isFile()) {
|
|
257
|
-
throw new ProducerPublicationError(
|
|
336
|
+
throw new ProducerPublicationError(
|
|
337
|
+
"Producer-managed files must be regular files.",
|
|
338
|
+
"producer_path_not_file",
|
|
339
|
+
);
|
|
258
340
|
}
|
|
259
341
|
return { exists: true, content: fs.readFileSync(absolutePath), mode: stat.mode & 0o777 };
|
|
260
342
|
}
|
|
@@ -282,20 +364,29 @@ function assertSnapshotMatches(absolutePath, expected, relativePath) {
|
|
|
282
364
|
function ensureParent(root, absolutePath, createdDirectories) {
|
|
283
365
|
const relative = path.relative(root, path.dirname(absolutePath));
|
|
284
366
|
let current = root;
|
|
285
|
-
relative
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
367
|
+
relative
|
|
368
|
+
.split(path.sep)
|
|
369
|
+
.filter(Boolean)
|
|
370
|
+
.forEach((part) => {
|
|
371
|
+
current = path.join(current, part);
|
|
372
|
+
if (!fs.existsSync(current)) {
|
|
373
|
+
fs.mkdirSync(current);
|
|
374
|
+
createdDirectories.push(current);
|
|
375
|
+
} else if (fs.lstatSync(current).isSymbolicLink() || !fs.statSync(current).isDirectory()) {
|
|
376
|
+
throw new ProducerPublicationError(
|
|
377
|
+
"Producer output parents must be ordinary directories.",
|
|
378
|
+
"producer_path_parent_not_directory",
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
294
382
|
}
|
|
295
383
|
|
|
296
384
|
function atomicWrite(root, absolutePath, content, createdDirectories) {
|
|
297
385
|
ensureParent(root, absolutePath, createdDirectories);
|
|
298
|
-
const temporaryPath = path.join(
|
|
386
|
+
const temporaryPath = path.join(
|
|
387
|
+
path.dirname(absolutePath),
|
|
388
|
+
`.${path.basename(absolutePath)}.${process.pid}.${crypto.randomBytes(6).toString("hex")}.tmp`,
|
|
389
|
+
);
|
|
299
390
|
try {
|
|
300
391
|
fs.writeFileSync(temporaryPath, content, { flag: "wx" });
|
|
301
392
|
fs.renameSync(temporaryPath, absolutePath);
|
|
@@ -306,19 +397,21 @@ function atomicWrite(root, absolutePath, content, createdDirectories) {
|
|
|
306
397
|
|
|
307
398
|
function restoreFiles(root, snapshots, published, createdDirectories) {
|
|
308
399
|
const conflicts = [];
|
|
309
|
-
Array.from(published.entries())
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
400
|
+
Array.from(published.entries())
|
|
401
|
+
.reverse()
|
|
402
|
+
.forEach(([absolutePath, expected]) => {
|
|
403
|
+
const snapshot = snapshots.get(absolutePath);
|
|
404
|
+
if (!snapshotMatches(absolutePath, expected)) {
|
|
405
|
+
conflicts.push(path.relative(root, absolutePath).replace(/\\/g, "/"));
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (snapshot.exists) {
|
|
409
|
+
atomicWrite(root, absolutePath, snapshot.content, []);
|
|
410
|
+
fs.chmodSync(absolutePath, snapshot.mode);
|
|
411
|
+
} else if (fs.existsSync(absolutePath) && fs.lstatSync(absolutePath).isFile()) {
|
|
412
|
+
fs.unlinkSync(absolutePath);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
322
415
|
createdDirectories.reverse().forEach((directory) => {
|
|
323
416
|
try {
|
|
324
417
|
fs.rmdirSync(directory);
|
|
@@ -339,9 +432,11 @@ function pruneEmptyDirectories(root, relativePaths) {
|
|
|
339
432
|
const visited = new Set();
|
|
340
433
|
relativePaths.forEach((relativePath) => {
|
|
341
434
|
let current = path.dirname(path.join(root, ...relativePath.split("/")));
|
|
342
|
-
while (
|
|
343
|
-
|
|
344
|
-
|
|
435
|
+
while (
|
|
436
|
+
isInside(root, current) &&
|
|
437
|
+
path.resolve(current) !== path.resolve(root) &&
|
|
438
|
+
!visited.has(current)
|
|
439
|
+
) {
|
|
345
440
|
visited.add(current);
|
|
346
441
|
try {
|
|
347
442
|
if (fs.readdirSync(current).length > 0) break;
|
|
@@ -362,7 +457,11 @@ class ProducerPublisher {
|
|
|
362
457
|
|
|
363
458
|
bundleRoot(bundleId) {
|
|
364
459
|
const bundle = this.project.bundles.find((entry) => entry.id === bundleId && !entry.remote);
|
|
365
|
-
if (!bundle)
|
|
460
|
+
if (!bundle)
|
|
461
|
+
throw new ProducerPublicationError(
|
|
462
|
+
"Configured producer bundle is unavailable.",
|
|
463
|
+
"unknown_producer_bundle",
|
|
464
|
+
);
|
|
366
465
|
return this.store.resolveWritableBundleRoot(bundle);
|
|
367
466
|
}
|
|
368
467
|
|
|
@@ -376,18 +475,25 @@ class ProducerPublisher {
|
|
|
376
475
|
const root = inspection.root;
|
|
377
476
|
const manifestPath = path.join(root, MANIFEST_NAME);
|
|
378
477
|
const manifestContent = `${JSON.stringify(manifestFor(producer, inspection.effective), null, 2)}\n`;
|
|
379
|
-
const changedPaths = inspection.changes.create
|
|
380
|
-
|
|
381
|
-
|
|
478
|
+
const changedPaths = inspection.changes.create.concat(
|
|
479
|
+
inspection.changes.update,
|
|
480
|
+
inspection.changes.delete,
|
|
481
|
+
);
|
|
482
|
+
if (
|
|
483
|
+
changedPaths.length === 0 &&
|
|
484
|
+
inspection.previousManifestSha256 === sha256(manifestContent)
|
|
485
|
+
) {
|
|
382
486
|
if (validatePersisted) await validatePersisted();
|
|
383
487
|
return inspection.changes;
|
|
384
488
|
}
|
|
385
489
|
const touched = new Set(changedPaths.concat(MANIFEST_NAME));
|
|
386
490
|
const snapshots = new Map();
|
|
387
|
-
touched.forEach((relativePath) =>
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
491
|
+
touched.forEach((relativePath) =>
|
|
492
|
+
snapshots.set(
|
|
493
|
+
path.join(root, ...relativePath.split("/")),
|
|
494
|
+
snapshotFile(path.join(root, ...relativePath.split("/"))),
|
|
495
|
+
),
|
|
496
|
+
);
|
|
391
497
|
inspection.changes.create.forEach((relativePath) => {
|
|
392
498
|
assertSnapshotMatches(
|
|
393
499
|
path.join(root, ...relativePath.split("/")),
|
|
@@ -408,11 +514,20 @@ class ProducerPublisher {
|
|
|
408
514
|
});
|
|
409
515
|
const manifestSnapshot = snapshots.get(manifestPath);
|
|
410
516
|
if (inspection.previousManifestSha256) {
|
|
411
|
-
if (
|
|
412
|
-
|
|
517
|
+
if (
|
|
518
|
+
!manifestSnapshot.exists ||
|
|
519
|
+
sha256(manifestSnapshot.content) !== inspection.previousManifestSha256
|
|
520
|
+
) {
|
|
521
|
+
throw new ProducerPublicationError(
|
|
522
|
+
"The producer ownership manifest changed during publication.",
|
|
523
|
+
"producer_publication_conflict",
|
|
524
|
+
);
|
|
413
525
|
}
|
|
414
526
|
} else if (manifestSnapshot.exists) {
|
|
415
|
-
throw new ProducerPublicationError(
|
|
527
|
+
throw new ProducerPublicationError(
|
|
528
|
+
"The producer ownership manifest changed during publication.",
|
|
529
|
+
"producer_publication_conflict",
|
|
530
|
+
);
|
|
416
531
|
}
|
|
417
532
|
const createdDirectories = [];
|
|
418
533
|
const published = new Map();
|
|
@@ -442,7 +557,10 @@ class ProducerPublisher {
|
|
|
442
557
|
restoreFiles(root, snapshots, published, createdDirectories);
|
|
443
558
|
} catch (rollbackError) {
|
|
444
559
|
if (rollbackError instanceof ProducerPublicationError) throw rollbackError;
|
|
445
|
-
throw new ProducerPublicationError(
|
|
560
|
+
throw new ProducerPublicationError(
|
|
561
|
+
"Producer publication failed and rollback could not be completed.",
|
|
562
|
+
"producer_rollback_failed",
|
|
563
|
+
);
|
|
446
564
|
}
|
|
447
565
|
throw error;
|
|
448
566
|
}
|