@lesliechan721/aw 0.1.0-beta.83 → 0.1.0-beta.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring/assets/aw-runtime-config.mjs +1 -1
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/src/commands/console.js +1 -0
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +1 -0
- package/dist/src/commands/intent-command.js +6 -2
- package/dist/src/commands/intent-command.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +3 -3
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +14 -13
- package/dist/src/commands/public-lifecycle-result.js +204 -64
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.d.ts +1 -2
- package/dist/src/commands/public-lifecycle.js +56 -34
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +44 -11
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +13 -3
- package/dist/src/commands/rebuild-command.js +665 -288
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +6 -2
- package/dist/src/commands/rebuild-integration.js +60 -29
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +1 -0
- package/dist/src/commands/rebuild-operations.js +28 -6
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +20 -5
- package/dist/src/commands/rebuild-platform-integration.js +752 -182
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +7 -1
- package/dist/src/generators/permissions.js +56 -0
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +112 -54
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/scope-context.d.ts +4 -2
- package/dist/src/intent/scope-context.js +37 -7
- package/dist/src/intent/scope-context.js.map +1 -1
- package/dist/src/output/component-delivery.d.ts +21 -0
- package/dist/src/output/component-delivery.js +82 -0
- package/dist/src/output/component-delivery.js.map +1 -0
- package/dist/src/output/public-result.d.ts +4 -0
- package/dist/src/output/public-result.js +85 -15
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/rebuild-progress.d.ts +3 -0
- package/dist/src/output/rebuild-progress.js +12 -2
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.js +64 -19
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/output/skill-invocation-notices.d.ts +18 -0
- package/dist/src/output/skill-invocation-notices.js +84 -0
- package/dist/src/output/skill-invocation-notices.js.map +1 -0
- package/dist/src/platforms/capabilities.d.ts +6 -1
- package/dist/src/platforms/capabilities.js +161 -38
- package/dist/src/platforms/capabilities.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +45 -10
- package/dist/src/platforms/discovery.d.ts +11 -7
- package/dist/src/platforms/discovery.js +176 -76
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/inspection-grok.js +121 -9
- package/dist/src/platforms/inspection-grok.js.map +1 -1
- package/dist/src/platforms/inspection-native.js +53 -97
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/inspection-pi.d.ts +7 -1
- package/dist/src/platforms/inspection-pi.js +295 -95
- package/dist/src/platforms/inspection-pi.js.map +1 -1
- package/dist/src/platforms/inspection-query.d.ts +6 -5
- package/dist/src/platforms/inspection-query.js +30 -25
- package/dist/src/platforms/inspection-query.js.map +1 -1
- package/dist/src/platforms/inspection.d.ts +4 -1
- package/dist/src/platforms/inspection.js +38 -6
- package/dist/src/platforms/inspection.js.map +1 -1
- package/dist/src/platforms/layout.d.ts +6 -0
- package/dist/src/platforms/layout.js +45 -12
- package/dist/src/platforms/layout.js.map +1 -1
- package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
- package/dist/src/platforms/lifecycle-native-services.js +14 -14
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.d.ts +1 -0
- package/dist/src/platforms/lifecycle-native.js +29 -89
- package/dist/src/platforms/lifecycle-native.js.map +1 -1
- package/dist/src/platforms/lifecycle.d.ts +2 -0
- package/dist/src/platforms/lifecycle.js +120 -69
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/platforms/projection-code-extension.js +9 -4
- package/dist/src/platforms/projection-code-extension.js.map +1 -1
- package/dist/src/platforms/projection.d.ts +3 -0
- package/dist/src/platforms/projection.js +152 -72
- package/dist/src/platforms/projection.js.map +1 -1
- package/dist/src/platforms/supplement-layout.d.ts +5 -1
- package/dist/src/platforms/supplement-layout.js +23 -1
- package/dist/src/platforms/supplement-layout.js.map +1 -1
- package/dist/src/platforms/supplement-state.d.ts +1 -1
- package/dist/src/platforms/supplement-state.js +18 -7
- package/dist/src/platforms/supplement-state.js.map +1 -1
- package/dist/src/portable/commands.js +1 -1
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +4 -0
- package/dist/src/portable/materializer.js +9 -2
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +31 -3
- package/dist/src/portable/recovery.js +261 -82
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +19 -5
- package/dist/src/recovery/coordinator.js +433 -174
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/install-concurrency.d.ts +48 -0
- package/dist/src/recovery/install-concurrency.js +196 -0
- package/dist/src/recovery/install-concurrency.js.map +1 -0
- package/dist/src/recovery/interruption.d.ts +19 -0
- package/dist/src/recovery/interruption.js +43 -0
- package/dist/src/recovery/interruption.js.map +1 -0
- package/dist/src/recovery/joint-coordinator.d.ts +18 -4
- package/dist/src/recovery/joint-coordinator.js +829 -341
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.d.ts +22 -2
- package/dist/src/recovery/joint-demand.js +104 -6
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/joint-install-execution.d.ts +19 -0
- package/dist/src/recovery/joint-install-execution.js +307 -0
- package/dist/src/recovery/joint-install-execution.js.map +1 -0
- package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
- package/dist/src/recovery/joint-install-native-rebase.js +67 -0
- package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
- package/dist/src/recovery/receipt.d.ts +35 -4
- package/dist/src/recovery/receipt.js +90 -1
- package/dist/src/recovery/receipt.js.map +1 -1
- package/dist/src/recovery/retirement.js +1 -1
- package/dist/src/recovery/retirement.js.map +1 -1
- package/dist/src/recovery/status.d.ts +20 -8
- package/dist/src/recovery/status.js +405 -116
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/platform-profile.d.ts +4 -1
- package/dist/src/review/platform-profile.js +14 -4
- package/dist/src/review/platform-profile.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +2 -0
- package/dist/src/review/skill-materialization.js +68 -50
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/review/source-binding.js +11 -5
- package/dist/src/review/source-binding.js.map +1 -1
- package/dist/src/tui/console-app-v4.d.ts +1 -1
- package/dist/src/tui/console-app-v4.js +180 -63
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +46 -10
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +15 -5
- package/dist/src/tui/controller.js +246 -102
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/deployment-view.d.ts +6 -3
- package/dist/src/tui/deployment-view.js +43 -9
- package/dist/src/tui/deployment-view.js.map +1 -1
- package/dist/src/tui/diagnostic-projection.d.ts +11 -3
- package/dist/src/tui/diagnostic-projection.js +85 -4
- package/dist/src/tui/diagnostic-projection.js.map +1 -1
- package/dist/src/tui/entity-cards.d.ts +2 -1
- package/dist/src/tui/entity-cards.js +34 -11
- package/dist/src/tui/entity-cards.js.map +1 -1
- package/dist/src/tui/glossary.js +5 -0
- package/dist/src/tui/glossary.js.map +1 -1
- package/dist/src/tui/model.js +2 -1
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +1 -1
- package/dist/src/tui/operation-diagnostic-screens.js +6 -2
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
- package/dist/src/tui/operation-history.d.ts +12 -3
- package/dist/src/tui/operation-history.js +34 -3
- package/dist/src/tui/operation-history.js.map +1 -1
- package/dist/src/tui/plugin-detail.d.ts +4 -1
- package/dist/src/tui/plugin-detail.js +9 -2
- package/dist/src/tui/plugin-detail.js.map +1 -1
- package/dist/src/tui/scoped-flow.d.ts +3 -1
- package/dist/src/tui/scoped-flow.js +117 -1
- package/dist/src/tui/scoped-flow.js.map +1 -1
- package/dist/src/tui/scoped-inventory.d.ts +6 -2
- package/dist/src/tui/scoped-inventory.js +29 -7
- package/dist/src/tui/scoped-inventory.js.map +1 -1
- package/dist/src/tui/session-console-app.d.ts +2 -0
- package/dist/src/tui/session-console-app.js +11 -0
- package/dist/src/tui/session-console-app.js.map +1 -1
- package/dist/src/types.d.ts +10 -2
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/artifact-plan.js +5 -1
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +1 -1
- package/dist/src/utils/artifact-renderer.js +29 -8
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.js +2 -1
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/catalog-source-references.js +14 -17
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +6 -0
- package/dist/src/utils/codex-native-observation.js +32 -3
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/component-command-preparation.d.ts +2 -0
- package/dist/src/utils/component-command-preparation.js +23 -4
- package/dist/src/utils/component-command-preparation.js.map +1 -1
- package/dist/src/utils/component-gap.d.ts +4 -0
- package/dist/src/utils/component-gap.js +20 -0
- package/dist/src/utils/component-gap.js.map +1 -0
- package/dist/src/utils/component-resources.js +2 -4
- package/dist/src/utils/component-resources.js.map +1 -1
- package/dist/src/utils/dynamic-skill-tree.js +2 -32
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.d.ts +2 -1
- package/dist/src/utils/managed-command-materialization.js +3 -3
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-store.d.ts +6 -0
- package/dist/src/utils/managed-command-store.js +90 -18
- package/dist/src/utils/managed-command-store.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +2 -0
- package/dist/src/utils/multi-source-catalog.js +3 -2
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli-interruption.d.ts +8 -0
- package/dist/src/utils/native-cli-interruption.js +65 -0
- package/dist/src/utils/native-cli-interruption.js.map +1 -0
- package/dist/src/utils/native-cli.d.ts +5 -19
- package/dist/src/utils/native-cli.js +168 -95
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +1 -0
- package/dist/src/utils/ownership.js +18 -4
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/package-content.d.ts +7 -0
- package/dist/src/utils/package-content.js +70 -0
- package/dist/src/utils/package-content.js.map +1 -0
- package/dist/src/utils/platform-empty-state.d.ts +32 -9
- package/dist/src/utils/platform-empty-state.js +135 -70
- package/dist/src/utils/platform-empty-state.js.map +1 -1
- package/dist/src/utils/plugin-config-write.d.ts +8 -0
- package/dist/src/utils/plugin-config-write.js +93 -25
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-scripts.js +24 -8
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +1 -1
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/skill-invocation-warning.d.ts +20 -0
- package/dist/src/utils/skill-invocation-warning.js +68 -0
- package/dist/src/utils/skill-invocation-warning.js.map +1 -0
- package/package.json +3 -3
- package/dist/src/output/native-consent.d.ts +0 -2
- package/dist/src/output/native-consent.js +0 -5
- package/dist/src/output/native-consent.js.map +0 -1
- package/dist/src/platforms/gemini-activation.d.ts +0 -36
- package/dist/src/platforms/gemini-activation.js +0 -331
- package/dist/src/platforms/gemini-activation.js.map +0 -1
- package/dist/src/platforms/gemini-consent.d.ts +0 -8
- package/dist/src/platforms/gemini-consent.js +0 -81
- package/dist/src/platforms/gemini-consent.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describeNativeToolClosure } from '../utils/native-tool-review.js';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { isDeliveryCapabilityGap } from '../utils/component-gap.js';
|
|
3
4
|
import { CatalogSourceInventoryIncompleteError } from '../utils/catalog-source-references.js';
|
|
4
5
|
import { inventoryRecoveryDiagnostic } from '../utils/inventory-recovery-diagnostic.js';
|
|
5
6
|
import { getCommandPackageId } from '@lesliechan721/aw-plugin-core/manifest';
|
|
@@ -11,25 +12,28 @@ import { bindNativeCliRunnerSignal, getDefaultNativeCliRunner, prepareNativeCliE
|
|
|
11
12
|
import { portableRecoveryLayout } from '../portable/recovery-layout.js';
|
|
12
13
|
import { canonicalizePathThroughExistingAncestor, resolveClaudeProjectKey, resolveCodexProjectKey } from '../utils/state-paths.js';
|
|
13
14
|
import { parsePluginId } from '../utils/multi-source-catalog.js';
|
|
14
|
-
import { CatalogPreparationReadScope } from '../utils/catalog-operation-context.js';
|
|
15
|
+
import { CatalogPreparationReadScope, selectCatalogOperationContext } from '../utils/catalog-operation-context.js';
|
|
15
16
|
import { CatalogGenerationError } from '../utils/catalog-generation-error.js';
|
|
16
17
|
import { createCatalogPreparationStoreKey } from '../utils/catalog-generation-resolver.js';
|
|
17
18
|
import { activateCatalogSourceGeneration, probeCatalogSourceGeneration, } from '../utils/catalog-generation-service.js';
|
|
18
19
|
import { readCatalogGenerationState } from '../utils/catalog-generation-state.js';
|
|
19
20
|
import { readCatalogSourcesConfigSnapshot } from '../utils/catalog-sources.js';
|
|
20
21
|
import { calculateCatalogSourceImpactDigest, inspectCatalogSourceImpact, } from '../utils/catalog-source-impact.js';
|
|
21
|
-
import { preparePortableRecovery, portablePreparationDiagnostic, preparePortableCleanup, inspectPortableRecovery, inspectPortableResidue, executePortableRecovery, } from '../portable/recovery.js';
|
|
22
|
+
import { preparePortableRecovery, portablePreparationDiagnostic, portableReviewMatches, unobservedPortableTarget, preparePortableCleanup, inspectPortableRecovery, inspectPortableResidue, executePortableRecovery, PortableInterruptedError, } from '../portable/recovery.js';
|
|
22
23
|
import { addRequirements } from '../commands/intent-command.js';
|
|
23
24
|
import { readDemand, demandNativeProjection, resolveDelivery } from './demand.js';
|
|
24
25
|
import { selectAgents, writePreferences } from '../intent/deployment-preferences.js';
|
|
25
26
|
import { calculateIntentDigest } from '../intent/intent-codec.js';
|
|
26
27
|
import { observeIntent } from '../intent/intent-store.js';
|
|
27
28
|
import { assertNeutralAncestorChain, createScopeContext } from '../intent/scope-context.js';
|
|
29
|
+
import { retainedOutputDiagnostic, scopeNativeComponentGaps, uniqueRecoveryComponentGaps } from './receipt.js';
|
|
28
30
|
import { prepareJointRecovery, executeJointRecovery } from './joint-coordinator.js';
|
|
29
31
|
import { createEmptyNativeDemandView } from '../utils/native-demand.js';
|
|
30
32
|
import { resolvePluginMetaDependencyClosure } from '../utils/plugin-dependencies.js';
|
|
31
33
|
import { runPreApplyScript } from '../utils/plugin-scripts.js';
|
|
32
34
|
import { readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
|
|
35
|
+
import { RebuildInterruptedError, RecoveryInterruptedError, recoveryInterruptionCode } from './interruption.js';
|
|
36
|
+
import { mapInstallReads } from './install-concurrency.js';
|
|
33
37
|
import { measureRecoveryPerformanceStage } from './performance.js';
|
|
34
38
|
import { disposePreparedPlatformRebuildSession } from '../commands/rebuild-integration.js';
|
|
35
39
|
import { operationPlanNativeToolChanges } from '../commands/operation-plan.js';
|
|
@@ -147,6 +151,24 @@ function nativeTargetSelection(targets) {
|
|
|
147
151
|
return { pluginIds: [...new Set(targets.map((target) => target.pluginId))],
|
|
148
152
|
platform: platforms.size === 1 ? targets[0].platform : 'both', targets: [...targets] };
|
|
149
153
|
}
|
|
154
|
+
// Rebuild accumulates one marketplace generation per platform across sources and scopes.
|
|
155
|
+
async function readNativeGroups(groups, read, signal) {
|
|
156
|
+
const lanes = new Map();
|
|
157
|
+
for (const group of groups) {
|
|
158
|
+
const key = group.command === 'install' || group.command === 'sync' ? group.platform : 'serial';
|
|
159
|
+
const lane = lanes.get(key) ?? [];
|
|
160
|
+
lane.push(group);
|
|
161
|
+
lanes.set(key, lane);
|
|
162
|
+
}
|
|
163
|
+
const results = new Map();
|
|
164
|
+
await mapInstallReads([...lanes.values()], async (lane) => {
|
|
165
|
+
for (const group of lane) {
|
|
166
|
+
signal?.throwIfAborted();
|
|
167
|
+
results.set(group, await read(group));
|
|
168
|
+
}
|
|
169
|
+
}, { signal });
|
|
170
|
+
return groups.map((group) => results.get(group));
|
|
171
|
+
}
|
|
150
172
|
async function nativeOperation(plan, pluginIds, platform, preview, runtime = plan.runtime, command = plan.command, selectedTargets, catalogReadScope) {
|
|
151
173
|
if (!runtime.awHomeMutationToken) {
|
|
152
174
|
await prepareNativeCliExecution({ env: plan.context.env, runner: runtime.nativeCliRunner });
|
|
@@ -200,24 +222,28 @@ function nativeResults(plan, group, result, executed) {
|
|
|
200
222
|
...(plan.receipt.commandResults ?? []), ...result.commandResults,
|
|
201
223
|
].map((entry) => [getCommandPackageId(entry.producer), entry])).values()];
|
|
202
224
|
}
|
|
225
|
+
const backend = buildRebuildReceiptJson(group.command === 'install' ? 'sync' : group.command, result);
|
|
203
226
|
for (const { pluginId, platform } of nativeGroupTargets(group)) {
|
|
204
227
|
const agent = agentForPlatform(platform);
|
|
205
228
|
const target = pair(plan, pluginId, agent);
|
|
206
229
|
if (!target)
|
|
207
230
|
continue;
|
|
208
|
-
const backend = buildRebuildReceiptJson(group.command === 'install' ? 'sync' : group.command, result);
|
|
209
231
|
target.backend = backend;
|
|
210
|
-
target.
|
|
211
|
-
|
|
212
|
-
|
|
232
|
+
const matchesTarget = (entry) => entry.target.pluginId === pluginId
|
|
233
|
+
&& entry.target.platform === platform && entry.target.scope === plan.options.scope;
|
|
234
|
+
const backendTargets = result.targetResults.filter(matchesTarget);
|
|
213
235
|
const deploymentPlans = new Map([
|
|
214
236
|
...(group.preview.operationPlan?.deploymentPlans ?? []),
|
|
215
237
|
...(result.operationPlan?.deploymentPlans ?? []),
|
|
216
238
|
].filter((deployment) => deployment.binding.plugin.pluginId === pluginId
|
|
217
239
|
&& deployment.binding.platform === platform && deployment.binding.scope.kind === plan.options.scope)
|
|
218
240
|
.map((deployment) => [deployment.binding.id, deployment]));
|
|
219
|
-
if (deploymentPlans.size)
|
|
241
|
+
if (deploymentPlans.size) {
|
|
220
242
|
target.deploymentPlans = [...deploymentPlans.values()];
|
|
243
|
+
const gaps = target.deploymentPlans.flatMap(({ expected, evidence }) => scopeNativeComponentGaps(expected.unmet, target, evidence.renderUnits));
|
|
244
|
+
if (gaps.length)
|
|
245
|
+
target.componentGaps = uniqueRecoveryComponentGaps(gaps);
|
|
246
|
+
}
|
|
221
247
|
const exclusions = [
|
|
222
248
|
...(group.preview.deploymentExclusions ?? []),
|
|
223
249
|
...(result.deploymentExclusions ?? []),
|
|
@@ -249,6 +275,12 @@ function nativeResults(plan, group, result, executed) {
|
|
|
249
275
|
&& target.target.scope === (result.dependencyPlan?.targets.find((dependency) => dependency.pluginId === producerPluginId && dependency.platform === platform)?.resolvedScope
|
|
250
276
|
?? plan.options.scope));
|
|
251
277
|
});
|
|
278
|
+
target.recoveryActions = backend.targetResults.length || backend.commandResults?.length
|
|
279
|
+
? [...new Set([
|
|
280
|
+
...backend.targetResults.filter(matchesTarget).flatMap((entry) => entry.recoveryActions),
|
|
281
|
+
...producers.flatMap((producer) => producer.recoveryActions),
|
|
282
|
+
])]
|
|
283
|
+
: backend.recoveryActions;
|
|
252
284
|
for (const failure of backendTargets.filter((entry) => entry.state === 'failed')) {
|
|
253
285
|
block(target, failure.errorCode ?? 'nativeRecoveryFailed');
|
|
254
286
|
}
|
|
@@ -324,15 +356,49 @@ function nativeResults(plan, group, result, executed) {
|
|
|
324
356
|
target.observation = succeeded ? 'verified' : 'unknown';
|
|
325
357
|
target.content = succeeded ? 'satisfied' : 'unknown';
|
|
326
358
|
}
|
|
359
|
+
if (deployments.length && plan.command !== 'cleanup' && plan.command !== 'uninstall') {
|
|
360
|
+
const gaps = deployments.flatMap((entry) => scopeNativeComponentGaps(entry.unmet, target, deploymentPlans.get(entry.bindingId)?.evidence.renderUnits));
|
|
361
|
+
if (gaps.length)
|
|
362
|
+
target.componentGaps = uniqueRecoveryComponentGaps(gaps);
|
|
363
|
+
const installed = new Set(deployments.flatMap((entry) => {
|
|
364
|
+
const deployment = deploymentPlans.get(entry.bindingId);
|
|
365
|
+
if (!deployment)
|
|
366
|
+
return [];
|
|
367
|
+
const ids = new Set(deployment.expected.components.map(({ id }) => id));
|
|
368
|
+
if (!succeeded) {
|
|
369
|
+
const partial = new Set(deployment.effects.filter((effect) => (effect.kind === 'publish-package' || effect.kind === 'write-supplement')
|
|
370
|
+
&& entry.effects.some((actual) => actual.id === effect.id && actual.status === 'applied' && actual.mutation === 'confirmed'))
|
|
371
|
+
.flatMap((effect) => effect.componentIds));
|
|
372
|
+
for (const id of ids)
|
|
373
|
+
if (!partial.has(id))
|
|
374
|
+
ids.delete(id);
|
|
375
|
+
}
|
|
376
|
+
for (const gap of entry.unmet)
|
|
377
|
+
if (!isDeliveryCapabilityGap(gap))
|
|
378
|
+
ids.delete(gap.componentId ?? gap.id);
|
|
379
|
+
return entry.after.components.filter(({ id, presence, reasonCodes }) => ids.has(id) && presence === 'present' && !reasonCodes.length).map(({ id }) => id);
|
|
380
|
+
}));
|
|
381
|
+
if (installed.size || succeeded && target.deploymentPlans?.every(({ expected }) => !expected.components.length)) {
|
|
382
|
+
target.installedComponentCount = installed.size;
|
|
383
|
+
target.installedComponentIds = [...installed];
|
|
384
|
+
}
|
|
385
|
+
if (succeeded && !target.blockers.length && gaps.every(isDeliveryCapabilityGap)) {
|
|
386
|
+
if (installed.size)
|
|
387
|
+
target.satisfaction = 'installed';
|
|
388
|
+
else if (gaps.length && target.deploymentPlans?.every(({ expected }) => !expected.components.length))
|
|
389
|
+
target.satisfaction = 'not-applicable';
|
|
390
|
+
}
|
|
391
|
+
}
|
|
327
392
|
if (!succeeded && !target.blockers.length)
|
|
328
393
|
block(target, 'nativeRecoveryFailed');
|
|
329
394
|
}
|
|
330
395
|
}
|
|
331
396
|
}
|
|
332
397
|
/** All scopes share one final marketplace generation before Review is returned. */
|
|
333
|
-
export async function refreshRecoveryNativePreviews(plan, catalogReadScope) {
|
|
334
|
-
|
|
335
|
-
|
|
398
|
+
export async function refreshRecoveryNativePreviews(plan, catalogReadScope, signal = plan.runtime.signal) {
|
|
399
|
+
const previews = await readNativeGroups(plan.nativeGroups, (group) => nativeOperation(plan, group.pluginIds, group.platform, true, { ...plan.runtime, signal }, group.command, nativeGroupTargets(group), catalogReadScope), signal);
|
|
400
|
+
for (const [index, group] of plan.nativeGroups.entries()) {
|
|
401
|
+
group.preview = previews[index];
|
|
336
402
|
nativeResults(plan, group, group.preview, false);
|
|
337
403
|
}
|
|
338
404
|
completeReceipt(plan.receipt);
|
|
@@ -350,12 +416,13 @@ function portableResults(plan, prepared) {
|
|
|
350
416
|
const gaps = (prepared.unmet ?? []).filter((gap) => gap.agent === agent);
|
|
351
417
|
if (gaps.length)
|
|
352
418
|
target.componentGaps = gaps;
|
|
419
|
+
const blockingGap = gaps.some((gap) => !isDeliveryCapabilityGap(gap));
|
|
353
420
|
target.content = observations.some((entry) => entry.observation === 'conflict') ? 'conflict'
|
|
354
421
|
: observations.some((entry) => entry.observation === 'unknown') ? 'unknown'
|
|
355
422
|
: observations.some((entry) => entry.observation === 'drifted') ? 'drifted'
|
|
356
423
|
: observations.some((entry) => entry.observation === 'absent') ? 'absent'
|
|
357
|
-
: observations.length || prepared.intentionalEmpty
|
|
358
|
-
if (
|
|
424
|
+
: observations.length || prepared.intentionalEmpty || gaps.length && !blockingGap && !prepared.blockers.length ? 'satisfied' : 'unknown';
|
|
425
|
+
if ((blockingGap || observations.some((entry) => entry.disposition === 'retain')) && target.content !== 'conflict')
|
|
359
426
|
target.content = 'unknown';
|
|
360
427
|
target.observation = target.content === 'satisfied' ? 'verified'
|
|
361
428
|
: target.content === 'absent' ? 'missing' : 'unknown';
|
|
@@ -363,9 +430,15 @@ function portableResults(plan, prepared) {
|
|
|
363
430
|
plan.changes.push(`组件未满足 · ${gap.providerPluginId} · ${gap.componentId ?? gap.id} · ${gap.reasonCode}`
|
|
364
431
|
+ gap.requiredFeatures.map((requirement) => ` · ${requirement.feature}${requirement.values ? `: ${requirement.values.join(', ')}` : ''}`).join(''));
|
|
365
432
|
for (const code of [...prepared.globalBlockers, ...observations.flatMap((entry) => entry.blocker
|
|
366
|
-
&& !(entry.disposition === 'retain' && entry.blocker === '
|
|
433
|
+
&& !(entry.disposition === 'retain' && entry.blocker === 'previousDeploymentRetained') ? [entry.blocker] : [])]) {
|
|
367
434
|
block(target, code, portablePreparationDiagnostic(prepared, diagnostic(code), agent));
|
|
368
435
|
}
|
|
436
|
+
const retained = observations.filter((entry) => entry.disposition === 'retain');
|
|
437
|
+
if (retained.length)
|
|
438
|
+
target.reasons = retained.map((entry) => retainedOutputDiagnostic(entry.providerPluginId, agent, target.scope, entry.physicalPath, `skill.${entry.skill}`));
|
|
439
|
+
const policyNotices = prepared.policyNotices?.filter((notice) => notice.subject?.target === agent);
|
|
440
|
+
if (policyNotices?.length)
|
|
441
|
+
(target.reasons ??= []).push(...policyNotices);
|
|
369
442
|
target.backend = observations.map((entry) => ({ skill: entry.skill, providerPluginId: entry.providerPluginId,
|
|
370
443
|
requiredBy: portableRequiredBy(plan, prepared, entry), observation: entry.observation,
|
|
371
444
|
ownership: entry.ownership, associatedAgents: entry.associatedAgents }));
|
|
@@ -375,16 +448,23 @@ function portableResults(plan, prepared) {
|
|
|
375
448
|
function portableOutcomes(plan, prepared, agent, outcomes, globalBlockers) {
|
|
376
449
|
const target = pair(plan, prepared.options.selector, agent);
|
|
377
450
|
const contentOutcomes = outcomes.filter((entry) => entry.disposition !== 'remove');
|
|
451
|
+
for (const entry of contentOutcomes) {
|
|
452
|
+
if (entry.invocationWarning && entry.disposition === 'write' && entry.observation === 'satisfied'
|
|
453
|
+
&& (entry.execution === 'applied' || entry.execution === 'no-op') && !entry.blockers.length) {
|
|
454
|
+
(target.reasons ??= []).push(entry.invocationWarning);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
378
457
|
const preparedTargets = prepared.targets.filter((entry) => entry.agent === agent);
|
|
379
458
|
const gaps = (prepared.unmet ?? []).filter((gap) => gap.agent === agent);
|
|
380
459
|
if (gaps.length)
|
|
381
460
|
target.componentGaps = gaps;
|
|
382
|
-
const
|
|
461
|
+
const blockingGap = gaps.some((gap) => !isDeliveryCapabilityGap(gap));
|
|
462
|
+
const completeEmpty = prepared.mode === 'deploy' && (prepared.intentionalEmpty || gaps.length > 0 && !blockingGap) && prepared.blockers.length === 0
|
|
383
463
|
&& globalBlockers.length === 0 && preparedTargets.every((entry) => entry.disposition === 'remove')
|
|
384
464
|
&& outcomes.length === preparedTargets.length
|
|
385
465
|
&& outcomes.every((entry) => entry.observation === 'absent' && entry.blockers.length === 0
|
|
386
466
|
&& ['applied', 'no-op'].includes(entry.execution));
|
|
387
|
-
target.execution = (prepared.mode === 'cleanup' ||
|
|
467
|
+
target.execution = (prepared.mode === 'cleanup' || completeEmpty) && outcomes.length === 0 && !globalBlockers.length ? 'no-op' : outcomes.length > 0 && outcomes.every((entry) => entry.execution === 'no-op') ? 'no-op'
|
|
388
468
|
: outcomes.length > 0 && outcomes.every((entry) => ['applied', 'no-op'].includes(entry.execution)) ? 'applied'
|
|
389
469
|
: outcomes.some((entry) => ['applied', 'no-op'].includes(entry.execution)) ? 'partial'
|
|
390
470
|
: outcomes.some((entry) => entry.execution === 'failed') ? 'failed' : 'not-run';
|
|
@@ -403,17 +483,34 @@ function portableOutcomes(plan, prepared, agent, outcomes, globalBlockers) {
|
|
|
403
483
|
target.observation = 'missing';
|
|
404
484
|
target.content = 'absent';
|
|
405
485
|
}
|
|
406
|
-
else if (
|
|
486
|
+
else if (completeEmpty) {
|
|
407
487
|
target.observation = 'verified';
|
|
408
488
|
target.content = 'satisfied';
|
|
409
489
|
}
|
|
410
|
-
if (
|
|
490
|
+
if (prepared.mode === 'deploy') {
|
|
491
|
+
const installed = contentOutcomes.filter((entry) => entry.providerPluginId === target.pluginId
|
|
492
|
+
&& entry.disposition === 'write' && entry.observation === 'satisfied' && !entry.blockers.length);
|
|
493
|
+
if (installed.length || !globalBlockers.length && contentOutcomes.every((entry) => entry.disposition === 'retain' || entry.observation === 'satisfied' || entry.observation === 'absent')) {
|
|
494
|
+
target.installedComponentCount = installed.length;
|
|
495
|
+
if (installed.every((entry) => entry.componentId))
|
|
496
|
+
target.installedComponentIds = installed.map((entry) => entry.componentId);
|
|
497
|
+
}
|
|
498
|
+
if (target.content === 'satisfied' && !blockingGap && !globalBlockers.length && outcomes.every((entry) => !entry.blockers.length)
|
|
499
|
+
&& (target.execution === 'applied' || target.execution === 'no-op')) {
|
|
500
|
+
if (installed.length)
|
|
501
|
+
target.satisfaction = 'installed';
|
|
502
|
+
else if (gaps.some((gap) => gap.providerPluginId === target.pluginId))
|
|
503
|
+
target.satisfaction = 'not-applicable';
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
if (blockingGap || contentOutcomes.some((entry) => entry.disposition === 'retain')) {
|
|
411
507
|
if (target.execution === 'applied' || target.execution === 'no-op')
|
|
412
508
|
target.execution = 'partial';
|
|
413
509
|
if (target.content !== 'conflict')
|
|
414
510
|
target.content = 'unknown';
|
|
415
511
|
target.observation = 'unknown';
|
|
416
|
-
|
|
512
|
+
if (blockingGap)
|
|
513
|
+
block(target, 'portableComponentsUnmet');
|
|
417
514
|
}
|
|
418
515
|
target.backend = outcomes.map((entry) => ({ skill: entry.skill, providerPluginId: entry.providerPluginId,
|
|
419
516
|
requiredBy: portableRequiredBy(plan, prepared, entry), observation: entry.observation,
|
|
@@ -421,20 +518,31 @@ function portableOutcomes(plan, prepared, agent, outcomes, globalBlockers) {
|
|
|
421
518
|
execution: entry.execution, blockers: entry.blockers }));
|
|
422
519
|
for (const code of [...globalBlockers, ...outcomes.flatMap((entry) => entry.blockers)])
|
|
423
520
|
block(target, code);
|
|
424
|
-
target.recoveryActions = portableRecoveryActions(plan, target.pluginId, outcomes.filter((entry) =>
|
|
521
|
+
target.recoveryActions = portableRecoveryActions(plan, target.pluginId, outcomes.filter((entry) => entry.observation === 'conflict' || entry.observation === 'unknown' && !entry.blockers.includes('operationReviewStale')));
|
|
522
|
+
if (globalBlockers.includes('operationReviewStale') && prepared.mode !== 'cleanup') {
|
|
523
|
+
target.recoveryActions.push(`aw plugin sync ${target.pluginId} --context ${target.scope} --target ${agent}`);
|
|
524
|
+
}
|
|
425
525
|
}
|
|
426
526
|
function portablePluginClosure(plan, prepared) {
|
|
427
527
|
const { sourceId, pluginName } = parsePluginId(prepared.options.selector);
|
|
428
528
|
return resolvePluginMetaDependencyClosure(plan.demand.plugins.filter((plugin) => plugin.sourceId === sourceId), [pluginName])
|
|
429
529
|
.filter((plugin) => !prepared.options.excludedPluginIds?.includes(plugin.pluginId));
|
|
430
530
|
}
|
|
531
|
+
function isHealthyPortableProvider(group) {
|
|
532
|
+
return !group.blockers.length && group.unmet.every(isDeliveryCapabilityGap)
|
|
533
|
+
&& (group.intentionalEmpty || group.unmet.length > 0 || group.targets.length > 0)
|
|
534
|
+
&& group.targets.every((target) => target.disposition === 'write' && target.ownership === 'aw'
|
|
535
|
+
&& target.observation === 'satisfied' && target.installedDigest === target.expectedDigest);
|
|
536
|
+
}
|
|
431
537
|
function preparePortablePreApplyAuthorization(plan) {
|
|
432
538
|
if (plan.command === 'cleanup' || plan.command === 'uninstall')
|
|
433
539
|
return;
|
|
434
540
|
const authorization = new Map();
|
|
541
|
+
const verifiedProviders = new Set(plan.portableGroups.filter((group) => plan.options.inheritedPortableProviderIds?.includes(group.options.selector) && isHealthyPortableProvider(group))
|
|
542
|
+
.map((group) => group.options.selector));
|
|
435
543
|
for (const prepared of plan.portableGroups) {
|
|
436
544
|
for (const plugin of portablePluginClosure(plan, prepared)) {
|
|
437
|
-
if (!plugin.manifest.scripts?.preApply)
|
|
545
|
+
if (!plugin.manifest.scripts?.preApply || verifiedProviders.has(plugin.pluginId))
|
|
438
546
|
continue;
|
|
439
547
|
for (const platform of prepared.options.agents) {
|
|
440
548
|
if (pair(plan, prepared.options.selector, platform)?.blockers.length)
|
|
@@ -469,6 +577,7 @@ async function executePreApplyAuthorization(plan, required, runtime) {
|
|
|
469
577
|
return 'preApplyAuthorizationRequired';
|
|
470
578
|
const cache = runtime.preApplyExecutionCache ??= new Map();
|
|
471
579
|
for (const target of required) {
|
|
580
|
+
runtime.signal?.throwIfAborted();
|
|
472
581
|
const plugin = plan.demand.plugins.find((entry) => entry.pluginId === target.pluginId);
|
|
473
582
|
if (!plugin || plugin.sourceIdentity !== target.sourceIdentity)
|
|
474
583
|
return 'sourceUnavailable';
|
|
@@ -489,9 +598,18 @@ async function executePreApplyAuthorization(plan, required, runtime) {
|
|
|
489
598
|
await execution;
|
|
490
599
|
}
|
|
491
600
|
catch (error) {
|
|
492
|
-
runtime.signal
|
|
493
|
-
if (
|
|
601
|
+
const interrupted = recoveryInterruptionCode(error, runtime.signal);
|
|
602
|
+
if (interrupted) {
|
|
603
|
+
const affected = pair(plan, target.pluginId, target.platform);
|
|
604
|
+
if (affected) {
|
|
605
|
+
affected.execution = 'partial';
|
|
606
|
+
affected.observation = 'unknown';
|
|
607
|
+
affected.content = 'unknown';
|
|
608
|
+
block(affected, interrupted);
|
|
609
|
+
}
|
|
610
|
+
plan.receipt.outputsMayHaveChanged = true;
|
|
494
611
|
throw error;
|
|
612
|
+
}
|
|
495
613
|
const operationDiagnostic = readSafeOperationError(error);
|
|
496
614
|
const affected = pair(plan, target.pluginId, target.platform);
|
|
497
615
|
if (affected) {
|
|
@@ -542,8 +660,7 @@ export async function executeRecoveryPreApply(plan, pluginId, agent, runtime) {
|
|
|
542
660
|
return executePreApplyAuthorization(plan, authorization.preApplyAuthorization, runtime);
|
|
543
661
|
}
|
|
544
662
|
catch (error) {
|
|
545
|
-
runtime.signal
|
|
546
|
-
if (error instanceof Error && error.name === 'AbortError')
|
|
663
|
+
if (recoveryInterruptionCode(error, runtime.signal))
|
|
547
664
|
throw error;
|
|
548
665
|
return readSafeOperationError(error)?.code ?? errorCode(error, 'nativePreparationFailed');
|
|
549
666
|
}
|
|
@@ -555,7 +672,7 @@ export async function executeRecoveryPreApply(plan, pluginId, agent, runtime) {
|
|
|
555
672
|
return executePortablePreApply(plan, prepared, agent, runtime);
|
|
556
673
|
}
|
|
557
674
|
}
|
|
558
|
-
async function checkFootprints(plan) {
|
|
675
|
+
export async function checkFootprints(plan) {
|
|
559
676
|
const footprints = [];
|
|
560
677
|
for (const [nativeGroup, group] of plan.nativeGroups.entries()) {
|
|
561
678
|
const actions = group.preview.operationPlan?.actions.filter((action) => (action.kind === 'writeOwnedArtifact' || action.kind === 'removeOwnedArtifact')
|
|
@@ -566,7 +683,7 @@ async function checkFootprints(plan) {
|
|
|
566
683
|
continue;
|
|
567
684
|
const consumers = group.preview.dependencyPlan?.targets.filter((target) => target.pluginId === action.pluginId)
|
|
568
685
|
.flatMap((target) => target.requiredBy ?? []) ?? [];
|
|
569
|
-
footprints.push({ path:
|
|
686
|
+
footprints.push({ path: action.path,
|
|
570
687
|
pluginIds: group.pluginIds.filter((id) => id === action.pluginId || consumers.includes(id)),
|
|
571
688
|
agent: agentForPlatform(action.platform), identity: `native:${action.platform}:${action.pluginId}`,
|
|
572
689
|
sharedNative: 'shared' in action && action.shared,
|
|
@@ -578,17 +695,23 @@ async function checkFootprints(plan) {
|
|
|
578
695
|
for (const prepared of plan.portableGroups) {
|
|
579
696
|
for (const target of prepared.targets)
|
|
580
697
|
footprints.push({
|
|
581
|
-
path:
|
|
698
|
+
path: target.physicalPath,
|
|
582
699
|
pluginIds: [prepared.options.selector], agent: target.agent,
|
|
583
|
-
identity:
|
|
700
|
+
identity: JSON.stringify(['agent-skills', prepared.logicalIdentity, target.providerPluginId, target.expectedDigest,
|
|
701
|
+
target.configDigest, target.disposition]),
|
|
584
702
|
});
|
|
585
703
|
}
|
|
704
|
+
const paths = [...new Set(footprints.map((entry) => entry.path))];
|
|
705
|
+
const canonical = new Map(await mapInstallReads(paths, async (value) => [value, await canonicalizePathThroughExistingAncestor(value)], { signal: plan.runtime.signal }));
|
|
706
|
+
for (const item of footprints)
|
|
707
|
+
item.path = canonical.get(item.path);
|
|
586
708
|
for (let index = 0; index < footprints.length; index += 1) {
|
|
587
709
|
const left = footprints[index];
|
|
588
710
|
for (const right of footprints.slice(index + 1)) {
|
|
589
|
-
|
|
711
|
+
const overlap = left.path === right.path || left.path.startsWith(right.path + path.sep) || right.path.startsWith(left.path + path.sep);
|
|
712
|
+
if (!overlap || left.identity === right.identity
|
|
590
713
|
|| (left.nativeGroup !== undefined && left.nativeGroup === right.nativeGroup)
|
|
591
|
-
|| (left.sharedMarketplaceSource !== undefined
|
|
714
|
+
|| (left.sharedMarketplaceSource !== undefined && left.agent === right.agent
|
|
592
715
|
&& left.sharedMarketplaceSource === right.sharedMarketplaceSource)
|
|
593
716
|
|| (left.sharedNative && right.sharedNative && left.agent === right.agent))
|
|
594
717
|
continue;
|
|
@@ -606,7 +729,7 @@ async function checkFootprints(plan) {
|
|
|
606
729
|
plan.changes.push(`${prepared.options.selector}:AW 写入所选 Agent 的 owned Skill 目录;准备目录 ${layout.generationRoot}。`);
|
|
607
730
|
}
|
|
608
731
|
}
|
|
609
|
-
export async function prepareScopedRecovery(command, selectors, options, runtime = {}, { catalogReadScope, nativeObservationBatch } = {}) {
|
|
732
|
+
export async function prepareScopedRecovery(command, selectors, options, runtime = {}, { catalogReadScope, nativeObservationBatch, portableGenerations = new Map() } = {}) {
|
|
610
733
|
runtime = { ...runtime, preparedArtifactRenderResults: runtime.preparedArtifactRenderResults ?? new Map() };
|
|
611
734
|
options.signal?.throwIfAborted();
|
|
612
735
|
const context = await createScopeContext({ scope: options.scope, cwd: options.cwd, env: options.env });
|
|
@@ -649,8 +772,7 @@ export async function prepareScopedRecovery(command, selectors, options, runtime
|
|
|
649
772
|
configDigest: config.digest, impact, impactDigest: calculateCatalogSourceImpactDigest(impact) });
|
|
650
773
|
}
|
|
651
774
|
catch (error) {
|
|
652
|
-
options.signal
|
|
653
|
-
if (error instanceof Error && error.name === 'AbortError')
|
|
775
|
+
if (recoveryInterruptionCode(error, options.signal))
|
|
654
776
|
throw error;
|
|
655
777
|
const code = errorCode(error, 'catalogGenerationRefreshFailed');
|
|
656
778
|
refreshFailures.set(sourceId, code.startsWith('catalog') ? code : 'catalogGenerationRefreshFailed');
|
|
@@ -769,15 +891,25 @@ export async function prepareScopedRecovery(command, selectors, options, runtime
|
|
|
769
891
|
group.targets.push({ pluginId: target.pluginId, platform: target.delivery.platform });
|
|
770
892
|
groups.set(key, group);
|
|
771
893
|
}
|
|
772
|
-
const preparationRuntime = { ...runtime, signal: options.signal,
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
continue;
|
|
894
|
+
const preparationRuntime = { ...runtime, signal: options.signal, nativeObservationBatch };
|
|
895
|
+
const pendingGroups = [...groups.values()].map((pending) => ({
|
|
896
|
+
...nativeTargetSelection(pending.targets), command: pending.command,
|
|
897
|
+
}));
|
|
898
|
+
const previews = await readNativeGroups(pendingGroups, async (group) => {
|
|
778
899
|
try {
|
|
779
900
|
const preview = await nativeOperation(plan, group.pluginIds, group.platform, true, preparationRuntime, group.command, group.targets, catalogReadScope);
|
|
780
|
-
|
|
901
|
+
return { ok: true, preview };
|
|
902
|
+
}
|
|
903
|
+
catch (error) {
|
|
904
|
+
if (recoveryInterruptionCode(error, options.signal))
|
|
905
|
+
throw error;
|
|
906
|
+
return { ok: false, error };
|
|
907
|
+
}
|
|
908
|
+
}, options.signal);
|
|
909
|
+
for (const [index, group] of pendingGroups.entries()) {
|
|
910
|
+
const result = previews[index];
|
|
911
|
+
if (result.ok) {
|
|
912
|
+
const { preview } = result;
|
|
781
913
|
const nativeGroup = { ...group, preview };
|
|
782
914
|
plan.nativeGroups.push(nativeGroup);
|
|
783
915
|
nativeResults(plan, nativeGroup, preview, false);
|
|
@@ -799,10 +931,8 @@ export async function prepareScopedRecovery(command, selectors, options, runtime
|
|
|
799
931
|
}
|
|
800
932
|
plan.warnings.push(...preview.warnings);
|
|
801
933
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
if (error instanceof Error && error.name === 'AbortError')
|
|
805
|
-
throw error;
|
|
934
|
+
else {
|
|
935
|
+
const { error } = result;
|
|
806
936
|
if (error instanceof CatalogSourceInventoryIncompleteError) {
|
|
807
937
|
receipt.blockers.push(...error.inventory.errors.map(inventoryRecoveryDiagnostic));
|
|
808
938
|
}
|
|
@@ -811,26 +941,32 @@ export async function prepareScopedRecovery(command, selectors, options, runtime
|
|
|
811
941
|
}
|
|
812
942
|
}
|
|
813
943
|
}
|
|
814
|
-
|
|
944
|
+
const portableReads = receipt.requestedRoots.flatMap((pluginId) => {
|
|
815
945
|
const agents = receipt.targetResults.filter((target) => target.pluginId === pluginId
|
|
816
946
|
&& !target.blockers.length && target.delivery?.kind === 'agent-skills').map((target) => target.agent).filter(isPortableAgent);
|
|
817
|
-
|
|
818
|
-
|
|
947
|
+
return agents.length ? [{ pluginId, agents }] : [];
|
|
948
|
+
});
|
|
949
|
+
const preparedGroups = await mapInstallReads(portableReads, async ({ pluginId, agents }) => {
|
|
819
950
|
try {
|
|
820
951
|
const prepared = command === 'cleanup' || command === 'uninstall'
|
|
821
952
|
? await preparePortableCleanup({ scope: options.scope, context, selector: pluginId, agents, force: options.force, signal: options.signal })
|
|
822
953
|
: await preparePortableRecovery({ scope: options.scope, context, selector: pluginId, agents,
|
|
823
954
|
env: options.env, cliVersion: options.cliVersion, signal: options.signal,
|
|
824
|
-
catalogOperationContext: demand.catalogOperationContext, excludedPluginIds: options.excludedPluginIds }, catalogReadScope);
|
|
825
|
-
|
|
955
|
+
catalogOperationContext: demand.catalogOperationContext, excludedPluginIds: options.excludedPluginIds }, catalogReadScope, portableGenerations);
|
|
956
|
+
return { ok: true, prepared };
|
|
826
957
|
}
|
|
827
958
|
catch (error) {
|
|
828
|
-
options.signal
|
|
829
|
-
if (error instanceof Error && error.name === 'AbortError')
|
|
959
|
+
if (recoveryInterruptionCode(error, options.signal))
|
|
830
960
|
throw error;
|
|
831
|
-
|
|
832
|
-
block(pair(plan, pluginId, agent), errorCode(error, 'portablePreparationFailed'));
|
|
961
|
+
return { ok: false, agents, pluginId, code: errorCode(error, 'portablePreparationFailed') };
|
|
833
962
|
}
|
|
963
|
+
}, { signal: options.signal });
|
|
964
|
+
for (const result of preparedGroups) {
|
|
965
|
+
if (result.ok)
|
|
966
|
+
plan.portableGroups.push(result.prepared);
|
|
967
|
+
else
|
|
968
|
+
for (const agent of result.agents)
|
|
969
|
+
block(pair(plan, result.pluginId, agent), result.code);
|
|
834
970
|
}
|
|
835
971
|
for (const prepared of plan.portableGroups)
|
|
836
972
|
portableResults(plan, prepared);
|
|
@@ -839,31 +975,26 @@ export async function prepareScopedRecovery(command, selectors, options, runtime
|
|
|
839
975
|
// Complete scope demand protects copies contributed by unselected roots and their dependencies.
|
|
840
976
|
const desiredAgents = new Set([...receipt.selection.agents,
|
|
841
977
|
...(demand.preferences.state === 'valid' ? demand.preferences.value.targets : [])]);
|
|
842
|
-
const
|
|
843
|
-
for (const root of demand.roots ?? []) {
|
|
978
|
+
const protection = await mapInstallReads(demand.roots ?? [], async (root) => {
|
|
844
979
|
const portableAgents = [...desiredAgents].filter(isPortableAgent).filter((agent) => root.plugin
|
|
845
980
|
&& resolveDelivery(root.plugin.manifest, agent, options.scope)?.kind === 'agent-skills');
|
|
846
|
-
if (!portableAgents.length)
|
|
847
|
-
|
|
981
|
+
if (!portableAgents.length || plan.portableGroups.some((group) => group.options.selector === root.pluginId
|
|
982
|
+
&& portableAgents.every((agent) => group.options.agents.includes(agent))))
|
|
983
|
+
return;
|
|
848
984
|
try {
|
|
849
|
-
const prepared =
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
if (!prepared.globalBlockers.length) {
|
|
855
|
-
retainedPortableTargets.push(...prepared.targets.filter((target) => !target.blocker && ['satisfied', 'drifted'].includes(target.observation)));
|
|
856
|
-
if (!plan.portableGroups.includes(prepared))
|
|
857
|
-
plan.portableProtectionGroups.push(prepared);
|
|
858
|
-
}
|
|
985
|
+
const prepared = await preparePortableRecovery({ scope: options.scope, context, selector: root.pluginId,
|
|
986
|
+
env: options.env, agents: portableAgents, cliVersion: options.cliVersion, signal: options.signal,
|
|
987
|
+
catalogOperationContext: demand.catalogOperationContext, excludedPluginIds: options.excludedPluginIds }, catalogReadScope, portableGenerations);
|
|
988
|
+
if (!prepared.globalBlockers.length)
|
|
989
|
+
return prepared;
|
|
859
990
|
}
|
|
860
991
|
catch (error) {
|
|
861
|
-
options.signal
|
|
862
|
-
if (error instanceof Error && error.name === 'AbortError')
|
|
992
|
+
if (recoveryInterruptionCode(error, options.signal))
|
|
863
993
|
throw error;
|
|
864
994
|
// Missing current Portable evidence cannot protect historical residue.
|
|
865
995
|
}
|
|
866
|
-
}
|
|
996
|
+
}, { signal: options.signal });
|
|
997
|
+
plan.portableProtectionGroups = protection.filter((prepared) => prepared !== undefined);
|
|
867
998
|
}
|
|
868
999
|
options.signal?.throwIfAborted();
|
|
869
1000
|
await checkFootprints(plan);
|
|
@@ -959,40 +1090,220 @@ function portablePrewriteBinding(context, sourceId) {
|
|
|
959
1090
|
return JSON.stringify([context.generationSetDigest,
|
|
960
1091
|
createCatalogPreparationStoreKey({ ...generation, requestedRef: source.requestedRef })]);
|
|
961
1092
|
}
|
|
962
|
-
async function recheckPortableRecovery(plan) {
|
|
1093
|
+
async function recheckPortableRecovery(plan, groups = plan.portableGroups, progress) {
|
|
1094
|
+
const executable = groups.filter(({ options }) => !options.agents.every((agent) => pair(plan, options.selector, agent)?.blockers.length));
|
|
1095
|
+
const providers = new Set(executable.flatMap((group) => plan.options.portableProviderChecks?.get(group.options.selector) ?? []));
|
|
963
1096
|
const inspections = [
|
|
964
|
-
...
|
|
1097
|
+
...executable,
|
|
965
1098
|
...plan.portableProtectionGroups,
|
|
1099
|
+
...providers,
|
|
966
1100
|
];
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
const
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
&&
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1101
|
+
if (!inspections.length)
|
|
1102
|
+
return;
|
|
1103
|
+
const readScope = new CatalogPreparationReadScope({ env: plan.context.env, signal: plan.runtime.signal });
|
|
1104
|
+
const active = new Map();
|
|
1105
|
+
const problems = await mapInstallReads(inspections, async (prepared) => {
|
|
1106
|
+
let current;
|
|
1107
|
+
const sourceId = parsePluginId(prepared.options.selector).sourceId;
|
|
1108
|
+
const reviewed = prepared.options.catalogOperationContext;
|
|
1109
|
+
if (sourceId && reviewed && prepared.mode === 'deploy') {
|
|
1110
|
+
try {
|
|
1111
|
+
let pending = active.get(sourceId);
|
|
1112
|
+
if (!pending) {
|
|
1113
|
+
pending = readScope.resolve({ sourceIds: [sourceId] }, true);
|
|
1114
|
+
active.set(sourceId, pending);
|
|
1115
|
+
}
|
|
1116
|
+
current = await pending;
|
|
1117
|
+
const original = selectCatalogOperationContext(reviewed, [sourceId]);
|
|
1118
|
+
if (portablePrewriteBinding(current, sourceId) !== portablePrewriteBinding(original, sourceId)) {
|
|
1119
|
+
return diagnostic('operationReviewStale');
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
catch (error) {
|
|
1123
|
+
if (recoveryInterruptionCode(error, plan.runtime.signal))
|
|
1124
|
+
throw error;
|
|
1125
|
+
return { ...diagnostic('operationReviewStale'), subject: { sourceId },
|
|
1126
|
+
detail: { reasonCode: error instanceof CatalogGenerationError ? error.code : 'catalogReadFailed' } };
|
|
1127
|
+
}
|
|
981
1128
|
}
|
|
982
|
-
|
|
983
|
-
|
|
1129
|
+
const checked = await inspectPortableRecovery({ ...prepared.options, catalogOperationContext: current,
|
|
1130
|
+
signal: plan.runtime.signal }, readScope);
|
|
1131
|
+
// The provider ran first. Its original missing state is never sufficient for a consumer.
|
|
1132
|
+
if (providers.has(prepared) && !isHealthyPortableProvider(checked)
|
|
1133
|
+
|| !await portableReviewMatches(prepared, checked, progress?.completed))
|
|
1134
|
+
return diagnostic('operationReviewStale');
|
|
1135
|
+
}, { signal: plan.runtime.signal });
|
|
1136
|
+
return problems.find((problem) => problem !== undefined);
|
|
1137
|
+
}
|
|
1138
|
+
async function executeNativeGroup(plan, group, nativeRuntime) {
|
|
1139
|
+
const { receipt } = plan;
|
|
1140
|
+
const running = new Set();
|
|
1141
|
+
try {
|
|
1142
|
+
const result = await nativeOperation(plan, group.pluginIds, group.platform, false, { ...nativeRuntime, onInstallTargetState(identity, state) {
|
|
1143
|
+
const target = identity.scope === plan.options.scope && identity.pluginId
|
|
1144
|
+
? pair(plan, identity.pluginId, identity.platform) : undefined;
|
|
1145
|
+
if (target && state === 'running')
|
|
1146
|
+
running.add(target);
|
|
1147
|
+
else if (target)
|
|
1148
|
+
running.delete(target);
|
|
1149
|
+
nativeRuntime.onInstallTargetState?.(identity, state);
|
|
1150
|
+
}, expectedPlanFingerprint: group.preview.operationPlan?.planFingerprint }, group.command, nativeGroupTargets(group));
|
|
1151
|
+
receipt.outputsMayHaveChanged ||= result.rebuildResults.some((result) => result.actions.some((action) => action.name === 'stale.cleanup' || action.name === 'native.write' || action.name === 'artifacts.write'
|
|
1152
|
+
|| action.name === 'recovery.cleanup' || action.name === 'cleanup.owned'))
|
|
1153
|
+
|| ((result.commandResults?.length ?? 0) > 0
|
|
1154
|
+
&& result.operationPlan?.actions.some((action) => action.kind === 'syncManagedCommandPackage') === true);
|
|
1155
|
+
nativeResults(plan, group, result, true);
|
|
1156
|
+
}
|
|
1157
|
+
catch (error) {
|
|
1158
|
+
if (error instanceof RebuildInterruptedError) {
|
|
1159
|
+
const recorded = error.result;
|
|
1160
|
+
const targets = nativeGroupTargets(group).filter(({ pluginId, platform }) => recorded.targetResults.some((entry) => entry.target.pluginId === pluginId && entry.target.platform === platform));
|
|
1161
|
+
nativeResults(plan, { ...group, targets }, recorded, true);
|
|
1162
|
+
receipt.outputsMayHaveChanged ||= recorded.rebuildResults.some((entry) => entry.actions.length > 0 || entry.deploymentReceipts?.some((deployment) => deployment.effects.some((effect) => effect.mutation !== 'none')))
|
|
1163
|
+
|| recorded.commandResults?.some((command) => command.state === 'completed') === true;
|
|
1164
|
+
}
|
|
1165
|
+
const interruption = recoveryInterruptionCode(error, nativeRuntime.signal);
|
|
1166
|
+
if (interruption) {
|
|
1167
|
+
for (const target of running) {
|
|
1168
|
+
target.execution = 'partial';
|
|
1169
|
+
target.observation = 'unknown';
|
|
1170
|
+
target.content = 'unknown';
|
|
1171
|
+
block(target, interruption);
|
|
1172
|
+
receipt.outputsMayHaveChanged = true;
|
|
1173
|
+
}
|
|
1174
|
+
throw error;
|
|
1175
|
+
}
|
|
1176
|
+
const code = errorCode(error, 'nativeRecoveryFailed');
|
|
1177
|
+
receipt.outputsMayHaveChanged ||= code !== 'preApplyAuthorizationRequired';
|
|
1178
|
+
for (const { pluginId, platform } of nativeGroupTargets(group)) {
|
|
1179
|
+
const target = pair(plan, pluginId, agentForPlatform(platform));
|
|
1180
|
+
target.execution = 'failed';
|
|
1181
|
+
block(target, code);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
async function executePortableGroups(plan, groups, nativeRuntime, progress, jointChecked = false) {
|
|
1186
|
+
const { receipt } = plan;
|
|
1187
|
+
for (const prepared of groups) {
|
|
1188
|
+
let started = false;
|
|
1189
|
+
const onStart = () => {
|
|
1190
|
+
if (started)
|
|
1191
|
+
return;
|
|
1192
|
+
started = true;
|
|
1193
|
+
try {
|
|
1194
|
+
nativeRuntime.onInstallTargetState?.({ pluginId: prepared.options.selector,
|
|
1195
|
+
platform: 'generic', scope: plan.options.scope }, 'running');
|
|
1196
|
+
}
|
|
1197
|
+
catch { /* Display callbacks don't control execution. */ }
|
|
1198
|
+
};
|
|
1199
|
+
const providers = plan.options.portableProviderChecks?.get(prepared.options.selector);
|
|
1200
|
+
const checkPrewrite = jointChecked || providers?.length ? () => recheckPortableRecovery(plan, [prepared], progress) : undefined;
|
|
1201
|
+
const agents = [];
|
|
1202
|
+
for (const agent of prepared.options.agents) {
|
|
1203
|
+
if (pair(plan, prepared.options.selector, agent).blockers.length)
|
|
1204
|
+
continue;
|
|
1205
|
+
const outcomes = prepared.targets.filter((entry) => entry.agent === agent).map((entry) => {
|
|
1206
|
+
const failed = progress.failed.find((failure) => failure.logicalIdentity === prepared.logicalIdentity
|
|
1207
|
+
&& failure.outcome.physicalPath === entry.physicalPath && failure.outcome.expectedDigest === entry.expectedDigest
|
|
1208
|
+
&& failure.outcome.providerPluginId === entry.providerPluginId);
|
|
1209
|
+
return failed ? { ...failed.outcome, agent } : { ...entry, execution: 'not-run', blockers: [] };
|
|
1210
|
+
});
|
|
1211
|
+
if (outcomes.some((entry) => entry.execution === 'failed')) {
|
|
1212
|
+
portableOutcomes(plan, prepared, agent, outcomes, []);
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
const hasScript = plan.preApplyAuthorization?.some((target) => target.platform === agent
|
|
1216
|
+
&& portablePluginClosure(plan, prepared).some((plugin) => plugin.pluginId === target.pluginId));
|
|
1217
|
+
const preApply = async () => {
|
|
1218
|
+
onStart();
|
|
1219
|
+
const stale = await checkPrewrite?.();
|
|
1220
|
+
if (stale) {
|
|
1221
|
+
receipt.blockers.push(stale);
|
|
1222
|
+
return stale.code;
|
|
1223
|
+
}
|
|
1224
|
+
return executePortablePreApply(plan, prepared, agent, nativeRuntime);
|
|
1225
|
+
};
|
|
1226
|
+
const preApplyFailure = !hasScript ? undefined : nativeRuntime.installAdmission
|
|
1227
|
+
? await nativeRuntime.installAdmission.run([{ kind: 'exclusive' }], preApply, nativeRuntime.signal) : await preApply();
|
|
1228
|
+
if (preApplyFailure) {
|
|
1229
|
+
const target = pair(plan, prepared.options.selector, agent);
|
|
1230
|
+
portableOutcomes(plan, prepared, agent, prepared.targets.filter((entry) => entry.agent === agent)
|
|
1231
|
+
.map((entry) => unobservedPortableTarget(entry, preApplyFailure)), [preApplyFailure]);
|
|
1232
|
+
if (preApplyFailure !== 'operationReviewStale')
|
|
1233
|
+
target.execution = 'failed';
|
|
1234
|
+
target.recoveryActions = [`aw plugin sync ${target.pluginId} --context ${target.scope} --target ${agent}`
|
|
1235
|
+
+ (preApplyFailure === 'operationReviewStale' ? '' : ' --yes')];
|
|
1236
|
+
continue;
|
|
1237
|
+
}
|
|
1238
|
+
agents.push(agent);
|
|
1239
|
+
}
|
|
1240
|
+
if (!agents.length)
|
|
1241
|
+
continue;
|
|
1242
|
+
let interruption;
|
|
1243
|
+
const result = await executePortableRecovery({ prepared, token: nativeRuntime.awHomeMutationToken, authorizeUpdate: plan.options.yes,
|
|
1244
|
+
action: plan.command === 'install' ? 'sync' : plan.command, force: plan.options.force,
|
|
1245
|
+
targets: prepared.targets.filter((target) => agents.includes(target.agent)).map(({ skill, agent }) => ({ skill, agent })),
|
|
1246
|
+
progress, checkPrewrite, readProviders: providers, onStart, admission: nativeRuntime.installAdmission, signal: nativeRuntime.signal }).catch((error) => {
|
|
1247
|
+
if (!(error instanceof PortableInterruptedError))
|
|
984
1248
|
throw error;
|
|
985
|
-
|
|
986
|
-
|
|
1249
|
+
interruption = error;
|
|
1250
|
+
return error.result;
|
|
1251
|
+
});
|
|
1252
|
+
if (result.reviewProblem)
|
|
1253
|
+
receipt.blockers.push(result.reviewProblem);
|
|
1254
|
+
receipt.outputsMayHaveChanged ||= result.outputsMayHaveChanged;
|
|
1255
|
+
for (const agent of agents) {
|
|
1256
|
+
portableOutcomes(plan, prepared, agent, result.targets.filter((entry) => entry.agent === agent), result.globalBlockers);
|
|
1257
|
+
if (interruption && result.outputsMayHaveChanged) {
|
|
1258
|
+
const target = pair(plan, prepared.options.selector, agent);
|
|
1259
|
+
if (target.execution === 'failed')
|
|
1260
|
+
target.execution = 'partial';
|
|
1261
|
+
}
|
|
987
1262
|
}
|
|
988
|
-
if (
|
|
989
|
-
|
|
1263
|
+
if (interruption)
|
|
1264
|
+
throw interruption.cause;
|
|
990
1265
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1266
|
+
}
|
|
1267
|
+
/** The joint coordinator holds the write lock and has checked this complete child against Review. */
|
|
1268
|
+
export async function executeCheckedScopedInstall(child, execution) {
|
|
1269
|
+
if (!execution.runtime.awHomeMutationToken || child.command !== 'sync' && child.command !== 'reinstall') {
|
|
1270
|
+
throw new Error('checkedScopedInstallUnavailable');
|
|
1271
|
+
}
|
|
1272
|
+
const selected = (pluginId) => !execution.pluginIds || execution.pluginIds.includes(pluginId);
|
|
1273
|
+
const receipt = structuredClone({ ...child.receipt,
|
|
1274
|
+
targetResults: child.receipt.targetResults.filter((target) => selected(target.pluginId)),
|
|
1275
|
+
requestedRoots: child.receipt.requestedRoots.filter(selected),
|
|
1276
|
+
});
|
|
1277
|
+
const plan = { ...child, receipt, runtime: { ...child.runtime, ...execution.runtime }, options: { ...child.options, yes: execution.yes ?? child.options.yes } };
|
|
1278
|
+
if (receipt.nativeToolChanges?.length && plan.options.yes !== true) {
|
|
1279
|
+
receipt.blockers.push(diagnostic('nativeToolAuthorizationRequired'));
|
|
1280
|
+
return completeReceipt(receipt);
|
|
1281
|
+
}
|
|
1282
|
+
if (plan.blockExecution)
|
|
1283
|
+
return completeReceipt(receipt);
|
|
1284
|
+
const runtime = plan.runtime;
|
|
1285
|
+
try {
|
|
1286
|
+
for (const group of plan.nativeGroups) {
|
|
1287
|
+
const targets = nativeGroupTargets(group);
|
|
1288
|
+
const blocked = new Map();
|
|
1289
|
+
for (const { pluginId, platform } of targets) {
|
|
1290
|
+
const code = pair(plan, pluginId, platform)?.blockers[0]?.code;
|
|
1291
|
+
if (code)
|
|
1292
|
+
blocked.set([pluginId, platform, plan.options.scope].join('\0'), code);
|
|
1293
|
+
}
|
|
1294
|
+
if (blocked.size === targets.length)
|
|
1295
|
+
continue;
|
|
1296
|
+
await executeNativeGroup(plan, group, { ...runtime, nativeInstallBlockers: blocked });
|
|
1297
|
+
}
|
|
1298
|
+
await executePortableGroups(plan, plan.portableGroups.filter((group) => selected(group.options.selector)), runtime, execution.portableProgress, true);
|
|
1299
|
+
return completeReceipt(receipt);
|
|
1300
|
+
}
|
|
1301
|
+
catch (error) {
|
|
1302
|
+
const code = recoveryInterruptionCode(error, runtime.signal);
|
|
1303
|
+
if (!code)
|
|
1304
|
+
throw error;
|
|
1305
|
+
receipt.blockers.push(diagnostic(code));
|
|
1306
|
+
throw new RecoveryInterruptedError(completeReceipt(receipt), error);
|
|
996
1307
|
}
|
|
997
1308
|
}
|
|
998
1309
|
export async function executeScopedRecovery(plan, execution = {}) {
|
|
@@ -1026,8 +1337,11 @@ export async function executeScopedRecovery(plan, execution = {}) {
|
|
|
1026
1337
|
}
|
|
1027
1338
|
return await withAwHomeMutationLock({ env: plan.options.env, token: plan.runtime.awHomeMutationToken,
|
|
1028
1339
|
action: async (token) => {
|
|
1029
|
-
const actualIntent = await
|
|
1030
|
-
|
|
1340
|
+
const [actualIntent, current] = await Promise.all([
|
|
1341
|
+
observeIntent(plan.options),
|
|
1342
|
+
readDemand({ ...plan.options, preferences: undefined,
|
|
1343
|
+
...(plan.declaration || plan.options.demandOverride ? { intent: plan.demand.intent } : {}) }),
|
|
1344
|
+
]);
|
|
1031
1345
|
if (intentEvidence(actualIntent) !== plan.originalIntent || preferenceEvidence(current) !== plan.preferencesEvidence
|
|
1032
1346
|
|| current.catalogOperationContext?.generationSetDigest !== plan.demand.catalogOperationContext?.generationSetDigest) {
|
|
1033
1347
|
receipt.blockers.push(diagnostic('operationReviewStale'));
|
|
@@ -1047,23 +1361,26 @@ export async function executeScopedRecovery(plan, execution = {}) {
|
|
|
1047
1361
|
...(session ? { codexObservationSession: session } : {}) };
|
|
1048
1362
|
try {
|
|
1049
1363
|
// Freeze every backend before the first declaration or output write.
|
|
1050
|
-
const
|
|
1051
|
-
for (const group of plan.nativeGroups) {
|
|
1364
|
+
const recheckedGroups = await readNativeGroups(plan.nativeGroups, async (group) => {
|
|
1052
1365
|
const targets = nativeGroupTargets(group);
|
|
1053
1366
|
const executable = targets.filter(({ pluginId, platform }) => !pair(plan, pluginId, agentForPlatform(platform)).blockers.length);
|
|
1054
|
-
if (executable.length
|
|
1055
|
-
|
|
1367
|
+
if (!executable.length)
|
|
1368
|
+
return;
|
|
1056
1369
|
const checked = await nativeOperation(plan, group.pluginIds, group.platform, true, nativeRuntime, group.command, targets);
|
|
1057
|
-
if (checked.operationPlan?.planFingerprint !== group.preview.operationPlan?.planFingerprint)
|
|
1058
|
-
|
|
1059
|
-
return completeReceipt(receipt);
|
|
1060
|
-
}
|
|
1370
|
+
if (checked.operationPlan?.planFingerprint !== group.preview.operationPlan?.planFingerprint)
|
|
1371
|
+
return 'stale';
|
|
1061
1372
|
const selection = nativeTargetSelection(executable);
|
|
1062
1373
|
const preview = executable.length === targets.length ? checked
|
|
1063
1374
|
: await nativeOperation(plan, selection.pluginIds, selection.platform, true, nativeRuntime, group.command, executable);
|
|
1064
|
-
|
|
1375
|
+
return { ...group, ...selection, preview };
|
|
1376
|
+
}, nativeRuntime.signal);
|
|
1377
|
+
if (recheckedGroups.includes('stale')) {
|
|
1378
|
+
receipt.blockers.push(diagnostic('operationReviewStale'));
|
|
1379
|
+
return completeReceipt(receipt);
|
|
1065
1380
|
}
|
|
1066
|
-
const
|
|
1381
|
+
const executableNativeGroups = recheckedGroups.filter((group) => group !== undefined && group !== 'stale');
|
|
1382
|
+
const portableProgress = execution.portableProgress ?? { completed: [], failed: [] };
|
|
1383
|
+
const portableBlocker = await recheckPortableRecovery(plan, plan.portableGroups, portableProgress);
|
|
1067
1384
|
if (portableBlocker) {
|
|
1068
1385
|
receipt.blockers.push(portableBlocker);
|
|
1069
1386
|
return completeReceipt(receipt);
|
|
@@ -1097,71 +1414,9 @@ export async function executeScopedRecovery(plan, execution = {}) {
|
|
|
1097
1414
|
return completeReceipt(receipt);
|
|
1098
1415
|
}
|
|
1099
1416
|
}
|
|
1100
|
-
for (const group of executableNativeGroups)
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
...(group.preview.operationPlan
|
|
1104
|
-
? { expectedPlanFingerprint: group.preview.operationPlan.planFingerprint } : {}) }, group.command, nativeGroupTargets(group));
|
|
1105
|
-
receipt.outputsMayHaveChanged ||= result.rebuildResults.some((result) => result.actions.some((action) => action.name === 'stale.cleanup' || action.name === 'native.write' || action.name === 'artifacts.write'
|
|
1106
|
-
|| action.name === 'recovery.cleanup' || action.name === 'cleanup.owned'))
|
|
1107
|
-
|| ((result.commandResults?.length ?? 0) > 0
|
|
1108
|
-
&& result.operationPlan?.actions.some((action) => action.kind === 'syncManagedCommandPackage') === true);
|
|
1109
|
-
nativeResults(plan, group, result, true);
|
|
1110
|
-
}
|
|
1111
|
-
catch (error) {
|
|
1112
|
-
const code = errorCode(error, 'nativeRecoveryFailed');
|
|
1113
|
-
receipt.outputsMayHaveChanged ||= code !== 'preApplyAuthorizationRequired';
|
|
1114
|
-
for (const { pluginId, platform } of nativeGroupTargets(group)) {
|
|
1115
|
-
const target = pair(plan, pluginId, agentForPlatform(platform));
|
|
1116
|
-
target.execution = 'failed';
|
|
1117
|
-
block(target, code);
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
const completedFootprints = [];
|
|
1122
|
-
const failedFootprints = [];
|
|
1123
|
-
for (const prepared of plan.portableGroups) {
|
|
1124
|
-
const agents = [];
|
|
1125
|
-
for (const agent of prepared.options.agents) {
|
|
1126
|
-
if (pair(plan, prepared.options.selector, agent).blockers.length)
|
|
1127
|
-
continue;
|
|
1128
|
-
const outcomes = prepared.targets.filter((entry) => entry.agent === agent).map((entry) => {
|
|
1129
|
-
const failed = failedFootprints.find((failure) => failure.logicalIdentity === prepared.logicalIdentity
|
|
1130
|
-
&& failure.outcome.physicalPath === entry.physicalPath && failure.outcome.expectedDigest === entry.expectedDigest
|
|
1131
|
-
&& failure.outcome.providerPluginId === entry.providerPluginId);
|
|
1132
|
-
return failed ? { ...failed.outcome, agent } : { ...entry, execution: 'not-run', blockers: [] };
|
|
1133
|
-
});
|
|
1134
|
-
if (outcomes.some((entry) => entry.execution === 'failed')) {
|
|
1135
|
-
portableOutcomes(plan, prepared, agent, outcomes, []);
|
|
1136
|
-
continue;
|
|
1137
|
-
}
|
|
1138
|
-
const preApplyFailure = await executePortablePreApply(plan, prepared, agent, nativeRuntime);
|
|
1139
|
-
if (preApplyFailure) {
|
|
1140
|
-
const target = pair(plan, prepared.options.selector, agent);
|
|
1141
|
-
target.execution = 'failed';
|
|
1142
|
-
block(target, preApplyFailure);
|
|
1143
|
-
target.recoveryActions = [`aw plugin sync ${target.pluginId} --context ${target.scope} --target ${agent} --yes`];
|
|
1144
|
-
continue;
|
|
1145
|
-
}
|
|
1146
|
-
agents.push(agent);
|
|
1147
|
-
}
|
|
1148
|
-
if (!agents.length)
|
|
1149
|
-
continue;
|
|
1150
|
-
const result = await executePortableRecovery({ prepared, token, authorizeUpdate: plan.options.yes,
|
|
1151
|
-
action: plan.command === 'install' ? 'sync' : plan.command, force: plan.options.force,
|
|
1152
|
-
targets: prepared.targets.filter((target) => agents.includes(target.agent)).map(({ skill, agent }) => ({ skill, agent })),
|
|
1153
|
-
completedFootprints });
|
|
1154
|
-
receipt.outputsMayHaveChanged ||= result.outputsMayHaveChanged;
|
|
1155
|
-
for (const agent of agents) {
|
|
1156
|
-
portableOutcomes(plan, prepared, agent, result.targets.filter((entry) => entry.agent === agent), result.globalBlockers);
|
|
1157
|
-
}
|
|
1158
|
-
failedFootprints.push(...result.targets.filter((target) => target.execution === 'failed')
|
|
1159
|
-
.map((outcome) => ({ logicalIdentity: prepared.logicalIdentity, outcome })));
|
|
1160
|
-
completedFootprints.push(...result.targets.filter((target) => target.observation === 'satisfied'
|
|
1161
|
-
&& ['applied', 'no-op'].includes(target.execution) && target.blockers.length === 0)
|
|
1162
|
-
.map(({ physicalPath, expectedDigest, providerPluginId }) => ({ physicalPath, expectedDigest, providerPluginId,
|
|
1163
|
-
logicalIdentity: prepared.logicalIdentity })));
|
|
1164
|
-
}
|
|
1417
|
+
for (const group of executableNativeGroups)
|
|
1418
|
+
await executeNativeGroup(plan, group, nativeRuntime);
|
|
1419
|
+
await executePortableGroups(plan, plan.portableGroups, nativeRuntime, portableProgress);
|
|
1165
1420
|
for (const { kind, pluginId, observation } of plan.portableResidues) {
|
|
1166
1421
|
if (kind !== 'cleanup')
|
|
1167
1422
|
continue;
|
|
@@ -1283,6 +1538,8 @@ export function describeRecoveryPlan(plan) {
|
|
|
1283
1538
|
nativeActivationOnlyTargets: child.options.nativeActivationOnlyTargets,
|
|
1284
1539
|
nativePlannedRetirements: child.options.nativePlannedRetirements,
|
|
1285
1540
|
portable: child.portableGroups.map((group) => group.evidenceDigest),
|
|
1541
|
+
inheritedPortable: child.options.portableProviderChecks?.size
|
|
1542
|
+
? [...child.options.portableProviderChecks].map(([root, providers]) => [root, providers.map((item) => item.evidenceDigest)]) : undefined,
|
|
1286
1543
|
protectedPortable: child.portableProtectionGroups.map((group) => group.evidenceDigest),
|
|
1287
1544
|
residue: child.portableResidues, blockers: child.receipt.blockers,
|
|
1288
1545
|
targetBlockers: child.receipt.targetResults.map((target) => target.blockers),
|
|
@@ -1290,6 +1547,8 @@ export function describeRecoveryPlan(plan) {
|
|
|
1290
1547
|
});
|
|
1291
1548
|
return { inputs: plan.joint?.evidence ?? [plan.originalIntent, plan.preferencesEvidence],
|
|
1292
1549
|
catalog: plan.command === 'install' ? plan.demand.catalogOperationContext?.generationSetDigest : undefined,
|
|
1550
|
+
pendingUserSkills: plan.joint?.pendingUserSkills,
|
|
1551
|
+
providerRetirements: plan.joint ? [...plan.joint.providerRetirements] : undefined,
|
|
1293
1552
|
command: plan.command, dependencyCleanupTargets: plan.dependencyCleanupTargets,
|
|
1294
1553
|
declaration: plan.joint?.declaration, packages: plan.runtime.configApplyPackages ? { targets: plan.runtime.configApplyPackages.targets, evidence: plan.runtime.configApplyPackages.evidence } : undefined, blockers: plan.receipt.blockers,
|
|
1295
1554
|
children: (plan.joint?.children ?? [plan]).map(describe) };
|