@ikon85/agent-workflow-kit 0.35.0 → 0.36.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.
@@ -2,6 +2,7 @@ import { lstat, readFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { isDeepStrictEqual } from 'node:util';
4
4
  import { sha256File } from './hash.mjs';
5
+ import { validateContributionBridge } from './contributionBridge.mjs';
5
6
  import {
6
7
  CONSUMER_INSTALL_ROLE, CONSUMER_MANIFEST_NAME, CONSUMER_ORIGIN, KIT_ORIGIN,
7
8
  emptyConsumerManifest, filesForInstallRole,
@@ -192,11 +193,24 @@ function validateInstalledEntry(tracked, desired, origin) {
192
193
  if (tracked.origin === KIT_ORIGIN && tracked.ownershipState !== undefined) {
193
194
  throw new Error(`candidate invariant ownership: Kit path has Consumer lifecycle ${tracked.path}`);
194
195
  }
196
+ if (tracked.origin === KIT_ORIGIN && tracked.contributionBridge !== undefined) {
197
+ throw new Error(`candidate invariant ownership: Kit path has contribution bridge ${tracked.path}`);
198
+ }
195
199
  if (tracked.origin === CONSUMER_ORIGIN && ![
196
200
  undefined, 'project-extension', 'contribution-bridge', 'explicit-fork',
197
201
  ].includes(tracked.ownershipState)) {
198
202
  throw new Error(`candidate invariant ownership: invalid lifecycle ${tracked.path}`);
199
203
  }
204
+ if (tracked.origin === CONSUMER_ORIGIN
205
+ && tracked.ownershipState === 'contribution-bridge') {
206
+ try {
207
+ validateContributionBridge(tracked);
208
+ } catch {
209
+ throw new Error(`candidate invariant ownership: invalid contribution bridge ${tracked.path}`);
210
+ }
211
+ } else if (tracked.contributionBridge !== undefined) {
212
+ throw new Error(`candidate invariant ownership: unexpected contribution bridge ${tracked.path}`);
213
+ }
200
214
  }
201
215
 
202
216
  function verifyLedgerMetadata(ledger, context) {
@@ -215,6 +229,7 @@ function verifyLedgerMetadata(ledger, context) {
215
229
  }
216
230
 
217
231
  function expectedOrigin(path, priorInstalled, preview) {
232
+ if ((preview.bridgeRetired ?? []).includes(path)) return KIT_ORIGIN;
218
233
  const transferredToCore = (preview.migrations ?? []).some(
219
234
  (migration) => migration.path === path && migration.ownership === 'kit-core',
220
235
  );
@@ -60,6 +60,16 @@ export function verifyTransactionPreview(preview, installable, installed) {
60
60
  }
61
61
  actionSets.set(key, local);
62
62
  }
63
+ if (!Array.isArray(preview.bridgeRetired ?? [])) {
64
+ throw new Error('candidate invariant transaction: bridgeRetired must be an array');
65
+ }
66
+ const retired = new Set();
67
+ for (const path of preview.bridgeRetired ?? []) {
68
+ claimTransactionPath(path, 'bridgeRetired', retired, owners);
69
+ if (!installablePaths.has(path) || installed.get(path)?.origin !== KIT_ORIGIN) {
70
+ throw new Error(`candidate invariant transaction: invalid bridge retirement ${path}`);
71
+ }
72
+ }
63
73
  if (!Array.isArray(preview.migrations ?? [])) {
64
74
  throw new Error('candidate invariant transaction: migrations must be an array');
65
75
  }