@lesliechan721/aw 0.1.0-beta.81 → 0.1.0-beta.83
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/intent-command.d.ts +2 -1
- package/dist/src/commands/intent-command.js +3 -4
- package/dist/src/commands/intent-command.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.js +4 -0
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.js +1 -1
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +2 -1
- package/dist/src/commands/rebuild-command.js +22 -13
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +2 -0
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +2 -0
- package/dist/src/commands/rebuild-platform-integration.js +63 -9
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/platforms/discovery.d.ts +4 -3
- package/dist/src/platforms/discovery.js +33 -9
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/inspection-native.js +15 -4
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/inspection-query.d.ts +12 -1
- package/dist/src/platforms/inspection-query.js +24 -6
- package/dist/src/platforms/inspection-query.js.map +1 -1
- package/dist/src/portable/commands.d.ts +2 -2
- package/dist/src/portable/commands.js +7 -3
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +2 -1
- package/dist/src/portable/materializer.js +4 -4
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +3 -3
- package/dist/src/portable/recovery.js +7 -7
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +13 -2
- package/dist/src/recovery/coordinator.js +67 -24
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/demand.d.ts +3 -1
- package/dist/src/recovery/demand.js +36 -6
- package/dist/src/recovery/demand.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.d.ts +8 -1
- package/dist/src/recovery/joint-coordinator.js +120 -26
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.d.ts +2 -0
- package/dist/src/recovery/joint-demand.js +46 -9
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/status.d.ts +4 -0
- package/dist/src/recovery/status.js +37 -19
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/tui/catalog-generation.d.ts +6 -0
- package/dist/src/tui/catalog-generation.js +22 -6
- package/dist/src/tui/catalog-generation.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +2 -2
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +100 -44
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.js +8 -0
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/glossary.js +1 -0
- package/dist/src/tui/glossary.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +5 -0
- package/dist/src/utils/catalog-generation-resolver.js +29 -17
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +3 -0
- package/dist/src/utils/catalog-generation-store.js +7 -4
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-operation-context.d.ts +27 -3
- package/dist/src/utils/catalog-operation-context.js +73 -3
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-snapshot.d.ts +3 -0
- package/dist/src/utils/catalog-snapshot.js +4 -1
- package/dist/src/utils/catalog-snapshot.js.map +1 -1
- package/dist/src/utils/codex-executable-discovery.js +8 -8
- package/dist/src/utils/codex-executable-discovery.js.map +1 -1
- package/dist/src/utils/native-cli.js +36 -9
- package/dist/src/utils/native-cli.js.map +1 -1
- package/package.json +3 -3
|
@@ -24,8 +24,8 @@ export async function readDemand(options) {
|
|
|
24
24
|
]);
|
|
25
25
|
const errors = [];
|
|
26
26
|
if (intent.state !== 'absent' && intent.state !== 'valid') {
|
|
27
|
-
errors.push(describeStrongStateProblem({ kind: 'intent', scope: options.scope,
|
|
28
|
-
|
|
27
|
+
errors.push({ ...describeStrongStateProblem({ kind: 'intent', scope: options.scope,
|
|
28
|
+
state: intent.state, filePath: await resolveIntentPath(options) }), subject: { scope: options.scope } });
|
|
29
29
|
}
|
|
30
30
|
if (preferences.state === 'invalid' || preferences.state === 'unreadable') {
|
|
31
31
|
errors.push(describeStrongStateProblem({ kind: 'preferences', scope: 'user',
|
|
@@ -56,7 +56,7 @@ export async function readDemand(options) {
|
|
|
56
56
|
context ??= await resolvePartialCatalogOperationContext({
|
|
57
57
|
env: options.env, configSnapshot: snapshot, signal: options.signal,
|
|
58
58
|
sourceIds: [...new Set(roots.map((root) => root.sourceId))].filter((id) => configured.has(id)),
|
|
59
|
-
});
|
|
59
|
+
}, options.catalogReadScope);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
catch (error) {
|
|
@@ -70,6 +70,7 @@ export async function readDemand(options) {
|
|
|
70
70
|
}
|
|
71
71
|
result.catalogOperationContext = context;
|
|
72
72
|
const pluginCache = new Map();
|
|
73
|
+
const unreadable = new Map();
|
|
73
74
|
for (const root of roots) {
|
|
74
75
|
options.signal?.throwIfAborted();
|
|
75
76
|
if (!configured.has(root.sourceId)) {
|
|
@@ -96,7 +97,7 @@ export async function readDemand(options) {
|
|
|
96
97
|
}
|
|
97
98
|
for (const entry of source.manifest.entries) {
|
|
98
99
|
const pluginId = `${root.sourceId}/${entry.name}`;
|
|
99
|
-
if (pluginCache.has(pluginId))
|
|
100
|
+
if (pluginCache.has(pluginId) || unreadable.has(pluginId))
|
|
100
101
|
continue;
|
|
101
102
|
try {
|
|
102
103
|
const key = JSON.stringify([source.sourceIdentity, source.logicalIdentity, source.snapshotDigest, source.rootDir, pluginId]);
|
|
@@ -113,12 +114,41 @@ export async function readDemand(options) {
|
|
|
113
114
|
pluginCache.set(pluginId, plugin);
|
|
114
115
|
}
|
|
115
116
|
catch {
|
|
116
|
-
|
|
117
|
-
root.blockers.push('pluginManifestUnavailable');
|
|
117
|
+
unreadable.set(pluginId, pluginId);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
root.plugin = pluginCache.get(root.pluginId);
|
|
121
121
|
}
|
|
122
|
+
if (unreadable.size) {
|
|
123
|
+
// Keep the complete readable closures usable when another manifest read fails.
|
|
124
|
+
const dependents = new Map();
|
|
125
|
+
for (const [id, plugin] of pluginCache)
|
|
126
|
+
for (const name of plugin.manifest.dependencies ?? []) {
|
|
127
|
+
const dependency = `${plugin.sourceId}/${name}`;
|
|
128
|
+
const consumers = dependents.get(dependency);
|
|
129
|
+
if (consumers)
|
|
130
|
+
consumers.push(id);
|
|
131
|
+
else
|
|
132
|
+
dependents.set(dependency, [id]);
|
|
133
|
+
}
|
|
134
|
+
// Map iteration visits each newly affected consumer, including transitive roots.
|
|
135
|
+
for (const [id, failedManifest] of unreadable) {
|
|
136
|
+
for (const consumer of dependents.get(id) ?? []) {
|
|
137
|
+
if (!unreadable.has(consumer))
|
|
138
|
+
unreadable.set(consumer, failedManifest);
|
|
139
|
+
}
|
|
140
|
+
pluginCache.delete(id);
|
|
141
|
+
}
|
|
142
|
+
for (const root of roots) {
|
|
143
|
+
const failed = unreadable.get(root.pluginId);
|
|
144
|
+
if (!failed || root.sourceState !== 'ready')
|
|
145
|
+
continue;
|
|
146
|
+
if (root.plugin)
|
|
147
|
+
root.unreadableDependency = failed;
|
|
148
|
+
else
|
|
149
|
+
root.blockers.push('pluginManifestUnavailable');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
122
152
|
result.plugins = [...pluginCache.values()];
|
|
123
153
|
return result;
|
|
124
154
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"demand.js","sourceRoot":"","sources":["../../../src/recovery/demand.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAGjF,OAAO,EAAE,kBAAkB,EAA6C,MAAM,qCAAqC,CAAC;AACpH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAA0B,MAAM,2BAA2B,CAAC;AACrG,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EACL,qCAAqC,
|
|
1
|
+
{"version":3,"file":"demand.js","sourceRoot":"","sources":["../../../src/recovery/demand.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAGjF,OAAO,EAAE,kBAAkB,EAA6C,MAAM,qCAAqC,CAAC;AACpH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAA0B,MAAM,2BAA2B,CAAC;AACrG,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EACL,qCAAqC,GAGtC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAyB,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAqChE,wFAAwF;AACxF,MAAM,UAAU,eAAe,CAC7B,QAAkC,EAAE,KAAc,EAAE,MAAa;IAEjE,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACzD,OAAO,KAAK,K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C7G,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9D,IAAI,MAAM,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzC,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrF,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Scope } from '../types.js';
|
|
2
2
|
import type { RebuildCommandRuntime } from '../commands/rebuild-command.js';
|
|
3
3
|
import { type PluginIntent } from '../intent/intent-codec.js';
|
|
4
|
+
import { CatalogPreparationReadScope } from '../utils/catalog-operation-context.js';
|
|
4
5
|
import { type JointDemandSnapshot, type JointDemandPlan } from './joint-demand.js';
|
|
5
6
|
import { type RecoveryCommand, type RecoveryOptions, type RecoveryPlan } from './coordinator.js';
|
|
6
7
|
import type { RecoveryReceipt } from './receipt.js';
|
|
@@ -17,9 +18,15 @@ export interface JointRecoveryState {
|
|
|
17
18
|
};
|
|
18
19
|
evidence: string;
|
|
19
20
|
}
|
|
21
|
+
declare function readJointPreparation(command: RecoveryCommand, options: RecoveryOptions, locked?: boolean): Promise<{
|
|
22
|
+
options: RecoveryOptions;
|
|
23
|
+
snapshot: JointDemandSnapshot;
|
|
24
|
+
catalogReadScope?: CatalogPreparationReadScope;
|
|
25
|
+
}>;
|
|
20
26
|
/** Complete requirements determine placement before execution selectors are applied. */
|
|
21
|
-
export declare function prepareJointRecovery(command: RecoveryCommand, selectors: readonly string[], options: RecoveryOptions, runtime: RebuildCommandRuntime): Promise<RecoveryPlan>;
|
|
27
|
+
export declare function prepareJointRecovery(command: RecoveryCommand, selectors: readonly string[], options: RecoveryOptions, runtime: RebuildCommandRuntime, preparation?: Awaited<ReturnType<typeof readJointPreparation>>): Promise<RecoveryPlan>;
|
|
22
28
|
export declare function executeJointRecovery(plan: RecoveryPlan, execution: {
|
|
23
29
|
yes?: boolean;
|
|
24
30
|
runtime?: RebuildCommandRuntime;
|
|
25
31
|
}): Promise<RecoveryReceipt>;
|
|
32
|
+
export {};
|
|
@@ -5,7 +5,7 @@ import { createEmptyIntent, calculateIntentDigest, removeIntentRoot } from '../i
|
|
|
5
5
|
import { observeIntent, writeIntent, resolveIntentPath } from '../intent/intent-store.js';
|
|
6
6
|
import { describeStrongStateProblem } from '../intent/diagnostics.js';
|
|
7
7
|
import { observePreferences, normalizeAgents, writePreferences } from '../intent/deployment-preferences.js';
|
|
8
|
-
import {
|
|
8
|
+
import { withNativeObservationBatch } from '../platforms/inspection-query.js';
|
|
9
9
|
import { createScopeContext } from '../intent/scope-context.js';
|
|
10
10
|
import { withAwHomeMutationLock } from '../utils/aw-home-mutation-lock.js';
|
|
11
11
|
import { readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
|
|
@@ -13,16 +13,17 @@ import { createCodexNativeObservationSession } from '../utils/codex-native-obser
|
|
|
13
13
|
import { bindNativeCliRunnerSignal, getDefaultNativeCliRunner } from '../utils/native-cli.js';
|
|
14
14
|
import { analyzeCodexSurface } from '../utils/codex-surface-analysis.js';
|
|
15
15
|
import { validateCatalogSnapshotComplete } from '../utils/catalog-snapshot.js';
|
|
16
|
+
import { CatalogPreparationReadScope } from '../utils/catalog-operation-context.js';
|
|
16
17
|
import { readCatalogGenerationState } from '../utils/catalog-generation-state.js';
|
|
18
|
+
import { readCatalogSourcesConfigSnapshot } from '../utils/catalog-sources.js';
|
|
17
19
|
import { parsePluginId } from '../utils/multi-source-catalog.js';
|
|
18
20
|
import { readDemand } from './demand.js';
|
|
19
|
-
import { readJointDemand, deriveJointDemand, deriveSharedReferenceView } from './joint-demand.js';
|
|
20
|
-
import { prepareScopedRecovery, executeScopedRecovery, executeRecoveryPreApply, refreshRecoveryNativePreviews, describeRecoveryPlan } from './coordinator.js';
|
|
21
|
-
import { readScopedRecoveryStatus, readRecoveryStatus } from './status.js';
|
|
21
|
+
import { canReuseProviderAcrossScopes, readJointDemand, deriveJointDemand, deriveSharedReferenceView } from './joint-demand.js';
|
|
22
|
+
import { prepareScopedRecovery, executeScopedRecovery, executeRecoveryPreApply, refreshRecoveryNativePreviews, describeRecoveryPlan, errorCode } from './coordinator.js';
|
|
23
|
+
import { isTargetObservationReadError, readScopedRecoveryStatus, readRecoveryStatus } from './status.js';
|
|
22
24
|
import { measureRecoveryPerformanceStage, recordRecoveryPerformanceStage } from './performance.js';
|
|
23
25
|
import { resolvePluginMetaDependencyClosure } from '../utils/plugin-dependencies.js';
|
|
24
26
|
const diagnostic = (code, message = code) => ({ code, message });
|
|
25
|
-
const canReuseProviderAcrossScopes = (target) => target === 'generic' || hasSharedUserPackage(target);
|
|
26
27
|
function intentReceipt(observation) {
|
|
27
28
|
return { state: observation.state,
|
|
28
29
|
roots: observation.state === 'valid' ? observation.value.roots.map((root) => root.pluginId)
|
|
@@ -80,19 +81,56 @@ function mergeReceipts(plan, receipts) {
|
|
|
80
81
|
receipt.ok = receipt.blockers.length === 0 && receipts.every((item) => item.ok);
|
|
81
82
|
return receipt;
|
|
82
83
|
}
|
|
84
|
+
function finalStatusReadFailure(status, receipt) {
|
|
85
|
+
const completed = receipt.targetResults.filter((target) => target.delivery && target.observation === 'verified');
|
|
86
|
+
const strongStateError = status.errors.find((error) => error.code === 'deploymentPreferencesInvalid'
|
|
87
|
+
|| error.code === 'pluginIntentStateInvalid' && (error.subject?.scope === receipt.scope
|
|
88
|
+
|| completed.some((target) => target.scope === error.subject?.scope)));
|
|
89
|
+
if (strongStateError)
|
|
90
|
+
return strongStateError;
|
|
91
|
+
for (const { pluginId, scope, agent } of completed) {
|
|
92
|
+
const matches = (target) => target.pluginId === pluginId
|
|
93
|
+
&& target.scope === scope && target.agent === agent;
|
|
94
|
+
const root = status.inventory?.find((item) => item.pluginId === pluginId && item.targetResults.some(matches));
|
|
95
|
+
const failure = root?.blockers.find((entry) => root.sourceState !== 'ready' || entry.code === 'pluginManifestUnavailable')
|
|
96
|
+
?? root?.targetResults.find(matches)?.blockers.find((entry) => entry.code === 'pluginManifestUnavailable' || entry.code === 'jointDemandUnknown')
|
|
97
|
+
?? status.observedTargets?.find(matches)?.blockers.find(isTargetObservationReadError);
|
|
98
|
+
if (failure)
|
|
99
|
+
return { ...failure, subject: { pluginId, scope, target: agent } };
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
async function readJointPreparation(command, options, locked = false) {
|
|
104
|
+
const catalogReadScope = command === 'install' && (locked || !options.catalogOperationContext)
|
|
105
|
+
? new CatalogPreparationReadScope(options) : undefined;
|
|
106
|
+
if (locked && catalogReadScope && options.catalogOperationContext) {
|
|
107
|
+
// A caller may have reviewed a subset of sources. Rebind just those IDs under
|
|
108
|
+
// the lock so a changed or removed source makes the existing Review stale.
|
|
109
|
+
const reviewed = new Set(options.catalogOperationContext.catalog.sources.map((source) => source.sourceId));
|
|
110
|
+
const configSnapshot = await readCatalogSourcesConfigSnapshot(options.env);
|
|
111
|
+
const sourceIds = configSnapshot.config.sources.map((source) => source.id).filter((id) => reviewed.has(id));
|
|
112
|
+
options = { ...options, catalogOperationContext: await catalogReadScope.resolve({ configSnapshot, sourceIds }) };
|
|
113
|
+
}
|
|
114
|
+
const snapshot = await readJointDemand({ ...options, catalogReadScope });
|
|
115
|
+
return { options, snapshot, catalogReadScope };
|
|
116
|
+
}
|
|
83
117
|
/** Complete requirements determine placement before execution selectors are applied. */
|
|
84
|
-
export async function prepareJointRecovery(command, selectors, options, runtime) {
|
|
118
|
+
export async function prepareJointRecovery(command, selectors, options, runtime, preparation) {
|
|
85
119
|
runtime = { ...runtime, preparedArtifactRenderResults: runtime.preparedArtifactRenderResults ?? new Map() };
|
|
86
|
-
const snapshot = await
|
|
120
|
+
const { snapshot, catalogReadScope } = preparation ?? await readJointPreparation(command, options);
|
|
121
|
+
const prepare = (current) => {
|
|
122
|
+
const read = (nativeObservationBatch) => prepareJointRecoveryInSession(command, selectors, options, current, snapshot, { catalogReadScope, nativeObservationBatch });
|
|
123
|
+
return command === 'install' ? withNativeObservationBatch({ runner: current.nativeCliRunner, signal: options.signal }, read) : read();
|
|
124
|
+
};
|
|
87
125
|
if (runtime.codexObservationSession)
|
|
88
|
-
return
|
|
126
|
+
return prepare(runtime);
|
|
89
127
|
const observationContext = await createScopeContext({ ...options, scope: snapshot.context.context });
|
|
90
128
|
const executionRunner = runtime.nativeCliRunner ?? getDefaultNativeCliRunner();
|
|
91
129
|
let sessionRunner = bindNativeCliRunnerSignal(executionRunner, options.signal);
|
|
92
130
|
const session = await createCodexNativeObservationSession({ exactCwd: observationContext.executionCwd,
|
|
93
131
|
env: observationContext.env, runner: (invocation) => sessionRunner(invocation), manager: runtime.codexManager });
|
|
94
132
|
try {
|
|
95
|
-
const plan = await
|
|
133
|
+
const plan = await prepare({ ...runtime, codexObservationSession: session });
|
|
96
134
|
const dispose = plan.context.dispose;
|
|
97
135
|
plan.context.dispose = async () => {
|
|
98
136
|
try {
|
|
@@ -123,18 +161,20 @@ export async function prepareJointRecovery(command, selectors, options, runtime)
|
|
|
123
161
|
sessionRunner = executionRunner;
|
|
124
162
|
}
|
|
125
163
|
}
|
|
126
|
-
async function prepareJointRecoveryInSession(command, selectors, options, runtime, snapshot) {
|
|
164
|
+
async function prepareJointRecoveryInSession(command, selectors, { checkInstallCatalog, ...options }, runtime, snapshot, { catalogReadScope, nativeObservationBatch }) {
|
|
127
165
|
// Status observes saved requirements, before projecting proposed declarations.
|
|
128
166
|
// Reuse them only within this preparation; execution reads them again under the lock.
|
|
129
167
|
const savedDemand = snapshot;
|
|
168
|
+
const initialNativeReads = { nativeCliRunner: nativeObservationBatch?.runner ?? runtime.nativeCliRunner,
|
|
169
|
+
discoveryCache: nativeObservationBatch?.discoveryCache, nativeQuerySession: nativeObservationBatch?.nativeQuerySession,
|
|
170
|
+
codexObservationSession: runtime.codexObservationSession };
|
|
130
171
|
let observedStatus;
|
|
131
172
|
const evidence = snapshotEvidence(snapshot);
|
|
132
173
|
const scope = options.scope ?? snapshot.context.context;
|
|
133
174
|
const observedIntent = (scope === 'project' ? snapshot.project : snapshot.user).intent;
|
|
134
175
|
if (options.existingOnly) {
|
|
135
176
|
// Existing owned deployments can be refreshed without converting them into declarations.
|
|
136
|
-
observedStatus = await readRecoveryStatus({ ...options,
|
|
137
|
-
codexObservationSession: runtime.codexObservationSession }, savedDemand);
|
|
177
|
+
observedStatus = await readRecoveryStatus({ ...options, catalogReadScope, ...initialNativeReads }, savedDemand);
|
|
138
178
|
const installed = (observedStatus.existingTargets ?? []).filter((item) => selectors.some((selector) => selector === item.pluginId
|
|
139
179
|
|| !selector.includes('/') && parsePluginId(item.pluginId).pluginName === selector)
|
|
140
180
|
&& (!options.targets || options.targets.includes(item.agent)));
|
|
@@ -155,7 +195,7 @@ async function prepareJointRecoveryInSession(command, selectors, options, runtim
|
|
|
155
195
|
value.sources[sourceId] = { logicalIdentity: identity };
|
|
156
196
|
value.roots.push({ pluginId: item.pluginId });
|
|
157
197
|
}
|
|
158
|
-
snapshot = { ...snapshot, [currentScope]: await readDemand({ ...options, preferences: undefined, scope: currentScope, intent: asObservation(value) }) };
|
|
198
|
+
snapshot = { ...snapshot, [currentScope]: await readDemand({ ...options, catalogReadScope, preferences: undefined, scope: currentScope, intent: asObservation(value) }) };
|
|
159
199
|
}
|
|
160
200
|
if (snapshot.preferences)
|
|
161
201
|
snapshot.preferences = { ...snapshot.preferences,
|
|
@@ -187,15 +227,26 @@ async function prepareJointRecoveryInSession(command, selectors, options, runtim
|
|
|
187
227
|
if (!snapshot.preferences?.targets.length)
|
|
188
228
|
errors.push(diagnostic('targetsNotConfigured', '请先配置本机 Agent,再安装插件。'));
|
|
189
229
|
else {
|
|
190
|
-
const proposed = await addRequirements({ ...options, scope, selectors, token: runtime.awHomeMutationToken, dryRun: true, installSelectors: true });
|
|
230
|
+
const proposed = await addRequirements({ ...options, catalogReadScope, scope, selectors, token: runtime.awHomeMutationToken, dryRun: true, installSelectors: true });
|
|
231
|
+
options.signal?.throwIfAborted();
|
|
191
232
|
errors.push(...proposed.errors);
|
|
192
233
|
if (proposed.state && !proposed.errors.length) {
|
|
193
234
|
requested = proposed.roots;
|
|
194
235
|
if (proposed.changed)
|
|
195
236
|
declaration = { scope, value: proposed.state };
|
|
196
|
-
const demand = await readDemand({ ...options, preferences: undefined, scope, intent: asObservation(proposed.state) });
|
|
237
|
+
const demand = await readDemand({ ...options, catalogReadScope, preferences: undefined, scope, intent: asObservation(proposed.state) });
|
|
238
|
+
checkInstallCatalog?.(demand.catalogOperationContext, requested);
|
|
197
239
|
snapshot = { ...snapshot, [scope]: demand };
|
|
198
240
|
}
|
|
241
|
+
else if (checkInstallCatalog && catalogReadScope
|
|
242
|
+
&& proposed.errors.some((error) => ['sourceMissing', 'sourceActiveUnavailable', 'pluginUnavailable', 'sourceIdentityConflict'].includes(error.code))) {
|
|
243
|
+
// The same error on the accepted generation remains an ordinary planner diagnostic.
|
|
244
|
+
const configSnapshot = await readCatalogSourcesConfigSnapshot(options.env);
|
|
245
|
+
const requestedSources = new Set(proposed.roots.map((root) => parsePluginId(root).sourceId));
|
|
246
|
+
const sourceIds = configSnapshot.config.sources.map((source) => source.id)
|
|
247
|
+
.filter((id) => requestedSources.has(id) || requestedSources.has(undefined));
|
|
248
|
+
checkInstallCatalog(await catalogReadScope.resolve({ configSnapshot, sourceIds }), proposed.roots);
|
|
249
|
+
}
|
|
199
250
|
}
|
|
200
251
|
}
|
|
201
252
|
else if (command === 'uninstall') {
|
|
@@ -296,7 +347,7 @@ async function prepareJointRecoveryInSession(command, selectors, options, runtim
|
|
|
296
347
|
pluginId: item.pluginId, sourceId: item.plugin.sourceId, sourceState: 'ready', blockers: [], plugin: item.plugin,
|
|
297
348
|
}])).values()], userProviders: Object.fromEntries(targets.map((target) => [target,
|
|
298
349
|
demand.placements.filter((item) => item.scope === 'user' && item.target === target).map((item) => item.pluginId)])) };
|
|
299
|
-
const observation = await readScopedRecoveryStatus({ ...options,
|
|
350
|
+
const observation = await readScopedRecoveryStatus({ ...options, catalogReadScope, ...initialNativeReads, scope: 'project', demandOverride: expanded,
|
|
300
351
|
cwd: snapshot.context.projectRoot, targets: undefined });
|
|
301
352
|
for (const item of sharedNative) {
|
|
302
353
|
const actual = observation.inventory?.find((entry) => entry.pluginId === item.pluginId)?.targetResults
|
|
@@ -353,8 +404,7 @@ async function prepareJointRecoveryInSession(command, selectors, options, runtim
|
|
|
353
404
|
if (plan.blockExecution)
|
|
354
405
|
return plan;
|
|
355
406
|
try {
|
|
356
|
-
const currentStatus = observedStatus ?? await readRecoveryStatus({ ...options,
|
|
357
|
-
codexObservationSession: runtime.codexObservationSession, targets: undefined }, savedDemand);
|
|
407
|
+
const currentStatus = observedStatus ?? await readRecoveryStatus({ ...options, catalogReadScope, ...initialNativeReads, targets: undefined }, savedDemand);
|
|
358
408
|
const sharedReferenceView = deriveSharedReferenceView(snapshot, demand, currentStatus);
|
|
359
409
|
const ownsOutput = (item) => currentStatus.ownedTargets?.some((owned) => owned.pluginId === item.pluginId
|
|
360
410
|
&& owned.agent === item.agent && owned.scope === item.scope) === true;
|
|
@@ -391,6 +441,28 @@ async function prepareJointRecoveryInSession(command, selectors, options, runtim
|
|
|
391
441
|
}
|
|
392
442
|
}
|
|
393
443
|
if (command === 'uninstall' && !options.force) {
|
|
444
|
+
for (const root of demand.roots) {
|
|
445
|
+
if (root.state !== 'unknown' || !targets.includes(root.target)
|
|
446
|
+
|| root.scope === scope && options.retiringCatalogRoots?.includes(root.pluginId))
|
|
447
|
+
continue;
|
|
448
|
+
for (const pluginId of requested) {
|
|
449
|
+
const provider = { pluginId, scope, agent: root.target };
|
|
450
|
+
if (root.pluginId === pluginId || !explicitlyRemoves(provider)
|
|
451
|
+
|| !sameProvider({ scope: root.scope, agent: root.target }, provider))
|
|
452
|
+
continue;
|
|
453
|
+
if (root.dependencies.length ? !root.dependencies.includes(pluginId)
|
|
454
|
+
: parsePluginId(root.pluginId).sourceId !== parsePluginId(pluginId).sourceId)
|
|
455
|
+
continue;
|
|
456
|
+
// Generic Project roots have their own directory. Verify the saved
|
|
457
|
+
// declaration's complete closure and ownership again under the write lock.
|
|
458
|
+
if (scope === 'user' && root.scope === 'project' && root.target === 'generic'
|
|
459
|
+
&& ownsOutput({ pluginId, agent: root.target, scope: 'project' })
|
|
460
|
+
&& currentStatus.inventory?.some((item) => item.pluginId === pluginId && item.targetResults.some((target) => target.agent === root.target && target.scope === 'project' && target.providerScope === 'project'
|
|
461
|
+
&& target.observation === 'verified' && target.content === 'satisfied' && !target.blockers.length)))
|
|
462
|
+
continue;
|
|
463
|
+
errors.push(diagnostic('dependencyStillRequired', `${pluginId} 仍被 ${root.pluginId} 依赖。使用 --force 可强制移除所选输出。`));
|
|
464
|
+
}
|
|
465
|
+
}
|
|
394
466
|
for (const pluginId of requested)
|
|
395
467
|
for (const agent of new Set(liveConsumers.map((consumer) => consumer.agent))) {
|
|
396
468
|
const provider = { pluginId, agent, scope };
|
|
@@ -454,11 +526,11 @@ async function prepareJointRecoveryInSession(command, selectors, options, runtim
|
|
|
454
526
|
? userProviders.filter((provider) => provider.target !== 'generic'
|
|
455
527
|
&& !placements.some((item) => item.pluginId === provider.pluginId && item.target === provider.target))
|
|
456
528
|
.map((item) => ({ pluginId: item.pluginId, platform: item.target, scope: 'user' })) : [],
|
|
457
|
-
}, runtime);
|
|
529
|
+
}, runtime, { catalogReadScope, nativeObservationBatch: children.length === 0 ? nativeObservationBatch : undefined });
|
|
458
530
|
// Synthetic roots are only an execution projection, never persisted Intent.
|
|
459
531
|
child.originalIntent = observationEvidence(sourceDemand.intent);
|
|
460
532
|
if (options.existingOnly) {
|
|
461
|
-
const observed = await readScopedRecoveryStatus({ ...options, nativeCliRunner: runtime.nativeCliRunner, codexObservationSession: runtime.codexObservationSession, scope: currentScope,
|
|
533
|
+
const observed = await readScopedRecoveryStatus({ ...options, catalogReadScope, nativeCliRunner: runtime.nativeCliRunner, codexObservationSession: runtime.codexObservationSession, scope: currentScope,
|
|
462
534
|
cwd: snapshot.context.projectRoot ?? options.cwd, demandOverride: childDemand, targets: groupTargets });
|
|
463
535
|
for (const item of child.receipt.targetResults) {
|
|
464
536
|
if (!observed.existingTargets?.some((existing) => existing.pluginId === item.pluginId && existing.agent === item.agent && existing.scope === currentScope)) {
|
|
@@ -604,7 +676,7 @@ async function prepareJointRecoveryInSession(command, selectors, options, runtim
|
|
|
604
676
|
// or retained packages. Refresh those previews before exposing Review.
|
|
605
677
|
if (!singleNativePreviewComplete)
|
|
606
678
|
for (const child of children)
|
|
607
|
-
await refreshRecoveryNativePreviews(child);
|
|
679
|
+
await refreshRecoveryNativePreviews(child, catalogReadScope);
|
|
608
680
|
const preparedNativeTargets = children.flatMap((child) => child.receipt.targetResults)
|
|
609
681
|
.filter((target) => target.delivery?.kind === 'native');
|
|
610
682
|
const failedProviders = preparedNativeTargets.filter((target) => target.blockers.length > 0);
|
|
@@ -664,7 +736,8 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
664
736
|
const acquiredAt = lockWaitStartedAt;
|
|
665
737
|
lockWaitStartedAt = undefined;
|
|
666
738
|
await recordRecoveryPerformanceStage(performanceRuntime, 'recovery.lock.wait', 'success', acquiredAt);
|
|
667
|
-
const
|
|
739
|
+
const preparation = await measureRecoveryPerformanceStage(performanceRuntime, 'recovery.locked.demand', () => readJointPreparation(plan.command, joint.originalOptions, true));
|
|
740
|
+
const actual = preparation.snapshot;
|
|
668
741
|
const currentIntent = (plan.options.scope === 'project' ? actual.project : actual.user).intent;
|
|
669
742
|
plan.receipt.intent = intentReceipt(currentIntent);
|
|
670
743
|
if (currentIntent.state !== 'valid' && currentIntent.state !== 'absent') {
|
|
@@ -679,7 +752,7 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
679
752
|
return plan.receipt;
|
|
680
753
|
// Recheck all backend candidates before any strong-state or output write.
|
|
681
754
|
(execution.runtime?.codexObservationSession ?? plan.runtime.codexObservationSession)?.invalidate();
|
|
682
|
-
const checked = await measureRecoveryPerformanceStage(performanceRuntime, 'recovery.locked.recheck', () => prepareJointRecovery(plan.command, joint.selectors,
|
|
755
|
+
const checked = await measureRecoveryPerformanceStage(performanceRuntime, 'recovery.locked.recheck', () => prepareJointRecovery(plan.command, joint.selectors, preparation.options, { ...plan.runtime, ...execution.runtime, awHomeMutationToken: token }, preparation.catalogReadScope ? preparation : undefined));
|
|
683
756
|
const stable = !checked.blockExecution && JSON.stringify(describeRecoveryPlan(plan)) === JSON.stringify(describeRecoveryPlan(checked));
|
|
684
757
|
await checked.context.dispose();
|
|
685
758
|
if (!stable) {
|
|
@@ -972,9 +1045,30 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
972
1045
|
receipt.ok &&= failedPackages.size === 0;
|
|
973
1046
|
receipt.outputsMayHaveChanged ||= packageResults.some((result) => result.state === 'completed');
|
|
974
1047
|
receipt.errors.push(...results.flatMap((result) => result.targetResults.flatMap((target) => target.blockers)));
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
|
|
1048
|
+
const { cwd, scope, env, cliVersion } = joint.originalOptions;
|
|
1049
|
+
const context = joint.snapshot.context.context;
|
|
1050
|
+
let statusFailure;
|
|
1051
|
+
try {
|
|
1052
|
+
// The reviewed Catalog may still be readable after Active has moved. Bind the
|
|
1053
|
+
// final read to the current sources, once per binding across both scopes.
|
|
1054
|
+
const status = await measureRecoveryPerformanceStage(runtime, 'recovery.status', () => readRecoveryStatus({ cwd, scope, context, env, cliVersion, expectedProjectRoot: joint.snapshot.context.projectRoot,
|
|
1055
|
+
catalogReadScope: new CatalogPreparationReadScope({ env }),
|
|
1056
|
+
nativeCliRunner: runtime.nativeCliRunner, codexObservationSession: runtime.codexObservationSession }));
|
|
1057
|
+
receipt.allSatisfied = status.allSatisfied;
|
|
1058
|
+
receipt.inSync = status.inSync;
|
|
1059
|
+
statusFailure = finalStatusReadFailure(status, receipt);
|
|
1060
|
+
}
|
|
1061
|
+
catch (error) {
|
|
1062
|
+
receipt.allSatisfied = null;
|
|
1063
|
+
receipt.inSync = null;
|
|
1064
|
+
statusFailure = diagnostic(readSafeOperationError(error)?.code ?? errorCode(error, 'statusUnavailable'));
|
|
1065
|
+
}
|
|
1066
|
+
if (statusFailure) {
|
|
1067
|
+
receipt.ok = false;
|
|
1068
|
+
receipt.errors.push({ code: 'statusUnavailable', message: 'Could not read the final plugin status.',
|
|
1069
|
+
subject: statusFailure.subject, detail: { reasonCode: statusFailure.code } });
|
|
1070
|
+
receipt.recoveryActions.push(`aw plugin status --context ${context} --json`);
|
|
1071
|
+
}
|
|
978
1072
|
return receipt;
|
|
979
1073
|
} });
|
|
980
1074
|
}
|