@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.
Files changed (97) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +172 -17
  3. package/bin/okf-mcp.js +6 -1
  4. package/okf/okf-mcp/policies/authoring-safety.md +11 -1
  5. package/package.json +17 -5
  6. package/server.json +2 -2
  7. package/src/assets.js +165 -73
  8. package/src/authoring/candidates.js +391 -0
  9. package/src/authoring/git-preflight.js +225 -0
  10. package/src/authoring/git-publish.js +776 -0
  11. package/src/authoring/live.js +789 -0
  12. package/src/authoring/paths.js +112 -0
  13. package/src/authoring/policy-hook.js +221 -0
  14. package/src/authoring/proposal-policy.js +137 -0
  15. package/src/authoring/receipts.js +329 -0
  16. package/src/authoring/render.js +38 -0
  17. package/src/authoring/shared.js +75 -0
  18. package/src/authoring/staging.js +216 -0
  19. package/src/authoring.js +386 -287
  20. package/src/cache/files.js +147 -0
  21. package/src/cache/lock.js +201 -0
  22. package/src/cache/paths.js +197 -0
  23. package/src/cache/store.js +703 -0
  24. package/src/catalog-text.js +19 -0
  25. package/src/cli.js +184 -151
  26. package/src/computation.js +99 -61
  27. package/src/context/assemble.js +567 -0
  28. package/src/context/cli-options.js +88 -0
  29. package/src/context/score.js +234 -0
  30. package/src/context/sections.js +274 -0
  31. package/src/embed/interface.js +160 -0
  32. package/src/embed/openai.js +715 -0
  33. package/src/embed/prepare.js +182 -0
  34. package/src/embed/units.js +96 -0
  35. package/src/git-source.js +112 -52
  36. package/src/graph.js +95 -37
  37. package/src/http-server.js +36 -17
  38. package/src/index.js +15 -0
  39. package/src/indexer/assemble.js +566 -0
  40. package/src/indexer/build.js +290 -0
  41. package/src/indexer/cache.js +81 -0
  42. package/src/indexer/edges.js +430 -0
  43. package/src/indexer/index.js +44 -0
  44. package/src/indexer/paths.js +178 -0
  45. package/src/indexer/resolve.js +282 -0
  46. package/src/indexer/update.js +720 -0
  47. package/src/indexer.js +3 -1068
  48. package/src/live-authoring.js +4 -2329
  49. package/src/markdown.js +21 -16
  50. package/src/mcp/registry.js +328 -0
  51. package/src/mcp/resources.js +45 -0
  52. package/src/mcp/server.js +472 -0
  53. package/src/mcp/tools/catalog.js +244 -0
  54. package/src/mcp/tools/computation.js +83 -0
  55. package/src/mcp/tools/context.js +133 -0
  56. package/src/mcp/tools/graph.js +167 -0
  57. package/src/mcp/tools/live-authoring.js +316 -0
  58. package/src/mcp/tools/migration.js +86 -0
  59. package/src/mcp/tools/producers.js +79 -0
  60. package/src/mcp/tools/proposals.js +213 -0
  61. package/src/mcp/tools/provenance.js +87 -0
  62. package/src/mcp/tools/remote.js +79 -0
  63. package/src/mcp/tools/search.js +242 -0
  64. package/src/mcp-server.js +3 -1611
  65. package/src/migration.js +431 -253
  66. package/src/parser.js +245 -130
  67. package/src/plugins.js +71 -48
  68. package/src/policy/write-policy.js +713 -0
  69. package/src/producer-publisher.js +195 -77
  70. package/src/producers.js +265 -101
  71. package/src/project.js +277 -93
  72. package/src/remote.js +96 -61
  73. package/src/search/cli-options.js +107 -0
  74. package/src/search/confidence.js +61 -0
  75. package/src/search/dense.js +304 -0
  76. package/src/search/embedding-cli.js +57 -0
  77. package/src/search/embedding-config.js +217 -0
  78. package/src/search/fusion.js +249 -0
  79. package/src/search/hybrid.js +526 -0
  80. package/src/search/languages.js +200 -0
  81. package/src/search/lexical.js +695 -0
  82. package/src/search/query.js +620 -0
  83. package/src/search/stem/among.js +43 -0
  84. package/src/search/stem/base-stemmer.js +311 -0
  85. package/src/search/stem/en-regions.js +456 -0
  86. package/src/search/stem/en-suffixes.js +664 -0
  87. package/src/search/stem/en-tables.js +176 -0
  88. package/src/search/stem/en.js +238 -0
  89. package/src/search/stem/it-regions.js +459 -0
  90. package/src/search/stem/it-suffixes.js +471 -0
  91. package/src/search/stem/it-tables.js +257 -0
  92. package/src/search/stem/it.js +155 -0
  93. package/src/search-index.js +2 -81
  94. package/src/search.js +2 -252
  95. package/src/store.js +134 -81
  96. package/src/v02.js +301 -105
  97. 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).sort()
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(parsed && (parsed.generated.by !== undefined || parsed.generated.at !== undefined));
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 || "").trim().replace(/\\/g, "/");
79
- if (!raw || raw.startsWith("/") || /^[A-Za-z]:\//.test(raw) || /[\u0000-\u001f\u007f]/.test(raw)) {
80
- throw new ProducerPublicationError("Producer paths must be safe bundle-relative Markdown paths.", "invalid_producer_path");
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("Producer paths cannot contain empty, hidden, dot, or parent segments.", "invalid_producer_path");
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("Producer output files must be Markdown documents.", "invalid_producer_path");
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("Producer generate() must return a non-empty files array.", "invalid_producer_output");
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.map((file) => {
99
- if (!file || typeof file !== "object" || Array.isArray(file)) {
100
- throw new ProducerPublicationError("Each producer file must be an object.", "invalid_producer_output");
101
- }
102
- const relativePath = normalizeProducedPath(file.path);
103
- if (seen.has(relativePath)) {
104
- throw new ProducerPublicationError("Producer output paths must be unique.", "duplicate_producer_path", { path: relativePath });
105
- }
106
- seen.add(relativePath);
107
- if (typeof file.content !== "string") {
108
- throw new ProducerPublicationError("Producer file content must be a string.", "invalid_producer_content", { path: relativePath });
109
- }
110
- return { path: relativePath, content: file.content, sha256: sha256(file.content) };
111
- }).sort((left, right) => left.path.localeCompare(right.path));
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("Producer-managed paths cannot traverse symbolic links.", "producer_path_symlink", { path: parts.slice(0, index + 1).join("/") });
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("A producer-managed path parent is not a directory.", "producer_path_parent_not_directory", { path: parts.slice(0, index + 1).join("/") });
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("Producer-managed files must be regular files.", "producer_path_not_file", { path: relativePath });
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("The producer ownership manifest is invalid.", "invalid_producer_manifest");
193
+ throw new ProducerPublicationError(
194
+ "The producer ownership manifest is invalid.",
195
+ "invalid_producer_manifest",
196
+ );
149
197
  }
150
- if (!manifest || manifest.version !== 1 || manifest.producer !== producer.type
151
- || manifest.bundle !== producer.bundle || !Array.isArray(manifest.files)) {
152
- throw new ProducerPublicationError("The producer ownership manifest does not match this configured producer.", "invalid_producer_manifest");
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 (owned.has(relativePath) || !entry || !/^sha256:[a-f0-9]{64}$/.test(String(entry.sha256 || ""))) {
158
- throw new ProducerPublicationError("The producer ownership manifest contains an invalid file entry.", "invalid_producer_manifest");
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("A producer-owned file changed outside the producer.", "producer_owned_file_modified", { path: relativePath });
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("A producer-owned file changed outside the producer.", "producer_owned_file_modified", { path: relativePath });
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("Producer output collides with an unowned file.", "producer_unowned_collision", { path: file.path });
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, { path: file.path, sha256: owned.get(file.path), content: file.content });
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("Producer-managed files must be regular files.", "producer_path_not_file");
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.split(path.sep).filter(Boolean).forEach((part) => {
286
- current = path.join(current, part);
287
- if (!fs.existsSync(current)) {
288
- fs.mkdirSync(current);
289
- createdDirectories.push(current);
290
- } else if (fs.lstatSync(current).isSymbolicLink() || !fs.statSync(current).isDirectory()) {
291
- throw new ProducerPublicationError("Producer output parents must be ordinary directories.", "producer_path_parent_not_directory");
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(path.dirname(absolutePath), `.${path.basename(absolutePath)}.${process.pid}.${crypto.randomBytes(6).toString("hex")}.tmp`);
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()).reverse().forEach(([absolutePath, expected]) => {
310
- const snapshot = snapshots.get(absolutePath);
311
- if (!snapshotMatches(absolutePath, expected)) {
312
- conflicts.push(path.relative(root, absolutePath).replace(/\\/g, "/"));
313
- return;
314
- }
315
- if (snapshot.exists) {
316
- atomicWrite(root, absolutePath, snapshot.content, []);
317
- fs.chmodSync(absolutePath, snapshot.mode);
318
- } else if (fs.existsSync(absolutePath) && fs.lstatSync(absolutePath).isFile()) {
319
- fs.unlinkSync(absolutePath);
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 (isInside(root, current)
343
- && path.resolve(current) !== path.resolve(root)
344
- && !visited.has(current)) {
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) throw new ProducerPublicationError("Configured producer bundle is unavailable.", "unknown_producer_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
- .concat(inspection.changes.update, inspection.changes.delete);
381
- if (changedPaths.length === 0 && inspection.previousManifestSha256 === sha256(manifestContent)) {
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) => snapshots.set(
388
- path.join(root, ...relativePath.split("/")),
389
- snapshotFile(path.join(root, ...relativePath.split("/"))),
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 (!manifestSnapshot.exists || sha256(manifestSnapshot.content) !== inspection.previousManifestSha256) {
412
- throw new ProducerPublicationError("The producer ownership manifest changed during publication.", "producer_publication_conflict");
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("The producer ownership manifest changed during publication.", "producer_publication_conflict");
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("Producer publication failed and rollback could not be completed.", "producer_rollback_failed");
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
  }