@lesliechan721/aw 0.1.0-beta.102 → 0.1.0-beta.103
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/src/commands/catalog-generation.d.ts +2 -5
- package/dist/src/commands/catalog-generation.js +2 -4
- package/dist/src/commands/catalog-generation.js.map +1 -1
- package/dist/src/commands/lifecycle-command-package.d.ts +1 -1
- package/dist/src/commands/lifecycle-command-package.js +40 -2
- package/dist/src/commands/lifecycle-command-package.js.map +1 -1
- package/dist/src/commands/managed-commands.d.ts +2 -1
- package/dist/src/commands/managed-commands.js +4 -2
- package/dist/src/commands/managed-commands.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +2 -8
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.d.ts +16 -10
- package/dist/src/commands/public-config-confirmation.js +87 -52
- package/dist/src/commands/public-config-confirmation.js.map +1 -1
- package/dist/src/commands/public-lifecycle.d.ts +1 -1
- package/dist/src/commands/public-lifecycle.js +36 -8
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +6 -4
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +22 -6
- package/dist/src/commands/rebuild-command.js +273 -557
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +12 -39
- package/dist/src/commands/rebuild-integration.js +67 -303
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +0 -4
- package/dist/src/commands/rebuild-operations.js +9 -8
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +14 -6
- package/dist/src/commands/rebuild-platform-integration.js +310 -101
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/commands/status-v6.d.ts +3 -117
- package/dist/src/commands/status-v6.js +0 -2886
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/commands/write-commands.js +0 -3
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/index.js +44 -36
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/deployment-preferences.js +4 -3
- package/dist/src/intent/deployment-preferences.js.map +1 -1
- package/dist/src/intent/intent-store.js +3 -2
- package/dist/src/intent/intent-store.js.map +1 -1
- package/dist/src/output/command-receipt.d.ts +0 -6
- package/dist/src/output/command-receipt.js +0 -15
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/receipt-projection.js +2 -1
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/platforms/capabilities.js +8 -2
- package/dist/src/platforms/capabilities.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +2 -0
- package/dist/src/platforms/discovery.d.ts +2 -0
- package/dist/src/platforms/discovery.js +95 -49
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/inspection-native.d.ts +7 -1
- package/dist/src/platforms/inspection-native.js +6 -3
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/inspection-query.d.ts +28 -14
- package/dist/src/platforms/inspection-query.js +102 -8
- package/dist/src/platforms/inspection-query.js.map +1 -1
- package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
- package/dist/src/platforms/lifecycle-native-services.js +7 -2
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.js +20 -3
- package/dist/src/platforms/lifecycle-native.js.map +1 -1
- package/dist/src/platforms/lifecycle.js +5 -0
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/platforms/supplement-state.js +11 -2
- package/dist/src/platforms/supplement-state.js.map +1 -1
- package/dist/src/portable/commands.d.ts +1 -0
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +2 -0
- package/dist/src/portable/materializer.js +4 -4
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +1 -0
- package/dist/src/portable/recovery.js +3 -2
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +6 -1
- package/dist/src/recovery/coordinator.js +113 -108
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/demand.d.ts +1 -2
- package/dist/src/recovery/demand.js +4 -11
- package/dist/src/recovery/demand.js.map +1 -1
- package/dist/src/recovery/install-concurrency.d.ts +12 -0
- package/dist/src/recovery/install-concurrency.js +39 -0
- package/dist/src/recovery/install-concurrency.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.d.ts +3 -4
- package/dist/src/recovery/joint-coordinator.js +324 -188
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.js +4 -3
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/joint-install-execution.js +46 -2
- package/dist/src/recovery/joint-install-execution.js.map +1 -1
- package/dist/src/recovery/joint-install-native-rebase.js +5 -2
- package/dist/src/recovery/joint-install-native-rebase.js.map +1 -1
- package/dist/src/recovery/locked-prepared-execution.d.ts +32 -0
- package/dist/src/recovery/locked-prepared-execution.js +67 -0
- package/dist/src/recovery/locked-prepared-execution.js.map +1 -0
- package/dist/src/recovery/status.d.ts +20 -6
- package/dist/src/recovery/status.js +153 -98
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +1 -0
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +4 -14
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +201 -57
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +8 -9
- package/dist/src/tui/controller.js +5 -6
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/operation-review-planner.js +14 -103
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- package/dist/src/types.d.ts +5 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.js +1 -0
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +10 -0
- package/dist/src/utils/artifact-renderer.js +28 -2
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.d.ts +8 -0
- package/dist/src/utils/aw-home-mutation-lock.js +44 -8
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/bundle-integrity.js +126 -33
- package/dist/src/utils/bundle-integrity.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +4 -0
- package/dist/src/utils/catalog-generation-resolver.js +4 -0
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +50 -11
- package/dist/src/utils/catalog-generation-service.js +276 -130
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-state.js +6 -1
- package/dist/src/utils/catalog-generation-state.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +5 -0
- package/dist/src/utils/catalog-generation-store.js +36 -13
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-operation-context.d.ts +17 -3
- package/dist/src/utils/catalog-operation-context.js +220 -22
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-performance.d.ts +3 -0
- package/dist/src/utils/catalog-performance.js +26 -0
- package/dist/src/utils/catalog-performance.js.map +1 -0
- package/dist/src/utils/catalog-snapshot.d.ts +5 -2
- package/dist/src/utils/catalog-snapshot.js +3 -2
- package/dist/src/utils/catalog-snapshot.js.map +1 -1
- package/dist/src/utils/catalog-source-impact.d.ts +2 -1
- package/dist/src/utils/catalog-source-impact.js +2 -2
- package/dist/src/utils/catalog-source-impact.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +2 -0
- package/dist/src/utils/catalog-source-references.js +284 -148
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-executable-discovery.js +1 -0
- package/dist/src/utils/codex-executable-discovery.js.map +1 -1
- package/dist/src/utils/codex-manager.js +1 -0
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +5 -2
- package/dist/src/utils/codex-native-observation.js +8 -4
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/component-command-preparation.d.ts +1 -0
- package/dist/src/utils/component-command-preparation.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +38 -5
- package/dist/src/utils/git-catalog-provider.js +365 -156
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/managed-command-closure.d.ts +3 -1
- package/dist/src/utils/managed-command-closure.js +10 -5
- package/dist/src/utils/managed-command-closure.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.d.ts +2 -0
- package/dist/src/utils/managed-command-materialization.js +4 -3
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-preparation.js +1 -1
- package/dist/src/utils/managed-command-preparation.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +1 -1
- package/dist/src/utils/multi-source-catalog.js +3 -3
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +6 -1
- package/dist/src/utils/native-cli.js +67 -32
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +2 -0
- package/dist/src/utils/platform-empty-state.js +5 -5
- package/dist/src/utils/platform-empty-state.js.map +1 -1
- package/dist/src/utils/plugin-config-command-apply.d.ts +14 -4
- package/dist/src/utils/plugin-config-command-apply.js +49 -5
- package/dist/src/utils/plugin-config-command-apply.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +42 -0
- package/dist/src/utils/plugin-config-impact.js +170 -14
- package/dist/src/utils/plugin-config-impact.js.map +1 -1
- package/dist/src/utils/plugin-config-references.d.ts +3 -1
- package/dist/src/utils/plugin-config-references.js +3 -5
- package/dist/src/utils/plugin-config-references.js.map +1 -1
- package/dist/src/utils/plugin-config-write.d.ts +14 -5
- package/dist/src/utils/plugin-config-write.js +213 -117
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +2 -0
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-scripts.d.ts +2 -0
- package/dist/src/utils/plugin-scripts.js +102 -3
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/utils/codex-reconciler.d.ts +0 -123
- package/dist/src/utils/codex-reconciler.js +0 -322
- package/dist/src/utils/codex-reconciler.js.map +0 -1
|
@@ -2,6 +2,7 @@ import crypto from 'node:crypto';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { mapInstallReads, runInstallTasks } from '../recovery/install-concurrency.js';
|
|
4
4
|
import { withNativeObservationBatch } from '../platforms/inspection-query.js';
|
|
5
|
+
import { LockedPreparedExecution } from '../recovery/locked-prepared-execution.js';
|
|
5
6
|
import { RebuildInterruptedError, recoveryInterruptionCode } from '../recovery/interruption.js';
|
|
6
7
|
import { inventoryRecoveryDiagnostic } from '../utils/inventory-recovery-diagnostic.js';
|
|
7
8
|
import fs from 'fs-extra';
|
|
@@ -18,17 +19,16 @@ import { getCodexOperationRequirement, probeAgentVersion } from '../utils/agent-
|
|
|
18
19
|
import { resolveArtifactRenderConfig } from '../utils/artifact-renderer.js';
|
|
19
20
|
import { configIssueDiagnostic, configReadDiagnostic } from '../utils/plugin-config-diagnostics.js';
|
|
20
21
|
import { reportCliPhase } from '../output/model.js';
|
|
21
|
-
import { withAwHomeMutationLock } from '../utils/aw-home-mutation-lock.js';
|
|
22
|
+
import { advanceAwHomeMutationEpoch, awHomeMutationEpoch, withAwHomeMutationLock } from '../utils/aw-home-mutation-lock.js';
|
|
22
23
|
import { catalogGenerationErrorCode, isOfflineCleanupCatalogGenerationError, } from '../utils/catalog-generation-error.js';
|
|
23
24
|
import { resolveActiveCatalogGeneration, resolveActiveCatalogPluginShallow } from '../utils/catalog-generation-resolver.js';
|
|
24
|
-
import { CatalogPreparationReadScope, catalogOperationBindingsMatch, resolveCatalogOperationContext, } from '../utils/catalog-operation-context.js';
|
|
25
|
+
import { CatalogPreparationReadScope, catalogOperationBindingsMatch, recheckCatalogClosureForCommit, resolveCatalogOperationContext, selectCatalogOperationContext, } from '../utils/catalog-operation-context.js';
|
|
25
26
|
import { sanitizeCatalogSourceErrorMessage } from '../utils/catalog-public-error.js';
|
|
26
27
|
import { validateCatalogSnapshotComplete } from '../utils/catalog-snapshot.js';
|
|
27
28
|
import { assertCatalogSourceInventoryComplete, resolveCleanupMarketplaceIdentity, scopedCleanupMarketplaceEvidence, inventoryCatalogSourceReferences, offlineOwnedPathEvidence, } from '../utils/catalog-source-references.js';
|
|
28
29
|
import { readCatalogSourcesConfigSnapshot } from '../utils/catalog-sources.js';
|
|
29
30
|
import { readCodexConfigFile } from '../utils/codex-config.js';
|
|
30
|
-
import {
|
|
31
|
-
import { createCodexNativeObservationSession } from '../utils/codex-native-observation.js';
|
|
31
|
+
import { resolveCodexOperationConsumer, } from '../utils/codex-manager.js';
|
|
32
32
|
import { isCanonicalCodexMarketplaceRegistration } from '../utils/codex-shared-native.js';
|
|
33
33
|
import { analyzeCodexSurface } from '../utils/codex-surface-analysis.js';
|
|
34
34
|
import { getNamespacedMarketplaceName, } from '../utils/local-marketplace.js';
|
|
@@ -49,18 +49,40 @@ import { createDependencyPlacementPlan, } from './dependency-operation-plan.js';
|
|
|
49
49
|
import { forceOfflineCleanupEvidence, intentOnlyOfflineCleanupEvidence, offlineCleanupEvidenceFromInventory, offlineCleanupEvidenceMatches, } from './offline-cleanup-evidence.js';
|
|
50
50
|
import { assertOperationPlanFingerprint, createOperationPlan, createOperationPlanConfigDigest, operationPlanNativeToolChanges, } from './operation-plan.js';
|
|
51
51
|
import { deploymentConfirmationEffects } from './deployment-confirmation.js';
|
|
52
|
-
import { assertNoClaudeUnboundNativeNameCollision,
|
|
52
|
+
import { assertNoClaudeUnboundNativeNameCollision, createRebuildIntegration, disposePreparedPlatformRebuildSession, inspectNativeMarketplaceRegistration, isNativeActivationOnlyTarget, recordPreparedGrokOfflineRuleRemoval, recordPreparedOfflinePermissionRemoval, recordPreparedPermissionWrite, removeForceCleanupCodexRoleRegistration } from './rebuild-integration.js';
|
|
53
53
|
import { executeRebuildOperation, hasPlannedPreApply, prepareRebuildOperation } from './rebuild-operations.js';
|
|
54
54
|
import { createReconcileOperationPlan, } from './reconcile-operation-plan.js';
|
|
55
55
|
// A read scope belongs to one Review or its independent locked recheck.
|
|
56
56
|
const nativePreparationReads = new WeakMap();
|
|
57
|
+
const lockedPreWriteInventories = new WeakMap();
|
|
58
|
+
function readSharedLockedPreWriteInventory(token, admissionGen, key, read) {
|
|
59
|
+
if (!token)
|
|
60
|
+
return read();
|
|
61
|
+
const epoch = awHomeMutationEpoch(token);
|
|
62
|
+
let bucket = lockedPreWriteInventories.get(token);
|
|
63
|
+
if (!bucket || bucket.epoch !== epoch || bucket.admissionGen !== admissionGen) {
|
|
64
|
+
bucket = { epoch, admissionGen, entries: new Map() };
|
|
65
|
+
lockedPreWriteInventories.set(token, bucket);
|
|
66
|
+
}
|
|
67
|
+
let pending = bucket.entries.get(key);
|
|
68
|
+
if (!pending) {
|
|
69
|
+
const activeBucket = bucket;
|
|
70
|
+
pending = read().catch((error) => {
|
|
71
|
+
if (activeBucket.entries.get(key) === pending)
|
|
72
|
+
activeBucket.entries.delete(key);
|
|
73
|
+
throw error;
|
|
74
|
+
});
|
|
75
|
+
bucket.entries.set(key, pending);
|
|
76
|
+
}
|
|
77
|
+
return pending;
|
|
78
|
+
}
|
|
57
79
|
function preparationReads(runtime) {
|
|
58
80
|
const scope = runtime?.catalogReadScope;
|
|
59
81
|
if (!scope || !runtime.previewOperationPlan || !runtime.batchInstallPlatform)
|
|
60
82
|
return;
|
|
61
83
|
let reads = nativePreparationReads.get(scope);
|
|
62
84
|
if (!reads) {
|
|
63
|
-
reads = {
|
|
85
|
+
reads = { inventories: new Map() };
|
|
64
86
|
nativePreparationReads.set(scope, reads);
|
|
65
87
|
}
|
|
66
88
|
return reads;
|
|
@@ -89,6 +111,14 @@ async function measureCommandPerformanceStage(runtime, name, operation) {
|
|
|
89
111
|
})).catch(() => undefined);
|
|
90
112
|
}
|
|
91
113
|
}
|
|
114
|
+
const sealedPreviews = new WeakMap();
|
|
115
|
+
/** A later scope can update a prepared target's shared descriptor, retention or script actions.
|
|
116
|
+
* Within the same observation epoch those are projections of the already checked targets. */
|
|
117
|
+
export function refreshSealedNativePreview(batch, result) {
|
|
118
|
+
if (!result.operationPlan || result.nativePreviewEpoch !== batch.writeEpoch)
|
|
119
|
+
return;
|
|
120
|
+
return sealedPreviews.get(batch)?.get(result.operationPlan)?.(result);
|
|
121
|
+
}
|
|
92
122
|
function assertNativeToolChangeAuthorization(plan, options) {
|
|
93
123
|
if (operationPlanNativeToolChanges(plan).length === 0
|
|
94
124
|
|| options.commandOptions.yes === true)
|
|
@@ -144,92 +174,6 @@ function omitSelectedPluginConfigErrors(inventory, targets) {
|
|
|
144
174
|
function selectedPlatforms(selection) {
|
|
145
175
|
return selection === 'both' ? ['codex', 'claude'] : [selection];
|
|
146
176
|
}
|
|
147
|
-
function selectCodexActivationPlans(plans, targetScopes, preservedActivations, originalUserActivations) {
|
|
148
|
-
return plans.flatMap((plan) => {
|
|
149
|
-
const includesScope = (pluginId, scope) => targetScopes.has(`${pluginId}\0${scope}`);
|
|
150
|
-
const pluginIds = new Set(plan.desiredTargets.flatMap((target) => ['user', 'project'].some((scope) => includesScope(target.pluginId, scope))
|
|
151
|
-
? [target.pluginId]
|
|
152
|
-
: []));
|
|
153
|
-
if (pluginIds.size === 0)
|
|
154
|
-
return [];
|
|
155
|
-
const includesActivationAction = (action) => includesScope(action.pluginId, action.scope);
|
|
156
|
-
const sharedNativeActions = plan.sharedNativeActions.filter((action) => pluginIds.has(action.pluginId));
|
|
157
|
-
const userActions = plan.activationActions.user.filter((action) => pluginIds.has(action.pluginId) && includesActivationAction(action));
|
|
158
|
-
for (const action of plan.activationActions.user) {
|
|
159
|
-
if (!originalUserActivations || includesScope(action.pluginId, 'user')
|
|
160
|
-
|| !includesScope(action.pluginId, 'project')
|
|
161
|
-
|| !sharedNativeActions.some((shared) => shared.pluginId === action.pluginId
|
|
162
|
-
&& (shared.action === 'install' || shared.action === 'replace' || shared.action === 'repair'))) {
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
const original = originalUserActivations.get(action.codexPluginId) === true;
|
|
166
|
-
if ((preservedActivations?.user.get(action.codexPluginId) === true) === original)
|
|
167
|
-
continue;
|
|
168
|
-
userActions.push({ ...action, action: original ? 'enable' : 'disable', desired: original });
|
|
169
|
-
}
|
|
170
|
-
const projectActions = plan.activationActions.project.filter((action) => pluginIds.has(action.pluginId) && includesActivationAction(action));
|
|
171
|
-
const desiredTargets = plan.desiredTargets.flatMap((target) => {
|
|
172
|
-
const scopes = target.scopes.filter((scope) => includesScope(target.pluginId, scope));
|
|
173
|
-
return scopes.length > 0 ? [{ ...target, scopes }] : [];
|
|
174
|
-
});
|
|
175
|
-
const postcheckPlugins = plan.postcheck.plugins.filter((plugin) => pluginIds.has(plugin.pluginId)).map((plugin) => ({
|
|
176
|
-
...plugin,
|
|
177
|
-
expectedUserEnabled: userActions.some((action) => action.pluginId === plugin.pluginId)
|
|
178
|
-
? plugin.expectedUserEnabled
|
|
179
|
-
: preservedActivations?.user.get(plugin.codexPluginId) ?? false,
|
|
180
|
-
expectedProjectEnabled: projectActions.some((action) => action.pluginId === plugin.pluginId)
|
|
181
|
-
? plugin.expectedProjectEnabled
|
|
182
|
-
: preservedActivations?.project.get(plugin.codexPluginId) ?? false,
|
|
183
|
-
}));
|
|
184
|
-
const codexPluginIds = new Set([
|
|
185
|
-
...sharedNativeActions.map((action) => action.codexPluginId),
|
|
186
|
-
...userActions.map((action) => action.codexPluginId),
|
|
187
|
-
...projectActions.map((action) => action.codexPluginId),
|
|
188
|
-
...postcheckPlugins.map((plugin) => plugin.codexPluginId),
|
|
189
|
-
]);
|
|
190
|
-
return [{
|
|
191
|
-
...plan,
|
|
192
|
-
desiredTargets,
|
|
193
|
-
sharedNativeActions,
|
|
194
|
-
activationActions: { user: userActions, project: projectActions },
|
|
195
|
-
extensionWrites: plan.extensionWrites.filter((action) => includesScope(action.pluginId, action.scope)),
|
|
196
|
-
extensionRemovals: plan.extensionRemovals.filter((action) => includesScope(action.pluginId, action.scope)),
|
|
197
|
-
staleActivationRemovals: plan.staleActivationRemovals.filter((action) => codexPluginIds.has(action.codexPluginId)
|
|
198
|
-
&& [...pluginIds].some((pluginId) => includesScope(pluginId, action.scope))),
|
|
199
|
-
postcheck: { ...plan.postcheck, plugins: postcheckPlugins },
|
|
200
|
-
}];
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
function failedCodexActivationTargetScopes(options) {
|
|
204
|
-
const error = options.error;
|
|
205
|
-
if (!(error instanceof CodexActivationPostcheckError)) {
|
|
206
|
-
return new Set(options.successfulTargetScopes);
|
|
207
|
-
}
|
|
208
|
-
const ownersByCodexPluginId = new Map();
|
|
209
|
-
for (const entry of options.plans.flatMap((plan) => [
|
|
210
|
-
...plan.activationActions.user,
|
|
211
|
-
...plan.activationActions.project,
|
|
212
|
-
...plan.postcheck.plugins,
|
|
213
|
-
])) {
|
|
214
|
-
const owners = ownersByCodexPluginId.get(entry.codexPluginId) ?? new Set();
|
|
215
|
-
owners.add(entry.pluginId);
|
|
216
|
-
ownersByCodexPluginId.set(entry.codexPluginId, owners);
|
|
217
|
-
}
|
|
218
|
-
const failed = new Set();
|
|
219
|
-
for (const codexPluginId of error.codexPluginIds) {
|
|
220
|
-
const owners = ownersByCodexPluginId.get(codexPluginId);
|
|
221
|
-
if (!owners || owners.size === 0)
|
|
222
|
-
return new Set(options.successfulTargetScopes);
|
|
223
|
-
for (const pluginId of owners) {
|
|
224
|
-
for (const scope of ['user', 'project']) {
|
|
225
|
-
const key = `${pluginId}\0${scope}`;
|
|
226
|
-
if (options.successfulTargetScopes.has(key))
|
|
227
|
-
failed.add(key);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return failed.size > 0 ? failed : new Set(options.successfulTargetScopes);
|
|
232
|
-
}
|
|
233
177
|
function effectiveDependencyScopeOverrides(options) {
|
|
234
178
|
const nodeKeys = new Set(options.nodes.map((node) => `${node.pluginId}\0${node.platform}`));
|
|
235
179
|
const explicitMatches = (pluginId, platform) => options.explicit.some((override) => override.pluginId === pluginId
|
|
@@ -339,6 +283,8 @@ async function resolveRequestedNames(options) {
|
|
|
339
283
|
}
|
|
340
284
|
async function runSingleSourceRebuildCommand(options) {
|
|
341
285
|
const runtime = {
|
|
286
|
+
awHomeMutationToken: options.runtime?.awHomeMutationToken,
|
|
287
|
+
catalogReadScope: options.runtime?.catalogReadScope,
|
|
342
288
|
invocationCwd: options.runtime?.invocationCwd,
|
|
343
289
|
referencePlugins: options.runtime?.referencePlugins,
|
|
344
290
|
recoveryCandidates: options.runtime?.recoveryCandidates,
|
|
@@ -358,8 +304,7 @@ async function runSingleSourceRebuildCommand(options) {
|
|
|
358
304
|
debugLogger: options.runtime?.debugLogger ?? createNoopDebugLogger(),
|
|
359
305
|
...(options.runtime?.codexManager ? { codexManager: options.runtime.codexManager } : {}),
|
|
360
306
|
expectedCatalogConfigDigest: options.runtime?.expectedCatalogConfigDigest,
|
|
361
|
-
|
|
362
|
-
codexObservationSession: options.runtime?.codexObservationSession,
|
|
307
|
+
nativeObservationBatch: options.runtime?.nativeObservationBatch,
|
|
363
308
|
preApplyExecutionCache: options.runtime?.preApplyExecutionCache,
|
|
364
309
|
managedCommandProducerCache: options.runtime?.managedCommandProducerCache ?? new Map(),
|
|
365
310
|
preserveLegacyNativeSkills: options.runtime?.preserveLegacyNativeSkills,
|
|
@@ -607,9 +552,6 @@ function mergeRebuildCommandResults(results) {
|
|
|
607
552
|
...(results.find((result) => result.dependencyPlan)?.dependencyPlan
|
|
608
553
|
? { dependencyPlan: results.find((result) => result.dependencyPlan).dependencyPlan }
|
|
609
554
|
: {}),
|
|
610
|
-
...(results.find((result) => result.codexManagerPreview)?.codexManagerPreview
|
|
611
|
-
? { codexManagerPreview: results.find((result) => result.codexManagerPreview).codexManagerPreview }
|
|
612
|
-
: {}),
|
|
613
555
|
...(results.find((result) => result.operationPlan)?.operationPlan
|
|
614
556
|
? { operationPlan: results.find((result) => result.operationPlan).operationPlan }
|
|
615
557
|
: {}),
|
|
@@ -643,48 +585,18 @@ function reconcileOverallState(targetResults, plan, rebuildResults = []) {
|
|
|
643
585
|
return completedRequested || completedMutation || observedMutation ? 'partial' : 'failed';
|
|
644
586
|
}
|
|
645
587
|
function createRebuildOperationPlan(options) {
|
|
646
|
-
const actions = [
|
|
647
|
-
...(options.targetActions ?? []),
|
|
648
|
-
...options.codexPlans.flatMap((plan) => [
|
|
649
|
-
...plan.sharedNativeActions.flatMap((action) => action.action === 'install' || action.action === 'replace' || action.action === 'repair'
|
|
650
|
-
? [{
|
|
651
|
-
kind: 'ensureNativeRegistration',
|
|
652
|
-
pluginId: action.pluginId,
|
|
653
|
-
platform: 'codex',
|
|
654
|
-
scope: options.dependencyPlan.targets.find((target) => target.pluginId === action.pluginId && target.platform === 'codex')?.resolvedScope ?? 'user',
|
|
655
|
-
registration: action.codexPluginId,
|
|
656
|
-
}]
|
|
657
|
-
: []),
|
|
658
|
-
...['user', 'project'].flatMap((scope) => plan.activationActions[scope].flatMap((action) => action.action === 'none'
|
|
659
|
-
? []
|
|
660
|
-
: [{
|
|
661
|
-
kind: 'setActivation',
|
|
662
|
-
pluginId: action.pluginId,
|
|
663
|
-
platform: 'codex',
|
|
664
|
-
scope,
|
|
665
|
-
enabled: action.desired,
|
|
666
|
-
}])),
|
|
667
|
-
...plan.staleActivationRemovals.map((action) => ({
|
|
668
|
-
kind: 'setActivation',
|
|
669
|
-
pluginId: action.codexPluginId,
|
|
670
|
-
platform: 'codex',
|
|
671
|
-
scope: action.scope,
|
|
672
|
-
enabled: false,
|
|
673
|
-
})),
|
|
674
|
-
]),
|
|
675
|
-
];
|
|
676
588
|
return createOperationPlan({
|
|
677
589
|
deploymentExclusions: options.deploymentExclusions,
|
|
678
590
|
...(options.deploymentPlans ? { deploymentPlans: options.deploymentPlans } : {}),
|
|
679
591
|
intentChanges: [],
|
|
680
|
-
actions,
|
|
592
|
+
actions: [...options.targetActions ?? []],
|
|
681
593
|
changes: options.dependencyPlan.targets.map((target) => [
|
|
682
594
|
target.pluginId,
|
|
683
595
|
target.platform,
|
|
684
596
|
target.resolvedScope,
|
|
685
597
|
target.action,
|
|
686
598
|
].join(':')),
|
|
687
|
-
warnings:
|
|
599
|
+
warnings: [],
|
|
688
600
|
evidence: {
|
|
689
601
|
catalogDigests: options.catalogSources.map((source) => ({
|
|
690
602
|
sourceId: source.sourceId,
|
|
@@ -1079,7 +991,7 @@ async function cleanupOfflineOwnedComponents(options) {
|
|
|
1079
991
|
await updateHostPermissions({ env: options.env, cwd: options.cwd, invocationCwd: options.nativePreparation?.invocationCwd }, locator, undefined, (previous, current, target = locator.settingsPath, host) => {
|
|
1080
992
|
advanced.set(target, current);
|
|
1081
993
|
if (options.preparedArtifactRenderResults) {
|
|
1082
|
-
recordPreparedPermissionWrite(options.preparedArtifactRenderResults, target, previous, current, locator.platform === 'grok' ? host : undefined);
|
|
994
|
+
recordPreparedPermissionWrite(options.preparedArtifactRenderResults, locator.platform, target, previous, current, locator.platform === 'grok' ? host : undefined);
|
|
1083
995
|
}
|
|
1084
996
|
}, review.batch, (notices) => permissionNotices.push(...notices), expected, locator.platform === 'opencode' && !locator.projectRoot ? relatedProjectBatch : undefined);
|
|
1085
997
|
}
|
|
@@ -1965,7 +1877,6 @@ async function removedPluginOutputCleanupInContext(options) {
|
|
|
1965
1877
|
cwd: options.context.executionCwd,
|
|
1966
1878
|
env: options.context.env,
|
|
1967
1879
|
nativeCliRunner: options.runtime?.nativeCliRunner,
|
|
1968
|
-
codexManagerPreviewer: options.runtime?.codexManagerPreviewer,
|
|
1969
1880
|
onPreviewStage: options.runtime?.onPreviewStage,
|
|
1970
1881
|
})
|
|
1971
1882
|
: await cleanupOfflineOwnedComponents({
|
|
@@ -2011,8 +1922,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
2011
1922
|
const runtimeEnv = executionInput.context.env;
|
|
2012
1923
|
const admission = options.runtime?.installAdmission;
|
|
2013
1924
|
const initialGeneration = admission?.exclusiveGeneration ?? 0;
|
|
2014
|
-
if (initialGeneration && requestedPlatforms.includes('codex'))
|
|
2015
|
-
options.runtime?.codexObservationSession?.invalidate();
|
|
2016
1925
|
const retainSelectors = options.command === 'cleanup' ? options.pluginNames.map(parsePluginId) : [];
|
|
2017
1926
|
const primarySourceId = retainSelectors.some((selector) => !selector.sourceId)
|
|
2018
1927
|
? await readCatalogSourcesConfigSnapshot(runtimeEnv)
|
|
@@ -2026,14 +1935,14 @@ async function runRebuildCommandInSession(options) {
|
|
|
2026
1935
|
const readInventory = options.runtime?.inventoryCatalogSourceReferences
|
|
2027
1936
|
?? inventoryCatalogSourceReferences;
|
|
2028
1937
|
const inventoryRequest = { cwd: options.commandOptions.cwd, env: runtimeEnv, scope: options.commandOptions.scope };
|
|
2029
|
-
const readCurrentInventory = () => {
|
|
1938
|
+
const readCurrentInventory = (request = inventoryRequest) => {
|
|
2030
1939
|
if (!admission || !options.runtime?.batchInstallPlatform)
|
|
2031
|
-
return readInventory(
|
|
1940
|
+
return readInventory(request);
|
|
2032
1941
|
// The inventory includes other hosts' registries and owner markers. Sample them
|
|
2033
1942
|
// outside any target or script lease, while sibling publishers are between writes.
|
|
2034
1943
|
const roots = [resolveAwHome(runtimeEnv), resolveRepoRootSync(inventoryRequest.cwd),
|
|
2035
1944
|
...NATIVE_PLATFORM_TARGETS.map((platform) => resolvePlatformConfigRoot(platform, inventoryRequest))];
|
|
2036
|
-
return admission.run(roots.map((value) => ({ kind: 'path', value, access: 'read' })), () => readInventory(
|
|
1945
|
+
return admission.run(roots.map((value) => ({ kind: 'path', value, access: 'read' })), () => readInventory(request), options.runtime.signal);
|
|
2037
1946
|
};
|
|
2038
1947
|
const readCache = preparationReads(options.runtime);
|
|
2039
1948
|
let ordinaryInventory;
|
|
@@ -2542,6 +2451,8 @@ async function runRebuildCommandInSession(options) {
|
|
|
2542
2451
|
&& catalogOperation?.generationSetDigest !== options.runtime.expectedGenerationSetDigest) {
|
|
2543
2452
|
throw new Error('operationReviewStale: Active Catalog generation changed before mutation.');
|
|
2544
2453
|
}
|
|
2454
|
+
let preparedGroupForReview;
|
|
2455
|
+
let refreshSealedPreview;
|
|
2545
2456
|
const resolvedResult = await withResolvedMultiSourceCatalog({
|
|
2546
2457
|
cliVersion: resolveRuntimeCliVersion(),
|
|
2547
2458
|
...(sourceIds ? { sourceIds } : {}),
|
|
@@ -2629,6 +2540,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
2629
2540
|
...removalDesiredEntries,
|
|
2630
2541
|
...removalConsumerEntries,
|
|
2631
2542
|
].map((candidate) => [candidate.pluginId, candidate])).values()];
|
|
2543
|
+
const checkedManifestSources = new Map();
|
|
2632
2544
|
if (dependencyEnabled) {
|
|
2633
2545
|
for (const candidate of requiredEntryClosure) {
|
|
2634
2546
|
const requiredCapabilities = candidate.entry.requires.aw.capabilities ?? [];
|
|
@@ -2644,19 +2556,36 @@ async function runRebuildCommandInSession(options) {
|
|
|
2644
2556
|
.filter((candidate) => candidate.source.sourceId === source.sourceId)
|
|
2645
2557
|
.map((candidate) => candidate.entry.name);
|
|
2646
2558
|
if (names.length > 0) {
|
|
2647
|
-
|
|
2559
|
+
if (!options.runtime?.previewOperationPlan && options.runtime?.nativeObservationBatch?.phase === 'locked-execution') {
|
|
2560
|
+
// The locked preparation has already validated Transport. A
|
|
2561
|
+
// native group entering execution must still read its current
|
|
2562
|
+
// source binding and complete dependency closure from disk.
|
|
2563
|
+
const original = selectCatalogOperationContext(catalogOperation, [source.sourceId]);
|
|
2564
|
+
const { current, readScope } = await recheckCatalogClosureForCommit({
|
|
2565
|
+
env: runtimeEnv, signal: options.runtime.signal, sourceId: source.sourceId,
|
|
2566
|
+
original, closurePluginNames: names,
|
|
2567
|
+
});
|
|
2568
|
+
const checkedSource = current?.catalog.sources.find((item) => item.sourceId === source.sourceId)?.resolution;
|
|
2569
|
+
if (!checkedSource || !catalogOperationBindingsMatch(original, current)) {
|
|
2570
|
+
throw new Error('operationReviewStale: Active Catalog changed before native execution.');
|
|
2571
|
+
}
|
|
2572
|
+
checkedManifestSources.set(source.sourceId, { source: checkedSource, scope: readScope });
|
|
2573
|
+
}
|
|
2574
|
+
else {
|
|
2575
|
+
await CatalogPreparationReadScope.validateEntries(options.runtime?.catalogReadScope, source, names);
|
|
2576
|
+
}
|
|
2648
2577
|
}
|
|
2649
2578
|
}
|
|
2650
2579
|
});
|
|
2651
2580
|
}
|
|
2652
2581
|
const available = await Promise.all(requiredEntryClosure.map(async (candidate) => {
|
|
2653
|
-
const
|
|
2654
|
-
const
|
|
2655
|
-
const
|
|
2656
|
-
|
|
2657
|
-
const plugin = { ...
|
|
2658
|
-
catalogLogicalIdentity:
|
|
2659
|
-
return { source
|
|
2582
|
+
const checked = checkedManifestSources.get(candidate.source.sourceId);
|
|
2583
|
+
const source = checked?.source ?? candidate.source;
|
|
2584
|
+
const scope = checked?.scope ?? (options.runtime?.previewOperationPlan ? options.runtime.catalogReadScope : undefined);
|
|
2585
|
+
const read = await CatalogPreparationReadScope.readManifest(scope, source, candidate.entry.name);
|
|
2586
|
+
const plugin = { ...read, sourceId: source.sourceId, sourceIdentity: source.sourceIdentity,
|
|
2587
|
+
catalogLogicalIdentity: source.logicalIdentity, pluginId: candidate.pluginId };
|
|
2588
|
+
return { source, plugin, pluginId: candidate.pluginId };
|
|
2660
2589
|
}));
|
|
2661
2590
|
const selected = selectedEntries.map((entry) => available.find((candidate) => candidate.pluginId === entry.pluginId));
|
|
2662
2591
|
const selectedIds = new Set(selected.map((entry) => entry.pluginId));
|
|
@@ -2799,7 +2728,29 @@ async function runRebuildCommandInSession(options) {
|
|
|
2799
2728
|
if (options.runtime?.previewOperationPlan) {
|
|
2800
2729
|
await options.runtime.onPreviewStage?.('inventory');
|
|
2801
2730
|
}
|
|
2802
|
-
const
|
|
2731
|
+
const preparedGroup = !options.runtime?.reviewPreflight && !rebuildCommandTestHooks?.afterTargetBuilt
|
|
2732
|
+
? LockedPreparedExecution.consumeGroup(options.runtime?.nativeObservationBatch, options.runtime?.awHomeMutationToken, options.runtime?.reviewedNativePlan) : undefined;
|
|
2733
|
+
const touched = preparedGroup && options.command === 'sync' && options.runtime?.singleLockedSync
|
|
2734
|
+
&& readInventory === inventoryCatalogSourceReferences
|
|
2735
|
+
? new Set(closureEntries.map((entry) => entry.pluginId)) : undefined;
|
|
2736
|
+
const canShareLockedInventory = !options.runtime?.previewOperationPlan
|
|
2737
|
+
&& readInventory === inventoryCatalogSourceReferences
|
|
2738
|
+
&& options.runtime?.awHomeMutationToken !== undefined;
|
|
2739
|
+
const stateInventory = touched
|
|
2740
|
+
? await readSharedLockedPreWriteInventory(options.runtime?.awHomeMutationToken, admission?.exclusiveGeneration ?? 0, JSON.stringify([
|
|
2741
|
+
inventoryRequest.cwd,
|
|
2742
|
+
inventoryRequest.scope,
|
|
2743
|
+
[...touched].sort(),
|
|
2744
|
+
Object.entries(runtimeEnv).sort(([a], [b]) => a.localeCompare(b)),
|
|
2745
|
+
]), () => measureCommandPerformanceStage(options.runtime, 'inventory', () => readCurrentInventory({ ...inventoryRequest, nativePathEvidencePlugins: touched })))
|
|
2746
|
+
: canShareLockedInventory
|
|
2747
|
+
? await readSharedLockedPreWriteInventory(options.runtime?.awHomeMutationToken, admission?.exclusiveGeneration ?? 0, JSON.stringify([
|
|
2748
|
+
inventoryRequest.cwd,
|
|
2749
|
+
inventoryRequest.scope,
|
|
2750
|
+
null,
|
|
2751
|
+
Object.entries(runtimeEnv).sort(([a], [b]) => a.localeCompare(b)),
|
|
2752
|
+
]), () => readOrdinaryInventory())
|
|
2753
|
+
: await readOrdinaryInventory();
|
|
2803
2754
|
const assertWriteInventoryComplete = (inventory, exactOwnedTextErrorLocations, exactSkillMarkerErrorLocations) => {
|
|
2804
2755
|
if (options.command === 'cleanup')
|
|
2805
2756
|
return;
|
|
@@ -2904,25 +2855,13 @@ async function runRebuildCommandInSession(options) {
|
|
|
2904
2855
|
}
|
|
2905
2856
|
}
|
|
2906
2857
|
const codexObservationScopeByMarketplace = new Map();
|
|
2907
|
-
const projectCodexConfig = options.commandOptions.scope === 'project'
|
|
2908
|
-
? await readCodexConfigFile(resolveCodexPaths(options.commandOptions.cwd, 'project', runtimeEnv).configTomlPath)
|
|
2909
|
-
: undefined;
|
|
2910
2858
|
for (const { entry, platform } of executionSelections) {
|
|
2911
|
-
if (platform
|
|
2912
|
-
|
|
2913
|
-
const marketplaceName = getNamespacedMarketplaceName(entry.source.sourceId);
|
|
2914
|
-
const codexPluginId = `${entry.plugin.manifest.name}@${marketplaceName}`;
|
|
2915
|
-
const requiredScope = options.commandOptions.scope === 'project'
|
|
2916
|
-
|| (projectCodexConfig !== undefined
|
|
2917
|
-
&& Object.hasOwn(projectCodexConfig.snapshot.plugins, codexPluginId))
|
|
2918
|
-
? 'both'
|
|
2919
|
-
: 'user';
|
|
2920
|
-
if (requiredScope === 'both'
|
|
2921
|
-
|| !codexObservationScopeByMarketplace.has(marketplaceName)) {
|
|
2922
|
-
codexObservationScopeByMarketplace.set(marketplaceName, requiredScope);
|
|
2923
|
-
}
|
|
2859
|
+
if (platform === 'codex')
|
|
2860
|
+
codexObservationScopeByMarketplace.set(getNamespacedMarketplaceName(entry.source.sourceId), options.commandOptions.scope === 'project' ? 'both' : 'user');
|
|
2924
2861
|
}
|
|
2925
2862
|
const executionContext = {
|
|
2863
|
+
awHomeMutationToken: options.runtime?.awHomeMutationToken,
|
|
2864
|
+
catalogReadScope: options.runtime?.catalogReadScope,
|
|
2926
2865
|
invocationCwd: options.runtime?.invocationCwd,
|
|
2927
2866
|
recoveryCandidates: options.runtime?.recoveryCandidates,
|
|
2928
2867
|
sharedReferenceView: options.runtime?.executionInput?.requirements.sharedReferenceView ?? options.runtime?.sharedReferenceView,
|
|
@@ -2943,8 +2882,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
2943
2882
|
reporter: options.runtime?.reporter ?? createNoopReporter(),
|
|
2944
2883
|
debugLogger: options.runtime?.debugLogger ?? createNoopDebugLogger(),
|
|
2945
2884
|
expectedCatalogConfigDigest: catalog.configDigest,
|
|
2946
|
-
|
|
2947
|
-
nativeObservationBatch: options.runtime?.previewOperationPlan ? options.runtime.nativeObservationBatch : undefined,
|
|
2885
|
+
nativeObservationBatch: options.runtime?.nativeObservationBatch,
|
|
2948
2886
|
codexObservationScopeByMarketplace,
|
|
2949
2887
|
preApplyExecutionCache: options.runtime?.preApplyExecutionCache,
|
|
2950
2888
|
managedCommandProducerCache: options.runtime?.managedCommandProducerCache,
|
|
@@ -2952,9 +2890,13 @@ async function runRebuildCommandInSession(options) {
|
|
|
2952
2890
|
nativeActivationOnlyTargets: options.runtime?.nativeActivationOnlyTargets,
|
|
2953
2891
|
commandResults: options.runtime?.commandResults,
|
|
2954
2892
|
};
|
|
2893
|
+
const awaitSharedNativePreparation = options.runtime?.previewOperationPlan ? options.runtime.awaitSharedNativePreparation : undefined;
|
|
2894
|
+
const ordinaryContext = awaitSharedNativePreparation
|
|
2895
|
+
? { ...executionContext, platformRebuildSession: undefined } : executionContext;
|
|
2955
2896
|
const inspection = createRebuildIntegration({
|
|
2956
|
-
context:
|
|
2897
|
+
context: ordinaryContext,
|
|
2957
2898
|
scriptTimeoutMs: options.commandOptions.scriptTimeoutMs,
|
|
2899
|
+
...(awaitSharedNativePreparation ? { isolatedObservation: true } : {}),
|
|
2958
2900
|
});
|
|
2959
2901
|
let plannedOwnedTextTargets = new Map();
|
|
2960
2902
|
let plannedSkillMarkerTargets = new Map();
|
|
@@ -2986,16 +2928,8 @@ async function runRebuildCommandInSession(options) {
|
|
|
2986
2928
|
}
|
|
2987
2929
|
return output;
|
|
2988
2930
|
};
|
|
2989
|
-
const readSelections =
|
|
2990
|
-
|
|
2991
|
-
const run = (batch) => mapInstallReads(executionSelections, (selection) => read(selection, batch), { signal: executionContext.signal, limit: batchInstall ? undefined : 1 });
|
|
2992
|
-
if (!batchInstall || executionSelections.length < 2)
|
|
2993
|
-
return run();
|
|
2994
|
-
if (existingBatch)
|
|
2995
|
-
return run(existingBatch);
|
|
2996
|
-
return withNativeObservationBatch({ runner: executionContext.nativeCliRunner, signal: executionContext.signal }, run);
|
|
2997
|
-
};
|
|
2998
|
-
const createPlan = async (inventory, _codexManager, planOptions) => {
|
|
2931
|
+
const readSelections = (read) => mapInstallReads(executionSelections, (selection) => read(selection, executionContext.nativeObservationBatch), { signal: executionContext.signal, limit: options.runtime?.batchInstallPlatform ? undefined : 1 });
|
|
2932
|
+
const createPlan = async (inventory, planOptions) => {
|
|
2999
2933
|
plannedOwnedTextTargets = new Map();
|
|
3000
2934
|
plannedSkillMarkerTargets = new Map();
|
|
3001
2935
|
assertWriteInventoryComplete(inventory);
|
|
@@ -3087,7 +3021,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
3087
3021
|
: inspectScope(otherScope),
|
|
3088
3022
|
]);
|
|
3089
3023
|
return { requestedInspection, otherInspection, otherScope };
|
|
3090
|
-
}
|
|
3024
|
+
});
|
|
3091
3025
|
for (const [order, selection] of executionSelections.entries()) {
|
|
3092
3026
|
const { entry, platform } = selection;
|
|
3093
3027
|
const relation = executionInput.selectedTargets.some((target) => target.pluginId === entry.pluginId && target.platform === platform)
|
|
@@ -3295,6 +3229,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
3295
3229
|
pluginName: entry.plugin.manifest.name,
|
|
3296
3230
|
manifest: entry.plugin.manifest,
|
|
3297
3231
|
referencePlugins: options.runtime?.referencePlugins,
|
|
3232
|
+
catalogReadScope: executionContext.catalogReadScope,
|
|
3298
3233
|
scope,
|
|
3299
3234
|
platform,
|
|
3300
3235
|
cwd: options.commandOptions.cwd,
|
|
@@ -3467,7 +3402,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
3467
3402
|
return;
|
|
3468
3403
|
throw namespacedPreflightError('preApplyAuthorizationRequired: Running plugin preApply requires --yes or an accepted Review.', preflightTargets);
|
|
3469
3404
|
};
|
|
3470
|
-
const createCodexPlans = async (_plan, _activationSupport = 'observed', _codexManager) => [];
|
|
3471
3405
|
const operationNeedsNativeCli = async (platform, plan) => {
|
|
3472
3406
|
for (const { entry, platform: selectedPlatform } of executionSelections) {
|
|
3473
3407
|
if (selectedPlatform !== platform)
|
|
@@ -3528,16 +3462,15 @@ async function runRebuildCommandInSession(options) {
|
|
|
3528
3462
|
}
|
|
3529
3463
|
return requested;
|
|
3530
3464
|
};
|
|
3531
|
-
const prepareRenderedTargets = async (plan,
|
|
3532
|
-
const integration = createRebuildIntegration({
|
|
3533
|
-
context: executionContext,
|
|
3534
|
-
scriptTimeoutMs: options.commandOptions.scriptTimeoutMs,
|
|
3535
|
-
operationScopedNativePhases: true,
|
|
3536
|
-
});
|
|
3465
|
+
const prepareRenderedTargets = async (plan, runTargetHook) => {
|
|
3537
3466
|
const preparedTargets = new Map();
|
|
3538
3467
|
const preparedTargetErrors = new Map();
|
|
3539
3468
|
const collisionSelections = [];
|
|
3540
|
-
|
|
3469
|
+
const groupChecks = new Map();
|
|
3470
|
+
const awaitPeerRenderers = options.runtime?.previewOperationPlan ? options.runtime.awaitLockedPeerRenderers : undefined;
|
|
3471
|
+
const collectNativeChecks = !!options.runtime?.previewOperationPlan && !!executionContext.nativeObservationBatch
|
|
3472
|
+
&& (options.command === 'install' || options.command === 'sync') && (awaitPeerRenderers !== undefined || awaitSharedNativePreparation !== undefined || executionSelections.some((selection) => planTargetFor(plan, selection)?.action !== 'block' && selection.entry.plugin.manifest.scripts?.artifacts?.render));
|
|
3473
|
+
const inputs = executionSelections.flatMap((selection) => {
|
|
3541
3474
|
const planned = planTargetFor(plan, selection);
|
|
3542
3475
|
if (planned.action === 'block')
|
|
3543
3476
|
return [];
|
|
@@ -3545,7 +3478,26 @@ async function runRebuildCommandInSession(options) {
|
|
|
3545
3478
|
pluginId: selection.entry.pluginId, plugin: selection.entry.plugin, platform: selection.platform,
|
|
3546
3479
|
scope: planned.resolvedScope, cwd: options.commandOptions.cwd, command: commandForTarget(selection, plan),
|
|
3547
3480
|
catalog: toCatalogResolution(selection.entry.source) }];
|
|
3548
|
-
})
|
|
3481
|
+
});
|
|
3482
|
+
if (awaitSharedNativePreparation) {
|
|
3483
|
+
await inspection.resolvePlatformTargets(inputs, true);
|
|
3484
|
+
await awaitSharedNativePreparation();
|
|
3485
|
+
}
|
|
3486
|
+
const integration = createRebuildIntegration({
|
|
3487
|
+
context: executionContext,
|
|
3488
|
+
scriptTimeoutMs: options.commandOptions.scriptTimeoutMs,
|
|
3489
|
+
operationScopedNativePhases: true,
|
|
3490
|
+
});
|
|
3491
|
+
if (awaitSharedNativePreparation) {
|
|
3492
|
+
const reader = ordinaryContext.platformRebuildSession;
|
|
3493
|
+
try {
|
|
3494
|
+
await executionContext.platformRebuildSession.adoptOrdinaryFrom(reader, inputs);
|
|
3495
|
+
}
|
|
3496
|
+
finally {
|
|
3497
|
+
await reader.dispose();
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
await integration.resolvePlatformTargets(inputs, collectNativeChecks);
|
|
3549
3501
|
const builds = await readSelections(async (selection, observationBatch) => {
|
|
3550
3502
|
const { entry, platform } = selection;
|
|
3551
3503
|
const planned = planTargetFor(plan, selection);
|
|
@@ -3553,15 +3505,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
3553
3505
|
if (planned.action === 'block')
|
|
3554
3506
|
return;
|
|
3555
3507
|
const buildCommand = commandForTarget(selection, plan);
|
|
3556
|
-
const plannedNative = platform === 'codex'
|
|
3557
|
-
? codexPlans.flatMap((codexPlan) => codexPlan.sharedNativeActions).find((action) => action.pluginId === entry.pluginId)
|
|
3558
|
-
: undefined;
|
|
3559
|
-
const codexNativeStillDesired = platform === 'codex'
|
|
3560
|
-
&& codexPlans.some((codexPlan) => codexPlan.desiredTargets.some((target) => target.pluginId === entry.pluginId && target.scopes.length > 0));
|
|
3561
|
-
const preserveSharedNative = plannedNative?.action === 'reuse'
|
|
3562
|
-
|| (plannedNative?.action === 'none' && codexNativeStillDesired)
|
|
3563
|
-
|| options.command === 'cleanup'
|
|
3564
|
-
|| options.command === 'uninstall';
|
|
3565
3508
|
const marketplaceName = getNamespacedMarketplaceName(entry.source.sourceId);
|
|
3566
3509
|
try {
|
|
3567
3510
|
const target = await measureCommandPerformanceStage(options.runtime, 'target.build', () => integration.buildTarget({
|
|
@@ -3576,57 +3519,10 @@ async function runRebuildCommandInSession(options) {
|
|
|
3576
3519
|
cwd: options.commandOptions.cwd,
|
|
3577
3520
|
command: buildCommand,
|
|
3578
3521
|
observationBatch,
|
|
3522
|
+
afterGroupRender: collectNativeChecks ? (verify) => groupChecks.set(key, verify) : undefined,
|
|
3523
|
+
combinePostRenderSeal: options.runtime?.singleLockedSync && !awaitSharedNativePreparation && inputs.length === 1,
|
|
3579
3524
|
catalog: toCatalogResolution(entry.source),
|
|
3580
|
-
...(platform === 'codex'
|
|
3581
|
-
&& (buildCommand === 'cleanup' || buildCommand === 'uninstall')
|
|
3582
|
-
? { includeNativeCleanupCandidate: false }
|
|
3583
|
-
: {}),
|
|
3584
3525
|
}));
|
|
3585
|
-
if (plannedNative) {
|
|
3586
|
-
const writesSharedNative = plannedNative.action === 'install'
|
|
3587
|
-
|| plannedNative.action === 'replace'
|
|
3588
|
-
|| plannedNative.action === 'repair';
|
|
3589
|
-
const isActivationComponent = (component) => component.kind === 'shared-config'
|
|
3590
|
-
&& component.locator.kind === 'codex-activation';
|
|
3591
|
-
const activationArtifactKeys = new Set(target.ownedComponents
|
|
3592
|
-
.filter(isActivationComponent)
|
|
3593
|
-
.map((component) => component.identity.artifactKey));
|
|
3594
|
-
target.ownedComponents = target.ownedComponents.filter((component) => !isActivationComponent(component));
|
|
3595
|
-
target.desiredOwnedComponents = target.desiredOwnedComponents?.filter((component) => !isActivationComponent(component));
|
|
3596
|
-
target.optionalOwnedComponents = target.optionalOwnedComponents?.filter((component) => !isActivationComponent(component));
|
|
3597
|
-
target.artifacts = target.artifacts.filter((artifact) => artifact.artifactKey === undefined
|
|
3598
|
-
|| !activationArtifactKeys.has(artifact.artifactKey));
|
|
3599
|
-
target.operationActions = target.operationActions?.filter((action) => action.kind !== 'setActivation');
|
|
3600
|
-
target.writeNativeRequired = writesSharedNative;
|
|
3601
|
-
const hasExtensionMutation = codexPlans.some((codexPlan) => [
|
|
3602
|
-
...codexPlan.extensionWrites,
|
|
3603
|
-
...codexPlan.extensionRemovals,
|
|
3604
|
-
].some((action) => action.pluginId === entry.pluginId
|
|
3605
|
-
&& action.scope === planned.resolvedScope));
|
|
3606
|
-
const hasActivationMutation = codexPlans.some((codexPlan) => [
|
|
3607
|
-
...codexPlan.activationActions.user,
|
|
3608
|
-
...codexPlan.activationActions.project,
|
|
3609
|
-
].some((action) => action.pluginId === entry.pluginId
|
|
3610
|
-
&& action.action !== 'none'));
|
|
3611
|
-
target.codexNativeObservationExpectation = preserveSharedNative && hasExtensionMutation
|
|
3612
|
-
? (plannedNative.action === 'reuse' ? 'installed' : 'observed')
|
|
3613
|
-
: undefined;
|
|
3614
|
-
target.codexNativeSensitivePreflightRequired = preserveSharedNative
|
|
3615
|
-
&& hasActivationMutation;
|
|
3616
|
-
if (!writesSharedNative) {
|
|
3617
|
-
const isSharedNativeComponent = (component) => component.kind === 'native-plugin'
|
|
3618
|
-
|| (component.kind === 'shared-config'
|
|
3619
|
-
&& component.identity.artifactKey.startsWith('marketplace-'));
|
|
3620
|
-
target.requiresNative = false;
|
|
3621
|
-
target.ownedComponents = target.ownedComponents.filter((component) => !isSharedNativeComponent(component));
|
|
3622
|
-
target.desiredOwnedComponents = target.desiredOwnedComponents?.filter((component) => !isSharedNativeComponent(component));
|
|
3623
|
-
target.optionalOwnedComponents = target.optionalOwnedComponents?.filter((component) => !isSharedNativeComponent(component));
|
|
3624
|
-
target.operationActions = target.operationActions?.filter((action) => action.kind !== 'ensureNativeRegistration');
|
|
3625
|
-
}
|
|
3626
|
-
if (target.codexNativeSensitivePreflightRequired && !hasExtensionMutation) {
|
|
3627
|
-
await integration.driver.preflightMutation?.(target);
|
|
3628
|
-
}
|
|
3629
|
-
}
|
|
3630
3526
|
if (runTargetHook) {
|
|
3631
3527
|
await rebuildCommandTestHooks?.afterTargetBuilt?.({
|
|
3632
3528
|
command: selection.requestedMethod ?? options.command,
|
|
@@ -3660,8 +3556,26 @@ async function runRebuildCommandInSession(options) {
|
|
|
3660
3556
|
return { key, error };
|
|
3661
3557
|
}
|
|
3662
3558
|
});
|
|
3559
|
+
if (awaitPeerRenderers)
|
|
3560
|
+
await awaitPeerRenderers();
|
|
3561
|
+
if (groupChecks.size)
|
|
3562
|
+
await mapInstallReads(builds, async (build) => {
|
|
3563
|
+
if (!build?.target)
|
|
3564
|
+
return;
|
|
3565
|
+
const check = groupChecks.get(build.key);
|
|
3566
|
+
if (!check)
|
|
3567
|
+
return;
|
|
3568
|
+
try {
|
|
3569
|
+
await check();
|
|
3570
|
+
}
|
|
3571
|
+
catch (error) {
|
|
3572
|
+
if (recoveryInterruptionCode(error, executionContext.signal) || readSafeOperationError(error))
|
|
3573
|
+
throw error;
|
|
3574
|
+
preparedTargetErrors.set(build.key, error);
|
|
3575
|
+
}
|
|
3576
|
+
}, { signal: executionContext.signal });
|
|
3663
3577
|
for (const build of builds) {
|
|
3664
|
-
if (!build)
|
|
3578
|
+
if (!build || preparedTargetErrors.has(build.key))
|
|
3665
3579
|
continue;
|
|
3666
3580
|
if (build.target) {
|
|
3667
3581
|
preparedTargets.set(build.key, { target: build.target });
|
|
@@ -3711,6 +3625,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
3711
3625
|
pluginName: entry.plugin.manifest.name,
|
|
3712
3626
|
manifest: entry.plugin.manifest,
|
|
3713
3627
|
referencePlugins: options.runtime?.referencePlugins,
|
|
3628
|
+
catalogReadScope: executionContext.catalogReadScope,
|
|
3714
3629
|
targetScope: scope,
|
|
3715
3630
|
platform,
|
|
3716
3631
|
cwd: options.commandOptions.cwd,
|
|
@@ -3723,9 +3638,11 @@ async function runRebuildCommandInSession(options) {
|
|
|
3723
3638
|
effectiveValues: effective.values,
|
|
3724
3639
|
});
|
|
3725
3640
|
}));
|
|
3641
|
+
const nativePreviewEpoch = executionContext.nativeObservationBatch?.writeEpoch;
|
|
3642
|
+
const sealInputEpoch = executionContext.awHomeMutationToken && awHomeMutationEpoch(executionContext.awHomeMutationToken, 'inputs');
|
|
3726
3643
|
await integration.sealMarketplaceGenerations([...preparedTargets.values()].map(({ target }) => target));
|
|
3727
3644
|
return {
|
|
3728
|
-
integration,
|
|
3645
|
+
integration, nativePreviewEpoch, sealInputEpoch,
|
|
3729
3646
|
deploymentPlans: [...preparedTargets.values()].flatMap(({ target }) => target.platformDeployment?.plans ?? []),
|
|
3730
3647
|
deploymentExclusions: [...[...preparedTargets.values()].flatMap(({ target }) => target.deploymentExclusions ?? []),
|
|
3731
3648
|
...[...preparedTargetErrors.values()].flatMap(deploymentExclusionsFromError)],
|
|
@@ -3736,7 +3653,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
3736
3653
|
};
|
|
3737
3654
|
};
|
|
3738
3655
|
if (options.runtime?.resolvePreApplyAuthorization) {
|
|
3739
|
-
const authorizationPlan = await measureCommandPerformanceStage(options.runtime, 'dependency.plan', () => createPlan(stateInventory,
|
|
3656
|
+
const authorizationPlan = await measureCommandPerformanceStage(options.runtime, 'dependency.plan', () => createPlan(stateInventory, { skipConfigValidation: true }));
|
|
3740
3657
|
assertWriteInventoryComplete(stateInventory, exactOwnedTextTargets(authorizationPlan), exactSkillMarkerTargets(authorizationPlan));
|
|
3741
3658
|
const preview = mergeRebuildCommandResults([]);
|
|
3742
3659
|
preview.dependencyPlan = authorizationPlan;
|
|
@@ -3747,11 +3664,10 @@ async function runRebuildCommandInSession(options) {
|
|
|
3747
3664
|
await options.runtime.onPreviewStage?.('dependencyPlan');
|
|
3748
3665
|
const initialPlan = await measureCommandPerformanceStage(options.runtime, 'dependency.plan', () => createPlan(stateInventory));
|
|
3749
3666
|
assertWriteInventoryComplete(stateInventory, exactOwnedTextTargets(initialPlan), exactSkillMarkerTargets(initialPlan));
|
|
3750
|
-
const
|
|
3751
|
-
const initialCodexPlans = provisionalCodexPlans;
|
|
3752
|
-
const previewPreparation = await prepareRenderedTargets(initialPlan, initialCodexPlans, false);
|
|
3667
|
+
const previewPreparation = await prepareRenderedTargets(initialPlan, false);
|
|
3753
3668
|
const preview = mergeRebuildCommandResults([]);
|
|
3754
3669
|
preview.dependencyPlan = initialPlan;
|
|
3670
|
+
preview.nativePreviewEpoch = previewPreparation.nativePreviewEpoch;
|
|
3755
3671
|
preview.preApplyAuthorization = preApplyAuthorizationForPlan(initialPlan, previewPreparation.preparedTargets);
|
|
3756
3672
|
const blockedTargets = [...previewPreparation.preparedTargets.values()].flatMap(({ target }) => {
|
|
3757
3673
|
const receipts = target.platformDeployment?.blockedReceipts ?? [];
|
|
@@ -3784,27 +3700,38 @@ async function runRebuildCommandInSession(options) {
|
|
|
3784
3700
|
}));
|
|
3785
3701
|
}
|
|
3786
3702
|
preview.nativeFootprints = preparedNativeFootprints([...previewPreparation.preparedTargets.values()].map((entry) => entry.target));
|
|
3787
|
-
|
|
3703
|
+
const operationPlanFor = (targetActions, deploymentPlans) => createRebuildOperationPlan({
|
|
3788
3704
|
dependencyPlan: initialPlan,
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
deploymentPlans: previewPreparation.deploymentPlans,
|
|
3705
|
+
targetActions,
|
|
3706
|
+
deploymentPlans,
|
|
3792
3707
|
deploymentExclusions: previewPreparation.deploymentExclusions,
|
|
3793
3708
|
catalogSources: catalog.sources.flatMap((source) => source.resolution ? [source.resolution] : []),
|
|
3794
3709
|
requirements,
|
|
3795
3710
|
scope: options.commandOptions.scope,
|
|
3796
3711
|
configDigests: previewPreparation.configDigests,
|
|
3797
3712
|
});
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3713
|
+
preview.operationPlan = operationPlanFor(previewPreparation.targetActions, previewPreparation.deploymentPlans);
|
|
3714
|
+
if (options.runtime.nativeObservationBatch && catalogOperation) {
|
|
3715
|
+
const batch = options.runtime.nativeObservationBatch;
|
|
3716
|
+
const group = { ...previewPreparation, dependencyPlan: initialPlan,
|
|
3717
|
+
ownedTextTargets: exactOwnedTextTargets(initialPlan), skillMarkerTargets: exactSkillMarkerTargets(initialPlan) };
|
|
3718
|
+
if (batch.phase === 'locked-execution')
|
|
3719
|
+
preparedGroupForReview = group;
|
|
3720
|
+
refreshSealedPreview = async (reviewed) => {
|
|
3721
|
+
const targets = [...group.preparedTargets.values()].map(({ target }) => target);
|
|
3722
|
+
const targetActions = targets.flatMap((target) => target.operationActions ?? []);
|
|
3723
|
+
const deploymentPlans = targets.flatMap((target) => target.platformDeployment?.plans ?? []);
|
|
3724
|
+
const operationPlan = operationPlanFor(targetActions, deploymentPlans);
|
|
3725
|
+
if (operationPlan.planFingerprint === reviewed.operationPlan.planFingerprint)
|
|
3726
|
+
return reviewed;
|
|
3727
|
+
const next = await withResolvedMultiSourceCatalog({
|
|
3728
|
+
cliVersion: resolveRuntimeCliVersion(), operationContext: catalogOperation, env: runtimeEnv,
|
|
3729
|
+
signal: options.runtime?.signal, consume: async () => ({ operationPlan,
|
|
3730
|
+
nativeFootprints: preparedNativeFootprints(targets), preApplyAuthorization: preApplyAuthorizationForPlan(initialPlan, group.preparedTargets) }),
|
|
3731
|
+
});
|
|
3732
|
+
LockedPreparedExecution.retainGroup(batch, next.operationPlan, { ...group, targetActions, deploymentPlans });
|
|
3733
|
+
return { ...reviewed, ...next };
|
|
3734
|
+
};
|
|
3808
3735
|
}
|
|
3809
3736
|
return preview;
|
|
3810
3737
|
}
|
|
@@ -3834,18 +3761,16 @@ async function runRebuildCommandInSession(options) {
|
|
|
3834
3761
|
contentDigest: entry.source.manifest.entries.find((candidate) => candidate.name === entry.plugin.manifest.name)?.contentDigest,
|
|
3835
3762
|
});
|
|
3836
3763
|
}
|
|
3837
|
-
let lockedPlan = await measureCommandPerformanceStage(options.runtime, 'dependency.plan', () => createPlan(stateInventory));
|
|
3838
|
-
assertWriteInventoryComplete(stateInventory, exactOwnedTextTargets(lockedPlan), exactSkillMarkerTargets(lockedPlan));
|
|
3764
|
+
let lockedPlan = preparedGroup?.dependencyPlan ?? await measureCommandPerformanceStage(options.runtime, 'dependency.plan', () => createPlan(stateInventory));
|
|
3765
|
+
assertWriteInventoryComplete(stateInventory, preparedGroup?.ownedTextTargets ?? exactOwnedTextTargets(lockedPlan), preparedGroup?.skillMarkerTargets ?? exactSkillMarkerTargets(lockedPlan));
|
|
3839
3766
|
assertPreApplyAuthorization(lockedPlan);
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
let lockedPreparation = await prepareRenderedTargets(lockedPlan, lockedCodexPlans, true);
|
|
3767
|
+
let lockedPreparation = preparedGroup
|
|
3768
|
+
? { ...preparedGroup, integration: createRebuildIntegration({ context: executionContext,
|
|
3769
|
+
scriptTimeoutMs: options.commandOptions.scriptTimeoutMs, operationScopedNativePhases: true,
|
|
3770
|
+
preparedTargets: [...preparedGroup.preparedTargets.values()].map(({ target }) => target) }) }
|
|
3771
|
+
: await prepareRenderedTargets(lockedPlan, true);
|
|
3846
3772
|
let lockedOperationPlan = createRebuildOperationPlan({
|
|
3847
3773
|
dependencyPlan: lockedPlan,
|
|
3848
|
-
codexPlans: lockedCodexPlans,
|
|
3849
3774
|
targetActions: lockedPreparation.targetActions,
|
|
3850
3775
|
deploymentPlans: lockedPreparation.deploymentPlans,
|
|
3851
3776
|
deploymentExclusions: lockedPreparation.deploymentExclusions,
|
|
@@ -3866,8 +3791,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
3866
3791
|
if (options.runtime?.directCli
|
|
3867
3792
|
&& options.commandOptions.yes !== true
|
|
3868
3793
|
&& lifecycleCommand) {
|
|
3869
|
-
const sharedNativeImpact =
|
|
3870
|
-
|| (lockedOperationPlan.deploymentPlans ?? []).some((plan) => deploymentConfirmationEffects(plan).some((effect) => effect.impact === 'shared'));
|
|
3794
|
+
const sharedNativeImpact = (lockedOperationPlan.deploymentPlans ?? []).some((plan) => deploymentConfirmationEffects(plan).some((effect) => effect.impact === 'shared'));
|
|
3871
3795
|
if (sharedNativeImpact) {
|
|
3872
3796
|
throw namespacedPreflightError('sharedNativeImpactAuthorizationRequired: Replacing or force-reinstalling shared native state requires --yes.', preflightTargets);
|
|
3873
3797
|
}
|
|
@@ -3887,18 +3811,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
3887
3811
|
const deferredPreApply = new Set();
|
|
3888
3812
|
let serialScriptGeneration = 0;
|
|
3889
3813
|
const currentGeneration = () => admission?.exclusiveGeneration ?? serialScriptGeneration;
|
|
3890
|
-
let observationGeneration = initialGeneration;
|
|
3891
|
-
const refreshCodexObservation = (includeSerial = false) => {
|
|
3892
|
-
if (!admission && !includeSerial)
|
|
3893
|
-
return;
|
|
3894
|
-
const generation = currentGeneration();
|
|
3895
|
-
if (observationGeneration === generation)
|
|
3896
|
-
return;
|
|
3897
|
-
executionContext.codexObservationSession?.invalidate();
|
|
3898
|
-
observationGeneration = generation;
|
|
3899
|
-
};
|
|
3900
3814
|
const prepareOperation = async (input) => {
|
|
3901
|
-
refreshCodexObservation();
|
|
3902
3815
|
const prepared = await prepareRebuildOperation({ ...input, onActionEvent: async (event) => {
|
|
3903
3816
|
if (event.data.name === 'preApply' && event.data.phase === 'start') {
|
|
3904
3817
|
if (!admission)
|
|
@@ -3929,7 +3842,17 @@ async function runRebuildCommandInSession(options) {
|
|
|
3929
3842
|
scriptTimeoutMs: options.commandOptions.scriptTimeoutMs,
|
|
3930
3843
|
preparedTargets: [...lockedPreparation.preparedTargets.values()].map((entry) => entry.target),
|
|
3931
3844
|
});
|
|
3932
|
-
|
|
3845
|
+
const hookPhase = !preparationOptions.skipPreApply && !preparationOptions.eligibleKeys ? options.runtime?.rootHookPhase : undefined;
|
|
3846
|
+
const independentHooks = hookPhase ? executionSelections.filter((selection) => {
|
|
3847
|
+
const target = lockedPreparation.preparedTargets.get(executionKey(selection, lockedPlan))?.target;
|
|
3848
|
+
return target && !selection.entry.plugin.manifest.dependencies?.length && hasPlannedPreApply(target);
|
|
3849
|
+
}) : [];
|
|
3850
|
+
const hooks = new Set(independentHooks);
|
|
3851
|
+
const ordered = hookPhase ? [...independentHooks, ...executionSelections.filter((selection) => !hooks.has(selection))] : executionSelections;
|
|
3852
|
+
await hookPhase?.before();
|
|
3853
|
+
for (const [index, selection] of ordered.entries()) {
|
|
3854
|
+
if (index === independentHooks.length)
|
|
3855
|
+
await hookPhase?.after();
|
|
3933
3856
|
const { entry, platform } = selection;
|
|
3934
3857
|
const key = executionKey(selection, lockedPlan);
|
|
3935
3858
|
const planned = planTargetFor(lockedPlan, selection);
|
|
@@ -3997,12 +3920,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
3997
3920
|
target: prepared.target,
|
|
3998
3921
|
driver: integration.driver,
|
|
3999
3922
|
skipPreApply,
|
|
4000
|
-
...(preparationOptions.deferCodexNativeInspection
|
|
4001
|
-
&& platform === 'codex'
|
|
4002
|
-
&& executionContext.codexManager === undefined
|
|
4003
|
-
&& (prepared.target.writeNativeRequired ?? prepared.target.requiresNative)
|
|
4004
|
-
? { deferNativeInspection: true }
|
|
4005
|
-
: {}),
|
|
4006
3923
|
});
|
|
4007
3924
|
const preparedOperation = admission && hasScript && !skipPreApply
|
|
4008
3925
|
? await admission.run([{ kind: 'exclusive' }], prepare, executionContext.signal) : await prepare();
|
|
@@ -4014,12 +3931,12 @@ async function runRebuildCommandInSession(options) {
|
|
|
4014
3931
|
preparations.set(key, preparedOperation.preparation);
|
|
4015
3932
|
states.set(key, 'ready');
|
|
4016
3933
|
}
|
|
3934
|
+
if (ordered.length === independentHooks.length)
|
|
3935
|
+
await hookPhase?.after();
|
|
4017
3936
|
return { preparations, failures };
|
|
4018
3937
|
};
|
|
4019
3938
|
if (lifecycleCommand) {
|
|
4020
|
-
const initialPreparation = await prepareLockedTargets({
|
|
4021
|
-
deferCodexNativeInspection: codexManagerRequired,
|
|
4022
|
-
});
|
|
3939
|
+
const initialPreparation = await prepareLockedTargets({});
|
|
4023
3940
|
for (const [key, preparation] of initialPreparation.preparations) {
|
|
4024
3941
|
operationPreparations.set(key, preparation);
|
|
4025
3942
|
}
|
|
@@ -4030,21 +3947,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
4030
3947
|
&& (preparation.target.writeNativeRequired ?? preparation.target.requiresNative)
|
|
4031
3948
|
? [key]
|
|
4032
3949
|
: []));
|
|
4033
|
-
const activationPluginIds = new Set(provisionalLockedCodexPlans.flatMap((plan) => plan.postcheck.plugins.map((plugin) => plugin.pluginId)));
|
|
4034
|
-
const activationPreparationKeys = new Set([...operationPreparations].flatMap(([key, preparation]) => preparation.target.identity.platform === 'codex'
|
|
4035
|
-
&& preparation.target.identity.pluginId
|
|
4036
|
-
&& activationPluginIds.has(preparation.target.identity.pluginId)
|
|
4037
|
-
? [key]
|
|
4038
|
-
: []));
|
|
4039
|
-
const codexRequirementScopeFor = (keys) => {
|
|
4040
|
-
const pluginIds = new Set([...keys].flatMap((key) => {
|
|
4041
|
-
const pluginId = operationPreparations.get(key)?.target.identity.pluginId;
|
|
4042
|
-
return pluginId ? [pluginId] : [];
|
|
4043
|
-
}));
|
|
4044
|
-
return provisionalLockedCodexPlans.some((plan) => plan.desiredTargets.some((target) => pluginIds.has(target.pluginId) && target.scopes.includes('project')))
|
|
4045
|
-
? 'project'
|
|
4046
|
-
: 'user';
|
|
4047
|
-
};
|
|
4048
3950
|
let refreshCodexNativePlan = false;
|
|
4049
3951
|
const failPreparedTargets = (keys, error) => {
|
|
4050
3952
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -4059,13 +3961,14 @@ async function runRebuildCommandInSession(options) {
|
|
|
4059
3961
|
if (executionContext.codexManager === undefined
|
|
4060
3962
|
&& nativePreparationKeys.size > 0) {
|
|
4061
3963
|
try {
|
|
3964
|
+
const requirement = getCodexOperationRequirement([...nativePreparationKeys].some((key) => operationPreparations.get(key)?.target.identity.scope === 'project') ? 'project' : 'user');
|
|
4062
3965
|
if (options.runtime?.codexManagerResolver) {
|
|
4063
3966
|
executionContext.codexManager = await options.runtime.codexManagerResolver({
|
|
4064
3967
|
cwd: options.commandOptions.cwd,
|
|
4065
3968
|
env: runtimeEnv,
|
|
4066
3969
|
runner: executionContext.nativeCliRunner,
|
|
4067
3970
|
signal: options.runtime?.signal,
|
|
4068
|
-
operationRequirement:
|
|
3971
|
+
operationRequirement: requirement,
|
|
4069
3972
|
});
|
|
4070
3973
|
}
|
|
4071
3974
|
else {
|
|
@@ -4074,7 +3977,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
4074
3977
|
env: runtimeEnv,
|
|
4075
3978
|
runner: executionContext.nativeCliRunner,
|
|
4076
3979
|
signal: options.runtime?.signal,
|
|
4077
|
-
operationRequirement:
|
|
3980
|
+
operationRequirement: requirement,
|
|
4078
3981
|
});
|
|
4079
3982
|
if (consumer.support !== 'observed') {
|
|
4080
3983
|
throw new Error('Codex native materialization requires an observed CLI consumer.');
|
|
@@ -4087,34 +3990,13 @@ async function runRebuildCommandInSession(options) {
|
|
|
4087
3990
|
failPreparedTargets(nativePreparationKeys, error);
|
|
4088
3991
|
}
|
|
4089
3992
|
}
|
|
4090
|
-
else if (executionContext.codexManager === undefined
|
|
4091
|
-
&& activationPreparationKeys.size > 0) {
|
|
4092
|
-
try {
|
|
4093
|
-
const consumer = await (options.runtime?.codexOperationConsumerResolver ?? resolveCodexOperationConsumer)({
|
|
4094
|
-
cwd: options.commandOptions.cwd,
|
|
4095
|
-
env: runtimeEnv,
|
|
4096
|
-
runner: executionContext.nativeCliRunner,
|
|
4097
|
-
signal: options.runtime?.signal,
|
|
4098
|
-
operationRequirement: getCodexOperationRequirement(codexRequirementScopeFor(activationPreparationKeys)),
|
|
4099
|
-
});
|
|
4100
|
-
executionContext.codexManager = consumer.manager;
|
|
4101
|
-
refreshCodexNativePlan = true;
|
|
4102
|
-
}
|
|
4103
|
-
catch (error) {
|
|
4104
|
-
failPreparedTargets(activationPreparationKeys, error);
|
|
4105
|
-
}
|
|
4106
|
-
}
|
|
4107
|
-
if (executionContext.codexManager) {
|
|
4108
|
-
executionContext.codexObservationSession?.setManager(executionContext.codexManager);
|
|
4109
|
-
}
|
|
4110
3993
|
if (refreshCodexNativePlan) {
|
|
4111
3994
|
if (executionContext.codexManager) {
|
|
4112
|
-
lockedPlan = await createPlan(stateInventory
|
|
3995
|
+
lockedPlan = await createPlan(stateInventory);
|
|
4113
3996
|
assertWriteInventoryComplete(stateInventory, exactOwnedTextTargets(lockedPlan), exactSkillMarkerTargets(lockedPlan));
|
|
4114
3997
|
}
|
|
4115
|
-
lockedCodexPlans = await createCodexPlans(lockedPlan, 'observed', executionContext.codexManager);
|
|
4116
3998
|
assertPreApplyAuthorization(lockedPlan);
|
|
4117
|
-
lockedPreparation = await prepareRenderedTargets(lockedPlan,
|
|
3999
|
+
lockedPreparation = await prepareRenderedTargets(lockedPlan, false);
|
|
4118
4000
|
const eligibleKeys = new Set(operationPreparations.keys());
|
|
4119
4001
|
const initialOperationPreparations = new Map(operationPreparations);
|
|
4120
4002
|
const finalPreparation = await prepareLockedTargets({
|
|
@@ -4143,7 +4025,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
4143
4025
|
}
|
|
4144
4026
|
lockedOperationPlan = createRebuildOperationPlan({
|
|
4145
4027
|
dependencyPlan: lockedPlan,
|
|
4146
|
-
codexPlans: lockedCodexPlans,
|
|
4147
4028
|
targetActions: lockedPreparation.targetActions,
|
|
4148
4029
|
deploymentPlans: lockedPreparation.deploymentPlans,
|
|
4149
4030
|
deploymentExclusions: lockedPreparation.deploymentExclusions,
|
|
@@ -4159,8 +4040,7 @@ async function runRebuildCommandInSession(options) {
|
|
|
4159
4040
|
if (options.runtime?.directCli
|
|
4160
4041
|
&& options.commandOptions.yes !== true
|
|
4161
4042
|
&& lifecycleCommand
|
|
4162
|
-
&& (
|
|
4163
|
-
|| (lockedOperationPlan.deploymentPlans ?? []).some((plan) => deploymentConfirmationEffects(plan).some((effect) => effect.impact === 'shared')))) {
|
|
4043
|
+
&& (lockedOperationPlan.deploymentPlans ?? []).some((plan) => deploymentConfirmationEffects(plan).some((effect) => effect.impact === 'shared'))) {
|
|
4164
4044
|
throw namespacedPreflightError('sharedNativeImpactAuthorizationRequired: Replacing or force-reinstalling shared native state requires --yes.', preflightTargets);
|
|
4165
4045
|
}
|
|
4166
4046
|
if (options.command !== 'cleanup'
|
|
@@ -4220,7 +4100,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
4220
4100
|
}
|
|
4221
4101
|
executionContext.codexManager = consumer.manager;
|
|
4222
4102
|
}
|
|
4223
|
-
executionContext.codexObservationSession?.setManager(executionContext.codexManager);
|
|
4224
4103
|
}
|
|
4225
4104
|
catch (error) {
|
|
4226
4105
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -4278,13 +4157,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
4278
4157
|
executionContext.signal?.throwIfAborted();
|
|
4279
4158
|
failClaudeTargets(error);
|
|
4280
4159
|
}
|
|
4281
|
-
const codexUserActivationDesired = new Set(lockedCodexPlans.flatMap((plan) => plan.activationActions.user.flatMap((action) => action.desired ? [action.codexPluginId] : [])));
|
|
4282
|
-
executionContext.codexUserActivationDesired = codexUserActivationDesired;
|
|
4283
|
-
const originalUserActivations = options.commandOptions.scope === 'project'
|
|
4284
|
-
&& lockedCodexPlans.length > 0
|
|
4285
|
-
? new Map(Object.entries((await readCodexConfigFile(resolveCodexPaths(options.commandOptions.cwd, 'user', runtimeEnv).configTomlPath)).snapshot.plugins)
|
|
4286
|
-
.map(([pluginId, activation]) => [pluginId, activation.enabled === true]))
|
|
4287
|
-
: undefined;
|
|
4288
4160
|
const preparedTargets = lockedPreparation.preparedTargets;
|
|
4289
4161
|
const preparedTargetErrors = lockedPreparation.preparedTargetErrors;
|
|
4290
4162
|
const removalRequiredConsumers = new Map();
|
|
@@ -4482,7 +4354,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
4482
4354
|
if (generation === initialGeneration || !directProviders.get(key)?.length
|
|
4483
4355
|
|| !target || !providersReady(key) || operationPreparationFailures.has(key))
|
|
4484
4356
|
return;
|
|
4485
|
-
refreshCodexObservation(true);
|
|
4486
4357
|
for (const provider of providerClosure(key)) {
|
|
4487
4358
|
if (verifiedGenerations.get(provider) === generation)
|
|
4488
4359
|
continue;
|
|
@@ -4541,19 +4412,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
4541
4412
|
return state === 'failed' || state === 'skipped';
|
|
4542
4413
|
});
|
|
4543
4414
|
const identity = targetIdentity(selection, planned.resolvedScope);
|
|
4544
|
-
const codexReconcilePlan = platform === 'codex'
|
|
4545
|
-
? lockedCodexPlans.find((plan) => plan.desiredTargets.some((target) => target.pluginId === entry.pluginId))
|
|
4546
|
-
: undefined;
|
|
4547
|
-
const plannedNativeAction = codexReconcilePlan?.sharedNativeActions.find((action) => action.pluginId === entry.pluginId);
|
|
4548
|
-
const hasCodexExtensionMutation = codexReconcilePlan !== undefined
|
|
4549
|
-
&& [...codexReconcilePlan.extensionWrites, ...codexReconcilePlan.extensionRemovals]
|
|
4550
|
-
.some((action) => action.pluginId === entry.pluginId);
|
|
4551
|
-
const reconcileActivationOnly = platform === 'codex'
|
|
4552
|
-
&& plannedNativeAction !== undefined
|
|
4553
|
-
&& (plannedNativeAction.action === 'reuse'
|
|
4554
|
-
|| plannedNativeAction.action === 'none')
|
|
4555
|
-
&& !hasCodexExtensionMutation
|
|
4556
|
-
&& !lockedPreparation.preparedTargets.get(key)?.target.ownedComponents.some((component) => component.kind === 'native-plugin');
|
|
4557
4415
|
if (failedDependency || failedConsumer || planned.action === 'block') {
|
|
4558
4416
|
const code = failedConsumer
|
|
4559
4417
|
? 'dependencyStillRequired'
|
|
@@ -4597,13 +4455,22 @@ async function runRebuildCommandInSession(options) {
|
|
|
4597
4455
|
dependencyStates.set(key, failedDependency || failedConsumer ? 'skipped' : 'failed');
|
|
4598
4456
|
return;
|
|
4599
4457
|
}
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4458
|
+
const keptTarget = preparedTargets.get(key)?.target;
|
|
4459
|
+
const keptDeployment = keptTarget?.platformDeployment;
|
|
4460
|
+
// A healthy dependency retained by Codex placement is outside the
|
|
4461
|
+
// requested update. Preserve its package bytes and scope activation.
|
|
4462
|
+
const retainedCodexProvider = platform === 'codex' && planned.relation === 'dependency'
|
|
4463
|
+
&& planned.state === 'present' && keptTarget?.operationActions?.length === 0;
|
|
4464
|
+
// The joint publisher can run before the host driver, including for a healthy wider provider.
|
|
4465
|
+
const publishesCommands = nativeTargetExecution && (nativeTargetExecution.produces?.(identity) ?? true);
|
|
4466
|
+
const recheckRetained = planned.action === 'keep' && (admission || providerKeys.has(key))
|
|
4467
|
+
&& currentGeneration() !== initialGeneration;
|
|
4468
|
+
const requiresEarlyExecutionCheck = keptDeployment?.combinedPostRenderSeal
|
|
4469
|
+
&& (isHealthyWiderDependency(planned) || planned.action === 'keep' && await keptDeployment.canSettleWithoutWrites?.());
|
|
4470
|
+
if ((publishesCommands || retainedCodexProvider || recheckRetained || requiresEarlyExecutionCheck) && !operationPreparationFailures.has(key)) {
|
|
4605
4471
|
try {
|
|
4606
|
-
|
|
4472
|
+
if (publishesCommands || retainedCodexProvider)
|
|
4473
|
+
executionContext.nativeObservationBatch?.refreshExecutionInspection(platform);
|
|
4607
4474
|
await preparedTargets.get(key)?.target.platformDeployment?.verify();
|
|
4608
4475
|
}
|
|
4609
4476
|
catch (error) {
|
|
@@ -4677,62 +4544,8 @@ async function runRebuildCommandInSession(options) {
|
|
|
4677
4544
|
return;
|
|
4678
4545
|
}
|
|
4679
4546
|
}
|
|
4680
|
-
if (reconcileActivationOnly) {
|
|
4681
|
-
const preparedError = preparedTargetErrors.get(key);
|
|
4682
|
-
if (preparedError) {
|
|
4683
|
-
const message = preparedError instanceof Error
|
|
4684
|
-
? preparedError.message
|
|
4685
|
-
: String(preparedError);
|
|
4686
|
-
const result = failedResult(requestedMethod, identity, message);
|
|
4687
|
-
record({
|
|
4688
|
-
platforms: [platform], plugins: [], warnings: [], rebuildResults: [result],
|
|
4689
|
-
targetResults: [{
|
|
4690
|
-
target: identity,
|
|
4691
|
-
action: planned.action,
|
|
4692
|
-
state: 'failed',
|
|
4693
|
-
errorCode: message.split(':', 1)[0] ?? 'targetPreparationFailed',
|
|
4694
|
-
message,
|
|
4695
|
-
}],
|
|
4696
|
-
overallState: 'failed',
|
|
4697
|
-
receiptTargets: [{
|
|
4698
|
-
pluginName: identity.pluginName, pluginId: identity.pluginId,
|
|
4699
|
-
sourceId: identity.sourceId, platform, scope: planned.resolvedScope,
|
|
4700
|
-
}],
|
|
4701
|
-
});
|
|
4702
|
-
dependencyStates.set(key, 'failed');
|
|
4703
|
-
return;
|
|
4704
|
-
}
|
|
4705
|
-
const actions = operationPreparations.get(key)?.actions
|
|
4706
|
-
?? [];
|
|
4707
|
-
let result;
|
|
4708
|
-
result ??= {
|
|
4709
|
-
status: 'succeeded', command: requestedMethod, target: identity,
|
|
4710
|
-
actions,
|
|
4711
|
-
cleanupAttempted: false, removed: [], absent: [], residual: [], quarantined: [], failures: [],
|
|
4712
|
-
};
|
|
4713
|
-
record({
|
|
4714
|
-
platforms: [platform],
|
|
4715
|
-
plugins: result.status === 'succeeded' ? [identity.pluginName] : [],
|
|
4716
|
-
warnings: result.failures.map((failure) => failure.message),
|
|
4717
|
-
rebuildResults: [result],
|
|
4718
|
-
targetResults: [{
|
|
4719
|
-
...toTargetResult(result),
|
|
4720
|
-
action: result.status === 'succeeded' && result.removed.length === 0
|
|
4721
|
-
&& codexReconcilePlan
|
|
4722
|
-
&& [...codexReconcilePlan.activationActions.user,
|
|
4723
|
-
...codexReconcilePlan.activationActions.project].every((action) => action.pluginId !== entry.pluginId || action.action === 'none')
|
|
4724
|
-
? 'keep' : planned.action,
|
|
4725
|
-
}],
|
|
4726
|
-
overallState: result.status === 'succeeded' ? 'succeeded' : 'failed',
|
|
4727
|
-
receiptTargets: [{
|
|
4728
|
-
pluginName: identity.pluginName, pluginId: identity.pluginId,
|
|
4729
|
-
sourceId: identity.sourceId, platform, scope: planned.resolvedScope,
|
|
4730
|
-
}],
|
|
4731
|
-
});
|
|
4732
|
-
dependencyStates.set(key, result.status === 'succeeded' ? 'completed' : 'failed');
|
|
4733
|
-
return;
|
|
4734
|
-
}
|
|
4735
4547
|
if (planned.action === 'keep'
|
|
4548
|
+
&& (!keptDeployment || retainedCodexProvider || await keptDeployment.canSettleWithoutWrites?.())
|
|
4736
4549
|
&& !(preparedTargets.get(key)?.target.writeNativeRequired ?? false)
|
|
4737
4550
|
&& options.command !== 'cleanup'
|
|
4738
4551
|
&& options.command !== 'uninstall') {
|
|
@@ -4899,7 +4712,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
4899
4712
|
const pendingCodex = new Set();
|
|
4900
4713
|
const runSelection = async (selection, index) => {
|
|
4901
4714
|
reportTargetState(selection, 'running');
|
|
4902
|
-
refreshCodexObservation();
|
|
4903
4715
|
await executeSelection(selection, index);
|
|
4904
4716
|
const key = executionKey(selection, lockedPlan);
|
|
4905
4717
|
if (selection.platform === 'codex')
|
|
@@ -4936,7 +4748,6 @@ async function runRebuildCommandInSession(options) {
|
|
|
4936
4748
|
reportTargetState(selection, 'completed');
|
|
4937
4749
|
};
|
|
4938
4750
|
const finishCodex = async () => {
|
|
4939
|
-
refreshCodexObservation();
|
|
4940
4751
|
for (const selection of codexSelections) {
|
|
4941
4752
|
const key = executionKey(selection, lockedPlan);
|
|
4942
4753
|
if (!admission || admission.exclusiveGeneration === verifiedGenerations.get(key))
|
|
@@ -4953,79 +4764,21 @@ async function runRebuildCommandInSession(options) {
|
|
|
4953
4764
|
}
|
|
4954
4765
|
}
|
|
4955
4766
|
}
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
...plan.activationActions.project,
|
|
4959
|
-
].flatMap((action) => action.action === 'none' ? [] : [action.pluginId])));
|
|
4960
|
-
for (const selection of executionSelections) {
|
|
4961
|
-
const { entry, platform } = selection;
|
|
4962
|
-
const key = executionKey(selection, lockedPlan);
|
|
4963
|
-
if (platform !== 'codex'
|
|
4964
|
-
|| !activationMutationPluginIds.has(entry.pluginId)
|
|
4965
|
-
|| (dependencyStates.get(key) !== 'completed'
|
|
4966
|
-
&& dependencyStates.get(key) !== 'kept'))
|
|
4967
|
-
continue;
|
|
4968
|
-
const prepared = preparedTargets.get(key)?.target;
|
|
4969
|
-
if (!prepared)
|
|
4970
|
-
continue;
|
|
4971
|
-
try {
|
|
4972
|
-
await lockedPreparation.integration.prepareNativeMarketplaceGroup(prepared);
|
|
4973
|
-
}
|
|
4974
|
-
catch (error) {
|
|
4975
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
4976
|
-
failCompletedCodexTarget({ identity: prepared.identity, message, phase: 'native.write' });
|
|
4977
|
-
}
|
|
4978
|
-
}
|
|
4979
|
-
const successfulCodexTargetScopes = new Set(executionSelections.flatMap((selection) => selection.platform === 'codex'
|
|
4980
|
-
&& (dependencyStates.get(executionKey(selection, lockedPlan)) === 'completed'
|
|
4981
|
-
|| dependencyStates.get(executionKey(selection, lockedPlan)) === 'kept')
|
|
4982
|
-
? [`${selection.entry.pluginId}\0${planTargetFor(lockedPlan, selection).resolvedScope}`]
|
|
4983
|
-
: []));
|
|
4984
|
-
const activationUserBefore = await readCodexConfigFile(resolveCodexPaths(options.commandOptions.cwd, 'user', runtimeEnv).configTomlPath);
|
|
4985
|
-
const activationProjectBefore = options.commandOptions.scope === 'project'
|
|
4986
|
-
? await readCodexConfigFile(resolveCodexPaths(options.commandOptions.cwd, 'project', runtimeEnv).configTomlPath)
|
|
4987
|
-
: undefined;
|
|
4988
|
-
const preservedActivations = {
|
|
4989
|
-
user: new Map(Object.entries(activationUserBefore.snapshot.plugins)
|
|
4990
|
-
.map(([pluginId, activation]) => [pluginId, activation.enabled === true])),
|
|
4991
|
-
project: new Map(Object.entries(activationProjectBefore?.snapshot.plugins ?? {})
|
|
4992
|
-
.map(([pluginId, activation]) => [pluginId, activation.enabled === true])),
|
|
4993
|
-
};
|
|
4994
|
-
const activationPlans = selectCodexActivationPlans(lockedCodexPlans, successfulCodexTargetScopes, preservedActivations, originalUserActivations);
|
|
4995
|
-
if (activationPlans.length > 0
|
|
4996
|
-
|| lockedPreparation.integration.driver.completePostchecks) {
|
|
4997
|
-
let activationError;
|
|
4998
|
-
const activationMutationMarketplaces = new Set();
|
|
4767
|
+
if (lockedPreparation.integration.driver.completePostchecks) {
|
|
4768
|
+
let captureError;
|
|
4999
4769
|
try {
|
|
5000
|
-
|
|
5001
|
-
await executeCodexReconcileActivations({
|
|
5002
|
-
plans: activationPlans,
|
|
5003
|
-
cwd: options.commandOptions.cwd,
|
|
5004
|
-
env: runtimeEnv,
|
|
5005
|
-
manager: executionContext.codexManager,
|
|
5006
|
-
runner: executionContext.nativeCliRunner,
|
|
5007
|
-
observationSession: executionContext.codexObservationSession,
|
|
5008
|
-
preflightCompleted: true,
|
|
5009
|
-
mutationMarketplaces: activationMutationMarketplaces,
|
|
5010
|
-
observationScopeByMarketplace: codexObservationScopeByMarketplace,
|
|
5011
|
-
});
|
|
5012
|
-
}
|
|
4770
|
+
await lockedPreparation.integration.captureCodexPostMutationSnapshots();
|
|
5013
4771
|
}
|
|
5014
4772
|
catch (error) {
|
|
5015
|
-
|
|
5016
|
-
}
|
|
5017
|
-
try {
|
|
5018
|
-
await lockedPreparation.integration.captureCodexPostMutationSnapshots([...activationMutationMarketplaces]);
|
|
5019
|
-
}
|
|
5020
|
-
catch (error) {
|
|
5021
|
-
activationError ??= error;
|
|
4773
|
+
captureError = error;
|
|
5022
4774
|
}
|
|
5023
4775
|
const failedCodexTargetScopes = new Set(executionSelections.flatMap((selection) => selection.platform === 'codex'
|
|
5024
4776
|
&& (dependencyStates.get(executionKey(selection, lockedPlan)) === 'failed'
|
|
5025
4777
|
|| dependencyStates.get(executionKey(selection, lockedPlan)) === 'skipped')
|
|
5026
4778
|
? [`${selection.entry.pluginId}\0${planTargetFor(lockedPlan, selection).resolvedScope}`]
|
|
5027
4779
|
: []));
|
|
5028
|
-
|
|
4780
|
+
const successful = captureError ? codexSelections.filter((selection) => ['completed', 'kept'].includes(dependencyStates.get(executionKey(selection, lockedPlan)) ?? '')) : [];
|
|
4781
|
+
for (const failure of await lockedPreparation.integration.driver.completePostchecks()) {
|
|
5029
4782
|
if (recoveryInterruptionCode(failure.error, executionContext.signal))
|
|
5030
4783
|
throw failure.error;
|
|
5031
4784
|
const message = failure.error instanceof Error
|
|
@@ -5037,55 +4790,17 @@ async function runRebuildCommandInSession(options) {
|
|
|
5037
4790
|
failedCodexTargetScopes.add(`${failedPluginId}\0${failure.target.identity.scope}`);
|
|
5038
4791
|
}
|
|
5039
4792
|
}
|
|
5040
|
-
if (
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
const
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
observationScopeByMarketplace: codexObservationScopeByMarketplace,
|
|
5052
|
-
observationSession: executionContext.codexObservationSession,
|
|
5053
|
-
});
|
|
5054
|
-
}
|
|
5055
|
-
catch (error) {
|
|
5056
|
-
activationError = error;
|
|
5057
|
-
}
|
|
5058
|
-
}
|
|
5059
|
-
if (activationError) {
|
|
5060
|
-
if (recoveryInterruptionCode(activationError, executionContext.signal))
|
|
5061
|
-
throw activationError;
|
|
5062
|
-
const failedActivationTargetScopes = failedCodexActivationTargetScopes({
|
|
5063
|
-
error: activationError,
|
|
5064
|
-
plans: activationPlans,
|
|
5065
|
-
successfulTargetScopes: successfulCodexTargetScopes,
|
|
5066
|
-
});
|
|
5067
|
-
const message = activationError instanceof Error
|
|
5068
|
-
? activationError.message
|
|
5069
|
-
: String(activationError);
|
|
5070
|
-
const failedSelections = executionSelections.filter((candidate) => candidate.platform === 'codex'
|
|
5071
|
-
&& failedActivationTargetScopes.has(`${candidate.entry.pluginId}\0${planTargetFor(lockedPlan, candidate).resolvedScope}`));
|
|
5072
|
-
if (failedSelections.length === 0)
|
|
5073
|
-
throw activationError;
|
|
5074
|
-
for (const selection of failedSelections) {
|
|
5075
|
-
const planned = planTargetFor(lockedPlan, selection);
|
|
5076
|
-
const identity = {
|
|
5077
|
-
sourceId: selection.entry.source.sourceId,
|
|
5078
|
-
sourceIdentity: selection.entry.source.sourceIdentity,
|
|
5079
|
-
pluginId: selection.entry.pluginId,
|
|
5080
|
-
pluginName: selection.entry.plugin.manifest.name,
|
|
5081
|
-
pluginVersion: selection.entry.plugin.manifest.version,
|
|
5082
|
-
platform: 'codex',
|
|
5083
|
-
scope: planned.resolvedScope,
|
|
5084
|
-
cwd: options.commandOptions.cwd,
|
|
5085
|
-
};
|
|
5086
|
-
if (!failCompletedCodexTarget({ identity, message }))
|
|
5087
|
-
throw activationError;
|
|
5088
|
-
failedCodexTargetScopes.add(`${selection.entry.pluginId}\0${planned.resolvedScope}`);
|
|
4793
|
+
if (captureError) {
|
|
4794
|
+
if (recoveryInterruptionCode(captureError, executionContext.signal))
|
|
4795
|
+
throw captureError;
|
|
4796
|
+
const message = captureError instanceof Error ? captureError.message : String(captureError);
|
|
4797
|
+
if (!successful.length)
|
|
4798
|
+
throw captureError;
|
|
4799
|
+
for (const selection of successful) {
|
|
4800
|
+
const scope = planTargetFor(lockedPlan, selection).resolvedScope;
|
|
4801
|
+
if (!failCompletedCodexTarget({ identity: targetIdentity(selection, scope), message }))
|
|
4802
|
+
throw captureError;
|
|
4803
|
+
failedCodexTargetScopes.add(`${selection.entry.pluginId}\0${scope}`);
|
|
5089
4804
|
}
|
|
5090
4805
|
}
|
|
5091
4806
|
let propagated = true;
|
|
@@ -5251,13 +4966,23 @@ async function runRebuildCommandInSession(options) {
|
|
|
5251
4966
|
}
|
|
5252
4967
|
merged.dependencyPlan = lockedPlan;
|
|
5253
4968
|
merged.overallState = reconcileOverallState(merged.targetResults, lockedPlan, merged.rebuildResults);
|
|
5254
|
-
if (lockedCodexPlans.length > 0)
|
|
5255
|
-
merged.codexReconcilePlans = lockedCodexPlans;
|
|
5256
4969
|
merged.operationPlan = lockedOperationPlan;
|
|
5257
4970
|
merged.nativeFootprints = preparedNativeFootprints([...lockedPreparation.preparedTargets.values()].map((entry) => entry.target));
|
|
5258
4971
|
return leaseSafeRebuildResult(merged);
|
|
5259
4972
|
},
|
|
5260
4973
|
});
|
|
4974
|
+
// The Catalog lease returns a checked plain-data copy. Bind the private staging
|
|
4975
|
+
// to the actual plan object the coordinator receives, after the lease boundary.
|
|
4976
|
+
if (refreshSealedPreview && resolvedResult.operationPlan && options.runtime?.nativeObservationBatch) {
|
|
4977
|
+
const batch = options.runtime.nativeObservationBatch;
|
|
4978
|
+
let groups = sealedPreviews.get(batch);
|
|
4979
|
+
if (!groups)
|
|
4980
|
+
sealedPreviews.set(batch, groups = new WeakMap());
|
|
4981
|
+
groups.set(resolvedResult.operationPlan, refreshSealedPreview);
|
|
4982
|
+
}
|
|
4983
|
+
if (preparedGroupForReview && resolvedResult.operationPlan) {
|
|
4984
|
+
LockedPreparedExecution.retainGroup(options.runtime?.nativeObservationBatch, resolvedResult.operationPlan, preparedGroupForReview);
|
|
4985
|
+
}
|
|
5261
4986
|
if (cleanupForce && !options.runtime?.previewOperationPlan) {
|
|
5262
4987
|
try {
|
|
5263
4988
|
await (options.runtime?.removeObsoleteInstallationContracts ?? fs.remove)(path.join(resolveAwHome(runtimeEnv), 'installation-contracts'));
|
|
@@ -5341,26 +5066,17 @@ export async function runRebuildCommand(options) {
|
|
|
5341
5066
|
runtime: { ...options.runtime, env: executionInput.context.env },
|
|
5342
5067
|
};
|
|
5343
5068
|
try {
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
}
|
|
5348
|
-
const
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
try {
|
|
5356
|
-
return withCommands(await runRebuildCommandInSession({
|
|
5357
|
-
...scopedOptions,
|
|
5358
|
-
runtime: { ...scopedOptions.runtime, codexObservationSession: session },
|
|
5359
|
-
}));
|
|
5360
|
-
}
|
|
5361
|
-
finally {
|
|
5362
|
-
await session.dispose();
|
|
5363
|
-
}
|
|
5069
|
+
const runtime = scopedOptions.runtime;
|
|
5070
|
+
const run = async (nativeObservationBatch) => withCommands(await runRebuildCommandInSession({
|
|
5071
|
+
...scopedOptions, runtime: { ...runtime, nativeObservationBatch },
|
|
5072
|
+
}));
|
|
5073
|
+
const borrowed = runtime.nativeObservationBatch;
|
|
5074
|
+
if (borrowed && (runtime.previewOperationPlan || borrowed.phase === 'locked-execution'))
|
|
5075
|
+
return await run(borrowed);
|
|
5076
|
+
const token = runtime.awHomeMutationToken;
|
|
5077
|
+
return await withNativeObservationBatch({ phase: runtime.previewOperationPlan && !token ? 'unlocked-preview' : 'locked-execution',
|
|
5078
|
+
runner: runtime.nativeCliRunner, signal: runtime.signal, codexExactCwd: executionInput.context.executionCwd,
|
|
5079
|
+
onInvalidate: token && ((impact) => advanceAwHomeMutationEpoch(token, impact === 'all' ? 'inputs' : 'outputs')) }, run);
|
|
5364
5080
|
}
|
|
5365
5081
|
finally {
|
|
5366
5082
|
if (ownsPreparation && !options.runtime?.previewOperationPlan)
|