@lesliechan721/aw 0.1.0-beta.102 → 0.1.0-beta.104

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 (199) hide show
  1. package/dist/src/commands/catalog-generation.d.ts +2 -5
  2. package/dist/src/commands/catalog-generation.js +2 -4
  3. package/dist/src/commands/catalog-generation.js.map +1 -1
  4. package/dist/src/commands/lifecycle-command-package.d.ts +1 -1
  5. package/dist/src/commands/lifecycle-command-package.js +40 -2
  6. package/dist/src/commands/lifecycle-command-package.js.map +1 -1
  7. package/dist/src/commands/managed-commands.d.ts +2 -1
  8. package/dist/src/commands/managed-commands.js +4 -2
  9. package/dist/src/commands/managed-commands.js.map +1 -1
  10. package/dist/src/commands/operation-plan.d.ts +2 -8
  11. package/dist/src/commands/operation-plan.js.map +1 -1
  12. package/dist/src/commands/public-config-confirmation.d.ts +16 -10
  13. package/dist/src/commands/public-config-confirmation.js +87 -52
  14. package/dist/src/commands/public-config-confirmation.js.map +1 -1
  15. package/dist/src/commands/public-lifecycle.d.ts +1 -1
  16. package/dist/src/commands/public-lifecycle.js +36 -8
  17. package/dist/src/commands/public-lifecycle.js.map +1 -1
  18. package/dist/src/commands/public-plugin-query.js +6 -4
  19. package/dist/src/commands/public-plugin-query.js.map +1 -1
  20. package/dist/src/commands/rebuild-command.d.ts +22 -6
  21. package/dist/src/commands/rebuild-command.js +273 -557
  22. package/dist/src/commands/rebuild-command.js.map +1 -1
  23. package/dist/src/commands/rebuild-integration.d.ts +12 -39
  24. package/dist/src/commands/rebuild-integration.js +67 -303
  25. package/dist/src/commands/rebuild-integration.js.map +1 -1
  26. package/dist/src/commands/rebuild-operations.d.ts +0 -4
  27. package/dist/src/commands/rebuild-operations.js +9 -8
  28. package/dist/src/commands/rebuild-operations.js.map +1 -1
  29. package/dist/src/commands/rebuild-platform-integration.d.ts +14 -6
  30. package/dist/src/commands/rebuild-platform-integration.js +310 -101
  31. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  32. package/dist/src/commands/status-v6.d.ts +3 -117
  33. package/dist/src/commands/status-v6.js +0 -2886
  34. package/dist/src/commands/status-v6.js.map +1 -1
  35. package/dist/src/commands/write-commands.js +0 -3
  36. package/dist/src/commands/write-commands.js.map +1 -1
  37. package/dist/src/index.js +44 -36
  38. package/dist/src/index.js.map +1 -1
  39. package/dist/src/intent/deployment-preferences.js +4 -3
  40. package/dist/src/intent/deployment-preferences.js.map +1 -1
  41. package/dist/src/intent/intent-store.js +3 -2
  42. package/dist/src/intent/intent-store.js.map +1 -1
  43. package/dist/src/output/command-receipt.d.ts +0 -6
  44. package/dist/src/output/command-receipt.js +0 -15
  45. package/dist/src/output/command-receipt.js.map +1 -1
  46. package/dist/src/output/receipt-projection.js +2 -1
  47. package/dist/src/output/receipt-projection.js.map +1 -1
  48. package/dist/src/platforms/capabilities.js +8 -2
  49. package/dist/src/platforms/capabilities.js.map +1 -1
  50. package/dist/src/platforms/contracts.d.ts +2 -0
  51. package/dist/src/platforms/discovery.d.ts +2 -0
  52. package/dist/src/platforms/discovery.js +95 -49
  53. package/dist/src/platforms/discovery.js.map +1 -1
  54. package/dist/src/platforms/inspection-native.d.ts +7 -1
  55. package/dist/src/platforms/inspection-native.js +6 -3
  56. package/dist/src/platforms/inspection-native.js.map +1 -1
  57. package/dist/src/platforms/inspection-query.d.ts +28 -14
  58. package/dist/src/platforms/inspection-query.js +102 -8
  59. package/dist/src/platforms/inspection-query.js.map +1 -1
  60. package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
  61. package/dist/src/platforms/lifecycle-native-services.js +7 -2
  62. package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
  63. package/dist/src/platforms/lifecycle-native.js +20 -3
  64. package/dist/src/platforms/lifecycle-native.js.map +1 -1
  65. package/dist/src/platforms/lifecycle.js +5 -0
  66. package/dist/src/platforms/lifecycle.js.map +1 -1
  67. package/dist/src/platforms/supplement-state.js +11 -2
  68. package/dist/src/platforms/supplement-state.js.map +1 -1
  69. package/dist/src/portable/commands.d.ts +1 -0
  70. package/dist/src/portable/commands.js.map +1 -1
  71. package/dist/src/portable/materializer.d.ts +2 -0
  72. package/dist/src/portable/materializer.js +4 -4
  73. package/dist/src/portable/materializer.js.map +1 -1
  74. package/dist/src/portable/recovery.d.ts +1 -0
  75. package/dist/src/portable/recovery.js +3 -2
  76. package/dist/src/portable/recovery.js.map +1 -1
  77. package/dist/src/recovery/coordinator.d.ts +6 -1
  78. package/dist/src/recovery/coordinator.js +113 -108
  79. package/dist/src/recovery/coordinator.js.map +1 -1
  80. package/dist/src/recovery/demand.d.ts +1 -2
  81. package/dist/src/recovery/demand.js +4 -11
  82. package/dist/src/recovery/demand.js.map +1 -1
  83. package/dist/src/recovery/install-concurrency.d.ts +12 -0
  84. package/dist/src/recovery/install-concurrency.js +39 -0
  85. package/dist/src/recovery/install-concurrency.js.map +1 -1
  86. package/dist/src/recovery/joint-coordinator.d.ts +3 -4
  87. package/dist/src/recovery/joint-coordinator.js +324 -188
  88. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  89. package/dist/src/recovery/joint-demand.js +4 -3
  90. package/dist/src/recovery/joint-demand.js.map +1 -1
  91. package/dist/src/recovery/joint-install-execution.js +46 -2
  92. package/dist/src/recovery/joint-install-execution.js.map +1 -1
  93. package/dist/src/recovery/joint-install-native-rebase.js +5 -2
  94. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -1
  95. package/dist/src/recovery/locked-prepared-execution.d.ts +32 -0
  96. package/dist/src/recovery/locked-prepared-execution.js +67 -0
  97. package/dist/src/recovery/locked-prepared-execution.js.map +1 -0
  98. package/dist/src/recovery/status.d.ts +20 -6
  99. package/dist/src/recovery/status.js +153 -98
  100. package/dist/src/recovery/status.js.map +1 -1
  101. package/dist/src/review/skill-materialization.d.ts +1 -0
  102. package/dist/src/review/skill-materialization.js.map +1 -1
  103. package/dist/src/tui/console-app-v4.js +4 -14
  104. package/dist/src/tui/console-app-v4.js.map +1 -1
  105. package/dist/src/tui/controller-runtime.js +201 -57
  106. package/dist/src/tui/controller-runtime.js.map +1 -1
  107. package/dist/src/tui/controller.d.ts +8 -9
  108. package/dist/src/tui/controller.js +5 -6
  109. package/dist/src/tui/controller.js.map +1 -1
  110. package/dist/src/tui/operation-review-planner.js +14 -103
  111. package/dist/src/tui/operation-review-planner.js.map +1 -1
  112. package/dist/src/types.d.ts +5 -1
  113. package/dist/src/types.js.map +1 -1
  114. package/dist/src/utils/agent-version.js +1 -0
  115. package/dist/src/utils/agent-version.js.map +1 -1
  116. package/dist/src/utils/artifact-renderer.d.ts +10 -0
  117. package/dist/src/utils/artifact-renderer.js +28 -2
  118. package/dist/src/utils/artifact-renderer.js.map +1 -1
  119. package/dist/src/utils/aw-home-mutation-lock.d.ts +8 -0
  120. package/dist/src/utils/aw-home-mutation-lock.js +44 -8
  121. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  122. package/dist/src/utils/bundle-integrity.js +126 -33
  123. package/dist/src/utils/bundle-integrity.js.map +1 -1
  124. package/dist/src/utils/catalog-generation-resolver.d.ts +4 -0
  125. package/dist/src/utils/catalog-generation-resolver.js +4 -0
  126. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  127. package/dist/src/utils/catalog-generation-service.d.ts +50 -11
  128. package/dist/src/utils/catalog-generation-service.js +276 -130
  129. package/dist/src/utils/catalog-generation-service.js.map +1 -1
  130. package/dist/src/utils/catalog-generation-state.js +6 -1
  131. package/dist/src/utils/catalog-generation-state.js.map +1 -1
  132. package/dist/src/utils/catalog-generation-store.d.ts +5 -0
  133. package/dist/src/utils/catalog-generation-store.js +36 -13
  134. package/dist/src/utils/catalog-generation-store.js.map +1 -1
  135. package/dist/src/utils/catalog-operation-context.d.ts +17 -3
  136. package/dist/src/utils/catalog-operation-context.js +220 -22
  137. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  138. package/dist/src/utils/catalog-performance.d.ts +3 -0
  139. package/dist/src/utils/catalog-performance.js +26 -0
  140. package/dist/src/utils/catalog-performance.js.map +1 -0
  141. package/dist/src/utils/catalog-snapshot.d.ts +5 -2
  142. package/dist/src/utils/catalog-snapshot.js +3 -2
  143. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  144. package/dist/src/utils/catalog-source-impact.d.ts +2 -1
  145. package/dist/src/utils/catalog-source-impact.js +2 -2
  146. package/dist/src/utils/catalog-source-impact.js.map +1 -1
  147. package/dist/src/utils/catalog-source-references.d.ts +2 -0
  148. package/dist/src/utils/catalog-source-references.js +284 -148
  149. package/dist/src/utils/catalog-source-references.js.map +1 -1
  150. package/dist/src/utils/codex-executable-discovery.js +1 -0
  151. package/dist/src/utils/codex-executable-discovery.js.map +1 -1
  152. package/dist/src/utils/codex-manager.js +1 -0
  153. package/dist/src/utils/codex-manager.js.map +1 -1
  154. package/dist/src/utils/codex-native-observation.d.ts +5 -2
  155. package/dist/src/utils/codex-native-observation.js +8 -4
  156. package/dist/src/utils/codex-native-observation.js.map +1 -1
  157. package/dist/src/utils/component-command-preparation.d.ts +1 -0
  158. package/dist/src/utils/component-command-preparation.js.map +1 -1
  159. package/dist/src/utils/git-catalog-provider.d.ts +38 -5
  160. package/dist/src/utils/git-catalog-provider.js +365 -156
  161. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  162. package/dist/src/utils/managed-command-closure.d.ts +3 -1
  163. package/dist/src/utils/managed-command-closure.js +10 -5
  164. package/dist/src/utils/managed-command-closure.js.map +1 -1
  165. package/dist/src/utils/managed-command-materialization.d.ts +2 -0
  166. package/dist/src/utils/managed-command-materialization.js +4 -3
  167. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  168. package/dist/src/utils/managed-command-preparation.js +1 -1
  169. package/dist/src/utils/managed-command-preparation.js.map +1 -1
  170. package/dist/src/utils/multi-source-catalog.d.ts +1 -1
  171. package/dist/src/utils/multi-source-catalog.js +3 -3
  172. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  173. package/dist/src/utils/native-cli.d.ts +6 -1
  174. package/dist/src/utils/native-cli.js +67 -32
  175. package/dist/src/utils/native-cli.js.map +1 -1
  176. package/dist/src/utils/platform-empty-state.d.ts +2 -0
  177. package/dist/src/utils/platform-empty-state.js +5 -5
  178. package/dist/src/utils/platform-empty-state.js.map +1 -1
  179. package/dist/src/utils/plugin-config-command-apply.d.ts +14 -4
  180. package/dist/src/utils/plugin-config-command-apply.js +49 -5
  181. package/dist/src/utils/plugin-config-command-apply.js.map +1 -1
  182. package/dist/src/utils/plugin-config-impact.d.ts +42 -0
  183. package/dist/src/utils/plugin-config-impact.js +170 -14
  184. package/dist/src/utils/plugin-config-impact.js.map +1 -1
  185. package/dist/src/utils/plugin-config-references.d.ts +3 -1
  186. package/dist/src/utils/plugin-config-references.js +3 -5
  187. package/dist/src/utils/plugin-config-references.js.map +1 -1
  188. package/dist/src/utils/plugin-config-write.d.ts +14 -5
  189. package/dist/src/utils/plugin-config-write.js +213 -117
  190. package/dist/src/utils/plugin-config-write.js.map +1 -1
  191. package/dist/src/utils/plugin-config.d.ts +2 -0
  192. package/dist/src/utils/plugin-config.js.map +1 -1
  193. package/dist/src/utils/plugin-scripts.d.ts +2 -0
  194. package/dist/src/utils/plugin-scripts.js +102 -3
  195. package/dist/src/utils/plugin-scripts.js.map +1 -1
  196. package/package.json +3 -3
  197. package/dist/src/utils/codex-reconciler.d.ts +0 -123
  198. package/dist/src/utils/codex-reconciler.js +0 -322
  199. package/dist/src/utils/codex-reconciler.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { IMPLEMENTED_AW_CAPABILITIES } from '../commands/aw-capabilities.js';
1
2
  import { withAwHomeMutationLock, } from './aw-home-mutation-lock.js';
2
3
  import { CatalogGenerationError, catalogGenerationErrorCode } from './catalog-generation-error.js';
3
4
  import { createCatalogStoreKey, prepareCatalogStoreEntryRepair, publishCatalogStoreEntry, readCatalogSnapshotLogicalIdentity, readCatalogStoreEntry, } from './catalog-generation-store.js';
@@ -6,7 +7,9 @@ export { removeCatalogSourceGenerationState } from './catalog-generation-state.j
6
7
  import { validateCatalogSnapshotTransport } from './catalog-snapshot.js';
7
8
  import { calculateCatalogSourceConfigFingerprint, calculateCatalogSourceIdentity } from './catalog-source-identity.js';
8
9
  import { readCatalogSourcesConfigSnapshot } from './catalog-sources.js';
9
- import { catalogGitProviderInternal } from './git-catalog-provider.js';
10
+ import { measureCatalogPerformanceStage } from './catalog-performance.js';
11
+ import { CatalogProviderCompatibilityError, sanitizeCatalogSourceError } from './catalog-public-error.js';
12
+ import { catalogGitProviderInternal, getGitCatalogTransportValidation, matchObservedGitRef } from './git-catalog-provider.js';
10
13
  import { catalogPathProviderInternal } from './path-catalog-provider.js';
11
14
  import { readValidatedCatalogGenerationStoreEntry, resolveValidatedActiveCatalogGeneration, } from './catalog-generation-resolver.js';
12
15
  import { compareStrictSemVer } from './manifest.js';
@@ -34,31 +37,37 @@ async function resolveProvider(options) {
34
37
  git: catalogGitProviderInternal.resolve,
35
38
  path: catalogPathProviderInternal.resolve,
36
39
  };
37
- return providers[options.source.type](options.source, {
38
- cliVersion: options.cliVersion,
39
- env: options.env,
40
- signal: options.signal,
41
- });
40
+ const runtime = {
41
+ cliVersion: options.cliVersion, env: options.env, signal: options.signal,
42
+ debugLogger: options.runtime?.debugLogger,
43
+ };
44
+ return options.source.type === 'git'
45
+ ? providers.git(options.source, runtime)
46
+ : providers.path(options.source, runtime);
42
47
  }
43
- async function resolveCandidate(options) {
44
- const source = options.source ?? (await readCatalogSourcesConfigSnapshot(options.env)).config.sources
45
- .find((entry) => entry.id === options.sourceId);
46
- if (!source)
48
+ function assertProviderIdentity(source, sourceIdentity, result) {
49
+ if (result.sourceId !== source.id || result.sourceIdentity !== sourceIdentity) {
47
50
  throw new CatalogGenerationError({
48
- code: 'catalogGenerationSourceMissing', sourceId: options.sourceId,
49
- message: `Catalog source "${options.sourceId}" is not configured.`,
51
+ code: 'catalogGenerationIdentityMismatch', sourceId: source.id,
52
+ message: `Catalog provider returned mismatched identity for source "${source.id}".`,
53
+ });
54
+ }
55
+ }
56
+ function assertCapabilitySupport(sourceId, store) {
57
+ const compatibility = projectCatalogCapabilityCompatibility(store.metadata.requiredAwCapabilities);
58
+ if (compatibility.state === 'unsupported') {
59
+ throw new CatalogProviderCompatibilityError({
60
+ sourceId, ...compatibility, availableCapabilities: IMPLEMENTED_AW_CAPABILITIES,
50
61
  });
51
- const resolution = await resolveProvider({ source, ...options });
62
+ }
63
+ }
64
+ async function validateResolution(source, sourceIdentity, resolution, debugLogger) {
52
65
  try {
53
- const sourceIdentity = await calculateCatalogSourceIdentity(source);
54
- if (resolution.sourceId !== source.id || resolution.sourceIdentity !== sourceIdentity) {
55
- throw new CatalogGenerationError({
56
- code: 'catalogGenerationIdentityMismatch', sourceId: source.id,
57
- message: `Catalog provider returned mismatched identity for source "${source.id}".`,
58
- });
59
- }
60
- const validation = await validateCatalogSnapshotTransport(resolution.rootDir);
61
- if (validation.manifestDigest !== resolution.manifestDigest
66
+ assertProviderIdentity(source, sourceIdentity, resolution);
67
+ const validation = getGitCatalogTransportValidation(resolution)
68
+ ?? await validateCatalogSnapshotTransport(resolution.rootDir, debugLogger);
69
+ if (validation.rootDir !== resolution.rootDir
70
+ || validation.manifestDigest !== resolution.manifestDigest
62
71
  || validation.snapshotDigest !== resolution.snapshotDigest)
63
72
  throw new CatalogGenerationError({
64
73
  code: 'catalogGenerationIdentityMismatch', sourceId: source.id,
@@ -69,14 +78,14 @@ async function resolveCandidate(options) {
69
78
  resolution,
70
79
  candidate: {
71
80
  sourceConfigFingerprint: calculateCatalogSourceConfigFingerprint(source),
72
- sourceIdentity: resolution.sourceIdentity,
81
+ sourceIdentity,
73
82
  logicalIdentity: await readCatalogSnapshotLogicalIdentity(resolution.rootDir),
74
83
  catalogVersion: validation.manifest.catalogVersion,
75
84
  channel: validation.manifest.channel,
76
85
  requestedRef: resolution.requestedRef,
77
86
  resolvedCommit: resolution.resolvedCommit,
78
- manifestDigest: resolution.manifestDigest,
79
- snapshotDigest: resolution.snapshotDigest,
87
+ manifestDigest: validation.manifestDigest,
88
+ snapshotDigest: validation.snapshotDigest,
80
89
  },
81
90
  };
82
91
  }
@@ -85,6 +94,73 @@ async function resolveCandidate(options) {
85
94
  throw error;
86
95
  }
87
96
  }
97
+ function storeMatchesActive(store, active) {
98
+ return store.metadata.logicalIdentity === active.logicalIdentity
99
+ && store.metadata.snapshotDigest === active.snapshotDigest
100
+ && store.metadata.manifestDigest === active.manifestDigest;
101
+ }
102
+ async function readActiveStore(active, env, debugLogger) {
103
+ const store = await readCatalogStoreEntry({ ...active, env, debugLogger });
104
+ if (!storeMatchesActive(store, active))
105
+ throw new CatalogGenerationError({
106
+ code: 'catalogGenerationIdentityMismatch', message: 'Active does not match store metadata.',
107
+ });
108
+ return store;
109
+ }
110
+ async function resolveCandidate(options) {
111
+ const source = options.source ?? (await readCatalogSourcesConfigSnapshot(options.env)).config.sources
112
+ .find((entry) => entry.id === options.sourceId);
113
+ if (!source)
114
+ throw new CatalogGenerationError({
115
+ code: 'catalogGenerationSourceMissing', sourceId: options.sourceId,
116
+ message: `Catalog source "${options.sourceId}" is not configured.`,
117
+ });
118
+ const sourceIdentity = await calculateCatalogSourceIdentity(source);
119
+ const active = options.reuseActive;
120
+ const gitProvider = options.runtime?.providers?.git ?? catalogGitProviderInternal.resolve;
121
+ const prepareGit = options.runtime?.prepareGit
122
+ ?? (gitProvider === catalogGitProviderInternal.resolve ? catalogGitProviderInternal.prepare : undefined);
123
+ if (source.type === 'git' && prepareGit && active?.sourceIdentity === sourceIdentity
124
+ && active.sourceConfigFingerprint === calculateCatalogSourceConfigFingerprint(source)) {
125
+ const prepared = await prepareGit(source, {
126
+ cliVersion: options.cliVersion, env: options.env, signal: options.signal, debugLogger: options.runtime?.debugLogger,
127
+ });
128
+ try {
129
+ assertProviderIdentity(source, sourceIdentity, prepared);
130
+ const materialize = async () => validateResolution(source, sourceIdentity, await prepared.materialize(), options.runtime?.debugLogger);
131
+ const matched = prepared.fixed ? undefined : matchObservedGitRef(prepared, active);
132
+ if (matched) {
133
+ const store = options.reviewedStore === undefined
134
+ ? await readActiveStore(active, options.env, options.runtime?.debugLogger).catch(() => null)
135
+ : options.reviewedStore;
136
+ if (store && storeMatchesActive(store, active)) {
137
+ assertCapabilitySupport(source.id, store);
138
+ const candidate = {
139
+ sourceConfigFingerprint: active.sourceConfigFingerprint,
140
+ sourceIdentity, logicalIdentity: active.logicalIdentity,
141
+ requestedRef: prepared.requestedRef, resolvedCommit: matched.resolvedCommit,
142
+ manifestDigest: active.manifestDigest, snapshotDigest: active.snapshotDigest,
143
+ catalogVersion: store.metadata.catalogVersion, channel: store.metadata.channel,
144
+ };
145
+ return {
146
+ source, candidate,
147
+ resolution: {
148
+ ...candidate, ...matched, sourceId: source.id, transport: 'git', rootDir: store.snapshotRoot,
149
+ manifest: store.manifest, cleanup: () => prepared.cleanup(),
150
+ },
151
+ reusedGit: { active, store, materialize },
152
+ };
153
+ }
154
+ }
155
+ return await materialize();
156
+ }
157
+ catch (error) {
158
+ await prepared.cleanup().catch(() => warnCleanupFailure(source.id));
159
+ throw error;
160
+ }
161
+ }
162
+ return validateResolution(source, sourceIdentity, await resolveProvider({ ...options, source }), options.runtime?.debugLogger);
163
+ }
88
164
  export function compareCatalogGenerationCandidates(expected, actual) {
89
165
  const changedFields = CANDIDATE_FIELDS.filter((field) => expected[field] !== actual[field]);
90
166
  return { matches: changedFields.length === 0, changedFields };
@@ -122,6 +198,10 @@ function publicEvidence(candidate) {
122
198
  const { sourceConfigFingerprint: _fingerprint, ...evidence } = candidate;
123
199
  return evidence;
124
200
  }
201
+ function gitRefProvenance(resolution) {
202
+ return resolution.transport === 'git' && resolution.resolvedRefObject
203
+ ? { resolvedRefObject: resolution.resolvedRefObject } : {};
204
+ }
125
205
  function sameActive(active, next) {
126
206
  return Boolean(active)
127
207
  && active.sourceConfigFingerprint === next.sourceConfigFingerprint
@@ -133,7 +213,7 @@ function sameActive(active, next) {
133
213
  && active.snapshotDigest === next.snapshotDigest;
134
214
  }
135
215
  const ACTIVE_FIELDS = [
136
- 'sourceConfigFingerprint', 'sourceIdentity', 'requestedRef', 'resolvedCommit',
216
+ 'sourceConfigFingerprint', 'sourceIdentity', 'requestedRef', 'resolvedCommit', 'resolvedRefObject',
137
217
  'logicalIdentity', 'manifestDigest', 'snapshotDigest', 'activatedAt',
138
218
  ];
139
219
  function assertExpectedActive(sourceId, current, expected) {
@@ -242,11 +322,8 @@ async function enforceCatalogActivationCandidatePolicy(options) {
242
322
  }
243
323
  let previous;
244
324
  try {
245
- previous = await readCatalogStoreEntry({
246
- logicalIdentity: options.active.logicalIdentity,
247
- snapshotDigest: options.active.snapshotDigest,
248
- env: options.env,
249
- });
325
+ previous = options.currentStore && storeMatchesActive(options.currentStore, options.active)
326
+ ? options.currentStore : await readActiveStore(options.active, options.env, options.debugLogger);
250
327
  }
251
328
  catch (error) {
252
329
  throw new CatalogGenerationError({
@@ -258,15 +335,15 @@ async function enforceCatalogActivationCandidatePolicy(options) {
258
335
  if (options.source.type === 'git'
259
336
  && options.active.logicalIdentity === options.candidate.logicalIdentity
260
337
  && options.active.snapshotDigest === options.candidate.snapshotDigest) {
261
- return { preserveActive: true };
338
+ return { currentManifest: previous.manifest, preserveActive: true };
262
339
  }
263
340
  if (options.mode === 'explicitSourceChange')
264
- return { preserveActive: false };
341
+ return { currentManifest: previous.manifest, preserveActive: false };
265
342
  if (options.source.type === 'path') {
266
- return { preserveActive: options.active.snapshotDigest === options.candidate.snapshotDigest };
343
+ return { currentManifest: previous.manifest, preserveActive: options.active.snapshotDigest === options.candidate.snapshotDigest };
267
344
  }
268
345
  if (options.active.snapshotDigest === options.candidate.snapshotDigest) {
269
- return { preserveActive: true };
346
+ return { currentManifest: previous.manifest, preserveActive: true };
270
347
  }
271
348
  const relation = compareStrictSemVer(options.candidate.catalogVersion, previous.metadata.catalogVersion);
272
349
  if (relation === 0)
@@ -279,7 +356,7 @@ async function enforceCatalogActivationCandidatePolicy(options) {
279
356
  code: 'catalogRollbackDetected', sourceId: options.sourceId,
280
357
  message: `Catalog source "${options.sourceId}" candidate version is lower than the Active version.`,
281
358
  });
282
- return { preserveActive: false };
359
+ return { currentManifest: previous.manifest, preserveActive: false };
283
360
  }
284
361
  function enforceCatalogActivationImpactPolicy(options) {
285
362
  if (catalogSourceImpactRequiresConfirmation(options.impact) && !options.impactConfirmed) {
@@ -302,14 +379,16 @@ function assertExpectedImpact(options) {
302
379
  }
303
380
  }
304
381
  async function inspectActivationImpact(options) {
305
- return (options.runtime?.inspectSourceImpact ?? inspectCatalogSourceImpact)({
382
+ const inspect = options.runtime?.inspectSourceImpact ?? inspectCatalogSourceImpact;
383
+ return measureCatalogPerformanceStage(options.runtime?.debugLogger, 'catalog.impact', () => inspect({
306
384
  sourceId: options.sourceId,
307
385
  cwd: options.cwd,
308
386
  env: options.env,
309
387
  sourcePrimary: options.source.primary,
310
388
  mode: options.mode,
311
- ...(options.mode === 'generation' ? { candidateManifest: options.candidateManifest } : {}),
312
- });
389
+ ...(options.mode === 'generation'
390
+ ? { candidateManifest: options.candidateManifest, currentManifest: options.currentManifest } : {}),
391
+ }));
313
392
  }
314
393
  function assertStoreMatchesCandidate(sourceId, store, candidate) {
315
394
  if (store.metadata.logicalIdentity !== candidate.logicalIdentity
@@ -320,22 +399,24 @@ function assertStoreMatchesCandidate(sourceId, store, candidate) {
320
399
  message: `Catalog store evidence does not match the validated candidate for source "${sourceId}".`,
321
400
  });
322
401
  }
323
- async function writeLastSync(options) {
324
- return withAwHomeMutationLock({
402
+ async function recordFailure(options) {
403
+ const candidate = options.candidate;
404
+ if (!candidate)
405
+ return;
406
+ await withAwHomeMutationLock({
325
407
  env: options.env,
408
+ token: options.token,
326
409
  signal: options.signal,
327
410
  onContention: options.runtime?.onContention,
328
411
  action: async () => {
329
- await assertCurrentSource(options);
412
+ const binding = { ...options, candidate };
413
+ await assertCurrentSource(binding);
330
414
  const lastSync = {
331
- syncedAt: now(options.runtime), mode: options.mode, state: options.state,
332
- ...(options.state === 'succeeded'
333
- ? { resolvedCommit: options.candidate.resolvedCommit }
334
- : { errorCode: options.errorCode }),
415
+ syncedAt: now(options.runtime), mode: 'sync', state: 'failed', errorCode: options.errorCode,
335
416
  };
336
417
  await withCatalogGenerationStateTransaction({
337
418
  env: options.env,
338
- beforeReplace: async () => { await assertCurrentSource(options); },
419
+ beforeReplace: async () => { await assertCurrentSource(binding); },
339
420
  action: async (current) => ({
340
421
  state: {
341
422
  schemaVersion: 1,
@@ -347,15 +428,8 @@ async function writeLastSync(options) {
347
428
  result: undefined,
348
429
  }),
349
430
  });
350
- return lastSync;
351
431
  },
352
- });
353
- }
354
- async function recordFailure(options) {
355
- if (!options.candidate)
356
- return;
357
- await writeLastSync({ ...options, candidate: options.candidate, state: 'failed' })
358
- .catch(() => undefined);
432
+ }).catch(() => undefined);
359
433
  }
360
434
  async function readCandidateContinuity(sourceId, env) {
361
435
  const source = (await readCatalogSourcesConfigSnapshot(env)).config.sources
@@ -475,6 +549,7 @@ export async function probeCatalogSourceFreshness(options) {
475
549
  cliVersion: options.cliVersion,
476
550
  env,
477
551
  signal: options.signal,
552
+ debugLogger: options.runtime?.debugLogger,
478
553
  });
479
554
  if (remote.sourceId !== source.id || remote.sourceIdentity !== active.sourceIdentity) {
480
555
  throw new CatalogGenerationError({
@@ -491,12 +566,13 @@ export async function probeCatalogSourceFreshness(options) {
491
566
  activeResolvedCommit: active.resolvedCommit,
492
567
  };
493
568
  }
494
- if (remote.resolvedCommit === active.resolvedCommit) {
569
+ const matched = matchObservedGitRef(remote, active.active);
570
+ if (matched) {
495
571
  return {
496
572
  sourceId: source.id,
497
573
  state: 'current',
498
574
  activeVersion: active.catalogVersion,
499
- activeResolvedCommit: remote.resolvedCommit,
575
+ activeResolvedCommit: matched.resolvedCommit,
500
576
  };
501
577
  }
502
578
  }
@@ -522,28 +598,14 @@ export async function probeCatalogSourceFreshness(options) {
522
598
  },
523
599
  };
524
600
  }
525
- export async function recordCatalogGenerationCheck(options) {
526
- const env = options.env ?? process.env;
527
- const lastSync = await writeLastSync({
528
- sourceId: options.probe.sourceId, candidate: options.probe.candidate,
529
- mode: 'check', state: 'succeeded', env,
530
- signal: options.signal, runtime: options.runtime,
531
- });
532
- const active = (await readCatalogGenerationState(env)).sources[options.probe.sourceId]?.active;
533
- return {
534
- catalogGenerationSchemaVersion: 1, sourceId: options.probe.sourceId,
535
- mode: 'check', outcome: 'checked', activeChanged: false,
536
- resolution: publicEvidence(options.probe.candidate),
537
- ...(active ? { active } : {}), lastSync,
538
- };
539
- }
540
601
  async function activateResolvedCandidate(options) {
541
602
  const candidate = options.resolved.candidate;
542
- const store = options.store ?? await publishCatalogStoreEntry({
543
- resolution: options.resolved.resolution, env: options.env, signal: options.signal,
603
+ const reused = options.resolved.reusedGit;
604
+ const store = reused?.store ?? options.store ?? await measureCatalogPerformanceStage(options.runtime?.debugLogger, 'catalog.store.publish', () => publishCatalogStoreEntry({
605
+ resolution: options.resolved.resolution, env: options.env, signal: options.signal, token: options.token,
544
606
  afterInactiveRepairPrepared: options.runtime?.afterInactiveStoreRepairPrepared,
545
607
  onContention: options.runtime?.onContention,
546
- });
608
+ }));
547
609
  assertStoreMatchesCandidate(options.sourceId, store, candidate);
548
610
  return withAwHomeMutationLock({
549
611
  env: options.env,
@@ -551,12 +613,6 @@ async function activateResolvedCandidate(options) {
551
613
  signal: options.signal,
552
614
  onContention: options.runtime?.onContention,
553
615
  action: async () => {
554
- const lockedStore = await readCatalogStoreEntry({
555
- logicalIdentity: store.metadata.logicalIdentity,
556
- snapshotDigest: store.metadata.snapshotDigest,
557
- env: options.env,
558
- });
559
- assertStoreMatchesCandidate(options.sourceId, lockedStore, candidate);
560
616
  const source = await assertCurrentSource({
561
617
  sourceId: options.sourceId,
562
618
  candidate,
@@ -577,6 +633,26 @@ async function activateResolvedCandidate(options) {
577
633
  action: async (current) => {
578
634
  const previous = current.sources[options.sourceId]?.active;
579
635
  assertExpectedActive(options.sourceId, previous, options.expectedActive);
636
+ if (reused)
637
+ assertExpectedActive(options.sourceId, previous, reused.active);
638
+ assertReviewedCandidate(options.sourceId, options.expectedCandidate, candidate);
639
+ let repairResolution;
640
+ const lockedStore = await readCatalogStoreEntry({
641
+ logicalIdentity: candidate.logicalIdentity, snapshotDigest: candidate.snapshotDigest, env: options.env,
642
+ debugLogger: options.runtime?.debugLogger,
643
+ }).catch(async (error) => {
644
+ if (!reused)
645
+ throw error;
646
+ // The Active changed on disk while waiting for the lock. Reproduce
647
+ // the exact candidate before authorizing any replacement.
648
+ const fresh = await reused.materialize();
649
+ assertReviewedCandidate(options.sourceId, candidate, fresh.candidate);
650
+ repairResolution = fresh.resolution;
651
+ return reused.store;
652
+ });
653
+ assertStoreMatchesCandidate(options.sourceId, lockedStore, candidate);
654
+ if (reused)
655
+ assertCapabilitySupport(options.sourceId, lockedStore);
580
656
  const policy = await enforceCatalogActivationCandidatePolicy({
581
657
  sourceId: options.sourceId,
582
658
  source,
@@ -584,6 +660,8 @@ async function activateResolvedCandidate(options) {
584
660
  candidate,
585
661
  mode: options.activationMode,
586
662
  env: options.env,
663
+ currentStore: lockedStore,
664
+ debugLogger: options.runtime?.debugLogger,
587
665
  });
588
666
  const impact = await inspectActivationImpact({
589
667
  sourceId: options.sourceId,
@@ -591,7 +669,8 @@ async function activateResolvedCandidate(options) {
591
669
  cwd: options.cwd ?? process.cwd(),
592
670
  env: options.env,
593
671
  mode: options.impactMode ?? 'generation',
594
- candidateManifest: options.resolved.resolution.manifest,
672
+ candidateManifest: repairResolution?.manifest ?? lockedStore.manifest,
673
+ currentManifest: policy.currentManifest,
595
674
  runtime: options.runtime,
596
675
  });
597
676
  assertExpectedImpact({
@@ -604,18 +683,31 @@ async function activateResolvedCandidate(options) {
604
683
  impact,
605
684
  impactConfirmed: options.impactConfirmed,
606
685
  });
686
+ if (repairResolution) {
687
+ const repair = await prepareCatalogStoreEntryRepair({
688
+ resolution: repairResolution, logicalIdentity: candidate.logicalIdentity,
689
+ snapshotDigest: candidate.snapshotDigest, env: options.env, signal: options.signal,
690
+ });
691
+ try {
692
+ assertStoreMatchesCandidate(options.sourceId, await repair.commit(), candidate);
693
+ }
694
+ finally {
695
+ await repair.cleanup();
696
+ }
697
+ }
607
698
  const activeInput = {
608
699
  sourceConfigFingerprint: candidate.sourceConfigFingerprint,
609
700
  sourceIdentity: candidate.sourceIdentity,
610
701
  requestedRef: candidate.requestedRef,
611
702
  resolvedCommit: candidate.resolvedCommit,
703
+ ...gitRefProvenance(repairResolution ?? options.resolved.resolution),
612
704
  logicalIdentity: store.metadata.logicalIdentity,
613
705
  manifestDigest: store.metadata.manifestDigest,
614
706
  snapshotDigest: store.metadata.snapshotDigest,
615
707
  };
616
708
  const unchanged = policy.preserveActive || sameActive(previous, activeInput);
617
709
  const active = unchanged
618
- ? policy.preserveActive && source.type === 'git'
710
+ ? source.type === 'git'
619
711
  ? { ...activeInput, activatedAt: previous.activatedAt }
620
712
  : previous
621
713
  : { ...activeInput, activatedAt: syncedAt };
@@ -639,28 +731,37 @@ async function activateResolvedCandidate(options) {
639
731
  },
640
732
  });
641
733
  }
642
- export async function activateCatalogSourceGeneration(options) {
734
+ function assertReviewedCandidate(sourceId, expected, actual) {
735
+ if (expected && !compareCatalogGenerationCandidates(expected, actual).matches) {
736
+ throw new CatalogGenerationError({
737
+ code: 'catalogGenerationReviewStale', sourceId,
738
+ message: `Catalog source "${sourceId}" changed after review. Review it again.`,
739
+ });
740
+ }
741
+ }
742
+ export function activateCatalogSourceGeneration(options) {
743
+ return activateReviewedSource(options);
744
+ }
745
+ async function activateReviewedSource(options, reviewedStore) {
643
746
  const env = options.env ?? process.env;
644
747
  const initialCandidate = await readCandidateContinuity(options.sourceId, env);
645
748
  let resolved;
646
749
  try {
647
- resolved = await resolveCandidate({ ...options, env });
648
- if (options.expectedCandidate
649
- && !compareCatalogGenerationCandidates(options.expectedCandidate, resolved.candidate).matches) {
650
- throw new CatalogGenerationError({
651
- code: 'catalogGenerationReviewStale', sourceId: options.sourceId,
652
- message: `Catalog source "${options.sourceId}" changed after review. Review it again.`,
653
- });
654
- }
655
750
  const activationMode = options.activationMode ?? 'normal';
656
751
  const active = (await readCatalogGenerationState(env)).sources[options.sourceId]?.active;
752
+ resolved = await resolveCandidate({
753
+ ...options, env, reuseActive: activationMode === 'normal' ? active : undefined, reviewedStore,
754
+ });
755
+ assertReviewedCandidate(options.sourceId, options.expectedCandidate, resolved.candidate);
657
756
  assertExpectedActive(options.sourceId, active, options.expectedActive);
658
- await enforceCatalogActivationCandidatePolicy({
757
+ const policy = await enforceCatalogActivationCandidatePolicy({
659
758
  sourceId: options.sourceId,
660
759
  source: resolved.source,
661
760
  active,
662
761
  candidate: resolved.candidate,
663
762
  mode: activationMode,
763
+ currentStore: resolved.reusedGit?.store ?? reviewedStore,
764
+ debugLogger: options.runtime?.debugLogger,
664
765
  env,
665
766
  });
666
767
  const impact = await inspectActivationImpact({
@@ -670,6 +771,7 @@ export async function activateCatalogSourceGeneration(options) {
670
771
  source: resolved.source,
671
772
  mode: options.impactMode ?? 'generation',
672
773
  candidateManifest: resolved.resolution.manifest,
774
+ currentManifest: policy.currentManifest,
673
775
  runtime: options.runtime,
674
776
  });
675
777
  assertExpectedImpact({
@@ -690,10 +792,10 @@ export async function activateCatalogSourceGeneration(options) {
690
792
  if (!(error instanceof CatalogGenerationError
691
793
  && error.code === 'catalogGenerationReviewStale')) {
692
794
  await recordFailure({
693
- sourceId: options.sourceId, candidate: resolved?.candidate ?? initialCandidate, mode: 'sync',
795
+ sourceId: options.sourceId, candidate: resolved?.candidate ?? initialCandidate,
694
796
  errorCode: error instanceof CatalogGenerationError
695
797
  ? error.code : 'catalogGenerationRefreshFailed',
696
- env, signal: options.signal, runtime: options.runtime,
798
+ env, signal: options.signal, runtime: options.runtime, token: options.token,
697
799
  });
698
800
  }
699
801
  if (error instanceof CatalogGenerationError)
@@ -791,6 +893,7 @@ export async function recoverCatalogGenerationStateAndActivate(options) {
791
893
  sourceIdentity: candidate.sourceIdentity,
792
894
  requestedRef: candidate.requestedRef,
793
895
  resolvedCommit: candidate.resolvedCommit,
896
+ ...gitRefProvenance(resolved.resolution),
794
897
  logicalIdentity: store.metadata.logicalIdentity,
795
898
  manifestDigest: store.metadata.manifestDigest,
796
899
  snapshotDigest: store.metadata.snapshotDigest,
@@ -1072,13 +1175,14 @@ export async function replaceDamagedCatalogSourceGeneration(options) {
1072
1175
  sourceIdentity: resolved.candidate.sourceIdentity,
1073
1176
  requestedRef: resolved.candidate.requestedRef,
1074
1177
  resolvedCommit: resolved.candidate.resolvedCommit,
1178
+ ...gitRefProvenance(resolved.resolution),
1075
1179
  logicalIdentity: store.metadata.logicalIdentity,
1076
1180
  manifestDigest: store.metadata.manifestDigest,
1077
1181
  snapshotDigest: store.metadata.snapshotDigest,
1078
1182
  };
1079
1183
  const unchanged = sameActive(previous, activeInput);
1080
1184
  const active = unchanged
1081
- ? previous
1185
+ ? { ...activeInput, activatedAt: previous.activatedAt }
1082
1186
  : { ...activeInput, activatedAt: syncedAt };
1083
1187
  const lastSync = {
1084
1188
  syncedAt,
@@ -1140,6 +1244,12 @@ export async function syncCatalogSourceGeneration(options) {
1140
1244
  const env = options.env ?? process.env;
1141
1245
  if (!options.check) {
1142
1246
  const config = await readCatalogSourcesConfigSnapshot(env);
1247
+ if (options.expectedConfigDigest && config.digest !== options.expectedConfigDigest) {
1248
+ throw new CatalogGenerationError({
1249
+ code: 'catalogGenerationReviewStale', sourceId: options.sourceId,
1250
+ message: `Catalog source "${options.sourceId}" configuration changed after review.`,
1251
+ });
1252
+ }
1143
1253
  const active = (await readCatalogGenerationState(env)).sources[options.sourceId]?.active;
1144
1254
  if (options.replaceDamaged === true && options.impactConfirmed !== true) {
1145
1255
  throw new CatalogGenerationError({
@@ -1147,13 +1257,11 @@ export async function syncCatalogSourceGeneration(options) {
1147
1257
  message: '--replace-damaged requires --yes.',
1148
1258
  });
1149
1259
  }
1260
+ assertExpectedActive(options.sourceId, active, options.expectedActive);
1261
+ let reviewedStore;
1150
1262
  if (active) {
1151
- const damaged = await readCatalogStoreEntry({
1152
- logicalIdentity: active.logicalIdentity,
1153
- snapshotDigest: active.snapshotDigest,
1154
- env,
1155
- }).then(() => false).catch(() => true);
1156
- if (damaged) {
1263
+ reviewedStore = await readActiveStore(active, env, options.runtime?.debugLogger).catch(() => undefined);
1264
+ if (!reviewedStore) {
1157
1265
  try {
1158
1266
  await repairCatalogSourceGeneration({
1159
1267
  ...options,
@@ -1183,42 +1291,39 @@ export async function syncCatalogSourceGeneration(options) {
1183
1291
  });
1184
1292
  }
1185
1293
  }
1186
- return activateCatalogSourceGeneration({
1294
+ return activateReviewedSource({
1187
1295
  ...options,
1188
1296
  env,
1189
1297
  expectedActive: active ?? null,
1190
1298
  activationMode: await inferredActivationMode({ sourceId: options.sourceId, active, env }),
1191
- });
1299
+ }, reviewedStore);
1192
1300
  }
1193
- const initialCandidate = await readCandidateContinuity(options.sourceId, env);
1194
- let probe;
1301
+ const state = (await readCatalogGenerationState(env)).sources[options.sourceId];
1302
+ return checkCatalogSourceGeneration({ ...options, env }, state);
1303
+ }
1304
+ async function checkCatalogSourceGeneration(options, state, observedStore) {
1305
+ const { env } = options;
1306
+ const reviewedStore = observedStore === undefined && state?.active
1307
+ ? await readActiveStore(state.active, env, options.runtime?.debugLogger).catch(() => null)
1308
+ : observedStore;
1309
+ let resolved;
1195
1310
  try {
1196
- probe = await probeCatalogSourceGeneration({ ...options, env });
1197
- const source = (await readCatalogSourcesConfigSnapshot(env)).config.sources
1198
- .find((entry) => entry.id === options.sourceId);
1199
- const impact = await inspectCatalogSourceImpact({
1200
- sourceId: options.sourceId,
1201
- cwd: options.cwd ?? process.cwd(),
1202
- env,
1203
- sourcePrimary: source?.primary === true,
1204
- mode: 'generation',
1205
- candidateManifest: probe.manifest,
1206
- });
1207
- const result = await recordCatalogGenerationCheck({
1208
- probe,
1209
- env,
1210
- signal: options.signal,
1211
- runtime: options.runtime,
1311
+ resolved = await resolveCandidate({ ...options, env, reuseActive: state?.active, reviewedStore });
1312
+ const impact = await inspectActivationImpact({
1313
+ sourceId: options.sourceId, source: resolved.source, cwd: options.cwd ?? process.cwd(), env,
1314
+ mode: 'generation', candidateManifest: resolved.resolution.manifest,
1315
+ currentManifest: reviewedStore === null ? null : reviewedStore?.manifest, runtime: options.runtime,
1212
1316
  });
1213
- return { ...result, impact };
1317
+ await assertCurrentSource({ ...options, env, candidate: resolved.candidate });
1318
+ return {
1319
+ catalogGenerationSchemaVersion: 1, sourceId: options.sourceId, mode: 'check', outcome: 'checked',
1320
+ activeChanged: false, resolution: publicEvidence(resolved.candidate),
1321
+ ...(state?.active ? { active: state.active } : {}),
1322
+ ...(state?.lastSync ? { lastSync: state.lastSync } : {}),
1323
+ impact,
1324
+ };
1214
1325
  }
1215
1326
  catch (error) {
1216
- await recordFailure({
1217
- sourceId: options.sourceId, candidate: probe?.candidate ?? initialCandidate, mode: 'check',
1218
- errorCode: error instanceof CatalogGenerationError
1219
- ? error.code : 'catalogGenerationRefreshFailed',
1220
- env, signal: options.signal, runtime: options.runtime,
1221
- });
1222
1327
  if (error instanceof CatalogGenerationError)
1223
1328
  throw error;
1224
1329
  throw new CatalogGenerationError({
@@ -1226,8 +1331,47 @@ export async function syncCatalogSourceGeneration(options) {
1226
1331
  message: `Cannot check Catalog source "${options.sourceId}".`, cause: error,
1227
1332
  });
1228
1333
  }
1334
+ finally {
1335
+ if (resolved)
1336
+ await resolved.resolution.cleanup().catch(() => warnCleanupFailure(options.sourceId));
1337
+ }
1338
+ }
1339
+ export function readCatalogGenerationStatus(options = {}) {
1340
+ return observeCatalogGenerationStatus(options);
1341
+ }
1342
+ export async function readRemoteCatalogGenerationStatus(options) {
1343
+ // Each source's status and impact refer to the very same local observation,
1344
+ // including when two aliases share a physical store. Never reuse this map for sync.
1345
+ const activeStores = new Map();
1346
+ const status = await observeCatalogGenerationStatus({ ...options, debugLogger: options.runtime?.debugLogger }, (id, entry) => activeStores.set(id, entry));
1347
+ const remote = await Promise.all(status.sources.map(async ({ sourceId, active, lastSync }) => {
1348
+ const started = performance.now();
1349
+ const report = (status) => {
1350
+ try {
1351
+ options.onCheckProgress?.({ sourceId, status,
1352
+ ...(status === 'start' ? {} : { durationMs: performance.now() - started }) });
1353
+ }
1354
+ catch { /* Progress observers cannot change a remote check's result. */ }
1355
+ };
1356
+ report('start');
1357
+ try {
1358
+ const result = await checkCatalogSourceGeneration({ ...options, sourceId }, { active, lastSync }, active ? activeStores.get(sourceId) ?? null : undefined);
1359
+ report('done');
1360
+ return {
1361
+ sourceId, checked: true, candidate: result.resolution, outcome: result.outcome, impact: result.impact,
1362
+ };
1363
+ }
1364
+ catch (error) {
1365
+ report('fail');
1366
+ return {
1367
+ sourceId, checked: false,
1368
+ error: { code: catalogGenerationErrorCode(error), message: sanitizeCatalogSourceError(error, options.env).message },
1369
+ };
1370
+ }
1371
+ }));
1372
+ return { ...status, remote };
1229
1373
  }
1230
- export async function readCatalogGenerationStatus(options = {}) {
1374
+ async function observeCatalogGenerationStatus(options, onValidated) {
1231
1375
  const env = options.env ?? process.env;
1232
1376
  const config = await readCatalogSourcesConfigSnapshot(env);
1233
1377
  const state = await readCatalogGenerationState(env);
@@ -1257,6 +1401,7 @@ export async function readCatalogGenerationStatus(options = {}) {
1257
1401
  logicalIdentity: active.logicalIdentity,
1258
1402
  snapshotDigest: active.snapshotDigest,
1259
1403
  env,
1404
+ debugLogger: options.debugLogger,
1260
1405
  validatedStoreEntries: options.validatedStoreEntries,
1261
1406
  validatingStoreEntries: options.validatingStoreEntries,
1262
1407
  });
@@ -1264,6 +1409,7 @@ export async function readCatalogGenerationStatus(options = {}) {
1264
1409
  throw new CatalogGenerationError({
1265
1410
  code: 'catalogGenerationIdentityMismatch', message: 'Active does not match store metadata.',
1266
1411
  });
1412
+ onValidated?.(source.id, entry);
1267
1413
  const compatibility = projectCatalogCapabilityCompatibility(entry.metadata.requiredAwCapabilities);
1268
1414
  return {
1269
1415
  sourceId: source.id, configuredSourceIdentity, active,