@lesliechan721/aw 0.1.0-beta.83 → 0.1.0-beta.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring/assets/aw-runtime-config.mjs +1 -1
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/src/commands/console.js +1 -0
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +1 -0
- package/dist/src/commands/intent-command.js +6 -2
- package/dist/src/commands/intent-command.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +3 -3
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +14 -13
- package/dist/src/commands/public-lifecycle-result.js +204 -64
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.d.ts +1 -2
- package/dist/src/commands/public-lifecycle.js +56 -34
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +44 -11
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +13 -3
- package/dist/src/commands/rebuild-command.js +665 -288
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +6 -2
- package/dist/src/commands/rebuild-integration.js +60 -29
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +1 -0
- package/dist/src/commands/rebuild-operations.js +28 -6
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +20 -5
- package/dist/src/commands/rebuild-platform-integration.js +752 -182
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +7 -1
- package/dist/src/generators/permissions.js +56 -0
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +112 -54
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/scope-context.d.ts +4 -2
- package/dist/src/intent/scope-context.js +37 -7
- package/dist/src/intent/scope-context.js.map +1 -1
- package/dist/src/output/component-delivery.d.ts +21 -0
- package/dist/src/output/component-delivery.js +82 -0
- package/dist/src/output/component-delivery.js.map +1 -0
- package/dist/src/output/public-result.d.ts +4 -0
- package/dist/src/output/public-result.js +85 -15
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/rebuild-progress.d.ts +3 -0
- package/dist/src/output/rebuild-progress.js +12 -2
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.js +64 -19
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/output/skill-invocation-notices.d.ts +18 -0
- package/dist/src/output/skill-invocation-notices.js +84 -0
- package/dist/src/output/skill-invocation-notices.js.map +1 -0
- package/dist/src/platforms/capabilities.d.ts +6 -1
- package/dist/src/platforms/capabilities.js +161 -38
- package/dist/src/platforms/capabilities.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +45 -10
- package/dist/src/platforms/discovery.d.ts +11 -7
- package/dist/src/platforms/discovery.js +176 -76
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/inspection-grok.js +121 -9
- package/dist/src/platforms/inspection-grok.js.map +1 -1
- package/dist/src/platforms/inspection-native.js +53 -97
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/inspection-pi.d.ts +7 -1
- package/dist/src/platforms/inspection-pi.js +295 -95
- package/dist/src/platforms/inspection-pi.js.map +1 -1
- package/dist/src/platforms/inspection-query.d.ts +6 -5
- package/dist/src/platforms/inspection-query.js +30 -25
- package/dist/src/platforms/inspection-query.js.map +1 -1
- package/dist/src/platforms/inspection.d.ts +4 -1
- package/dist/src/platforms/inspection.js +38 -6
- package/dist/src/platforms/inspection.js.map +1 -1
- package/dist/src/platforms/layout.d.ts +6 -0
- package/dist/src/platforms/layout.js +45 -12
- package/dist/src/platforms/layout.js.map +1 -1
- package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
- package/dist/src/platforms/lifecycle-native-services.js +14 -14
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.d.ts +1 -0
- package/dist/src/platforms/lifecycle-native.js +29 -89
- package/dist/src/platforms/lifecycle-native.js.map +1 -1
- package/dist/src/platforms/lifecycle.d.ts +2 -0
- package/dist/src/platforms/lifecycle.js +120 -69
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/platforms/projection-code-extension.js +9 -4
- package/dist/src/platforms/projection-code-extension.js.map +1 -1
- package/dist/src/platforms/projection.d.ts +3 -0
- package/dist/src/platforms/projection.js +152 -72
- package/dist/src/platforms/projection.js.map +1 -1
- package/dist/src/platforms/supplement-layout.d.ts +5 -1
- package/dist/src/platforms/supplement-layout.js +23 -1
- package/dist/src/platforms/supplement-layout.js.map +1 -1
- package/dist/src/platforms/supplement-state.d.ts +1 -1
- package/dist/src/platforms/supplement-state.js +18 -7
- package/dist/src/platforms/supplement-state.js.map +1 -1
- package/dist/src/portable/commands.js +1 -1
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +4 -0
- package/dist/src/portable/materializer.js +9 -2
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +31 -3
- package/dist/src/portable/recovery.js +261 -82
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +19 -5
- package/dist/src/recovery/coordinator.js +433 -174
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/install-concurrency.d.ts +48 -0
- package/dist/src/recovery/install-concurrency.js +196 -0
- package/dist/src/recovery/install-concurrency.js.map +1 -0
- package/dist/src/recovery/interruption.d.ts +19 -0
- package/dist/src/recovery/interruption.js +43 -0
- package/dist/src/recovery/interruption.js.map +1 -0
- package/dist/src/recovery/joint-coordinator.d.ts +18 -4
- package/dist/src/recovery/joint-coordinator.js +829 -341
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.d.ts +22 -2
- package/dist/src/recovery/joint-demand.js +104 -6
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/joint-install-execution.d.ts +19 -0
- package/dist/src/recovery/joint-install-execution.js +307 -0
- package/dist/src/recovery/joint-install-execution.js.map +1 -0
- package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
- package/dist/src/recovery/joint-install-native-rebase.js +67 -0
- package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
- package/dist/src/recovery/receipt.d.ts +35 -4
- package/dist/src/recovery/receipt.js +90 -1
- package/dist/src/recovery/receipt.js.map +1 -1
- package/dist/src/recovery/retirement.js +1 -1
- package/dist/src/recovery/retirement.js.map +1 -1
- package/dist/src/recovery/status.d.ts +20 -8
- package/dist/src/recovery/status.js +405 -116
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/platform-profile.d.ts +4 -1
- package/dist/src/review/platform-profile.js +14 -4
- package/dist/src/review/platform-profile.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +2 -0
- package/dist/src/review/skill-materialization.js +68 -50
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/review/source-binding.js +11 -5
- package/dist/src/review/source-binding.js.map +1 -1
- package/dist/src/tui/console-app-v4.d.ts +1 -1
- package/dist/src/tui/console-app-v4.js +180 -63
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +46 -10
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +15 -5
- package/dist/src/tui/controller.js +246 -102
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/deployment-view.d.ts +6 -3
- package/dist/src/tui/deployment-view.js +43 -9
- package/dist/src/tui/deployment-view.js.map +1 -1
- package/dist/src/tui/diagnostic-projection.d.ts +11 -3
- package/dist/src/tui/diagnostic-projection.js +85 -4
- package/dist/src/tui/diagnostic-projection.js.map +1 -1
- package/dist/src/tui/entity-cards.d.ts +2 -1
- package/dist/src/tui/entity-cards.js +34 -11
- package/dist/src/tui/entity-cards.js.map +1 -1
- package/dist/src/tui/glossary.js +5 -0
- package/dist/src/tui/glossary.js.map +1 -1
- package/dist/src/tui/model.js +2 -1
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +1 -1
- package/dist/src/tui/operation-diagnostic-screens.js +6 -2
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
- package/dist/src/tui/operation-history.d.ts +12 -3
- package/dist/src/tui/operation-history.js +34 -3
- package/dist/src/tui/operation-history.js.map +1 -1
- package/dist/src/tui/plugin-detail.d.ts +4 -1
- package/dist/src/tui/plugin-detail.js +9 -2
- package/dist/src/tui/plugin-detail.js.map +1 -1
- package/dist/src/tui/scoped-flow.d.ts +3 -1
- package/dist/src/tui/scoped-flow.js +117 -1
- package/dist/src/tui/scoped-flow.js.map +1 -1
- package/dist/src/tui/scoped-inventory.d.ts +6 -2
- package/dist/src/tui/scoped-inventory.js +29 -7
- package/dist/src/tui/scoped-inventory.js.map +1 -1
- package/dist/src/tui/session-console-app.d.ts +2 -0
- package/dist/src/tui/session-console-app.js +11 -0
- package/dist/src/tui/session-console-app.js.map +1 -1
- package/dist/src/types.d.ts +10 -2
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/artifact-plan.js +5 -1
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +1 -1
- package/dist/src/utils/artifact-renderer.js +29 -8
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.js +2 -1
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/catalog-source-references.js +14 -17
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +6 -0
- package/dist/src/utils/codex-native-observation.js +32 -3
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/component-command-preparation.d.ts +2 -0
- package/dist/src/utils/component-command-preparation.js +23 -4
- package/dist/src/utils/component-command-preparation.js.map +1 -1
- package/dist/src/utils/component-gap.d.ts +4 -0
- package/dist/src/utils/component-gap.js +20 -0
- package/dist/src/utils/component-gap.js.map +1 -0
- package/dist/src/utils/component-resources.js +2 -4
- package/dist/src/utils/component-resources.js.map +1 -1
- package/dist/src/utils/dynamic-skill-tree.js +2 -32
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.d.ts +2 -1
- package/dist/src/utils/managed-command-materialization.js +3 -3
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-store.d.ts +6 -0
- package/dist/src/utils/managed-command-store.js +90 -18
- package/dist/src/utils/managed-command-store.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +2 -0
- package/dist/src/utils/multi-source-catalog.js +3 -2
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli-interruption.d.ts +8 -0
- package/dist/src/utils/native-cli-interruption.js +65 -0
- package/dist/src/utils/native-cli-interruption.js.map +1 -0
- package/dist/src/utils/native-cli.d.ts +5 -19
- package/dist/src/utils/native-cli.js +168 -95
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +1 -0
- package/dist/src/utils/ownership.js +18 -4
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/package-content.d.ts +7 -0
- package/dist/src/utils/package-content.js +70 -0
- package/dist/src/utils/package-content.js.map +1 -0
- package/dist/src/utils/platform-empty-state.d.ts +32 -9
- package/dist/src/utils/platform-empty-state.js +135 -70
- package/dist/src/utils/platform-empty-state.js.map +1 -1
- package/dist/src/utils/plugin-config-write.d.ts +8 -0
- package/dist/src/utils/plugin-config-write.js +93 -25
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-scripts.js +24 -8
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +1 -1
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/skill-invocation-warning.d.ts +20 -0
- package/dist/src/utils/skill-invocation-warning.js +68 -0
- package/dist/src/utils/skill-invocation-warning.js.map +1 -0
- package/package.json +3 -3
- package/dist/src/output/native-consent.d.ts +0 -2
- package/dist/src/output/native-consent.js +0 -5
- package/dist/src/output/native-consent.js.map +0 -1
- package/dist/src/platforms/gemini-activation.d.ts +0 -36
- package/dist/src/platforms/gemini-activation.js +0 -331
- package/dist/src/platforms/gemini-activation.js.map +0 -1
- package/dist/src/platforms/gemini-consent.d.ts +0 -8
- package/dist/src/platforms/gemini-consent.js +0 -81
- package/dist/src/platforms/gemini-consent.js.map +0 -1
|
@@ -2,37 +2,150 @@ import crypto from 'node:crypto';
|
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
|
-
import { createMarketplaceManifestEntry,
|
|
5
|
+
import { createMarketplaceManifestEntry, getComponentFeatureRequirements, normalizeStaticPluginComponents } from '@lesliechan721/aw-plugin-core/manifest';
|
|
6
|
+
import { selectNativeProduct, supportsSharedNativeProbe } from '../platforms/discovery.js';
|
|
6
7
|
import { getAgentPluginAdapter } from '../platforms/registry.js';
|
|
7
|
-
import { getQualifiedPlatformProfile } from '../platforms/capabilities.js';
|
|
8
|
-
import { getDeploymentLayout, getDeploymentResourceKey, getInvocationPolicyPhysicalKey } from '../platforms/layout.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { getAntigravityUnsupportedSkillControls, getQualifiedPlatformProfile } from '../platforms/capabilities.js';
|
|
9
|
+
import { getDeploymentLayout, getDeploymentResourceKey, getInvocationPolicyPhysicalKey, isAntigravityProjectDirectory } from '../platforms/layout.js';
|
|
10
|
+
import { getPhysicalKey } from '../platforms/identity.js';
|
|
11
|
+
import { antigravityLegacyProjectComponent, deploymentPackageComponent, inspectStaticSupplements, requiredDeploymentActivation } from '../platforms/inspection.js';
|
|
12
|
+
import { hasCompleteDeliveryDeclaration } from '../platforms/lifecycle.js';
|
|
13
|
+
import { piAgentConsumerDiagnostic, piProjectListContainsOnly } from '../platforms/inspection-pi.js';
|
|
14
|
+
import { grokRegistrationOwned, piProjectEmptyDeliveryObserved, piProjectRegistrationHidden, piProjectRemovalConfirmed } from '../platforms/lifecycle-native.js';
|
|
11
15
|
import { createNativeLifecycleServices } from '../platforms/lifecycle-native-services.js';
|
|
12
|
-
import { assertGeminiProjectRules, geminiActivationEvidence, geminiActivationRules, geminiExtensionPaths, geminiScopePattern, geminiUserActivation, readGeminiActivationSnapshot } from '../platforms/gemini-activation.js';
|
|
13
16
|
import { cursorWorkspaceOpenCommand } from '../platforms/projection.js';
|
|
14
17
|
import { cursorHookEntryCommand, cursorHooks } from '../platforms/cursor-workspace-hook.js';
|
|
15
|
-
import { ownedSupplementFile, staticSupplementFiles } from '../platforms/supplement-layout.js';
|
|
18
|
+
import { gapSupplementFiles, ownedSupplementFile, staticSupplementFiles } from '../platforms/supplement-layout.js';
|
|
16
19
|
import { projectPlatformMarketplace } from '../platforms/projection-marketplace.js';
|
|
17
20
|
import { readStrictNamespacedMarketplaceRoot } from '../utils/local-marketplace.js';
|
|
21
|
+
import { isDeliveryCapabilityGap } from '../utils/component-gap.js';
|
|
18
22
|
import { artifactValueDigest, mergeExpectedComponentSets } from '../utils/artifact-plan.js';
|
|
19
23
|
import { preparePlatformComponents, resolveArtifactRenderConfig } from '../utils/artifact-renderer.js';
|
|
20
24
|
import { finalizePlatformSkillProducers } from '../utils/component-command-preparation.js';
|
|
21
|
-
import { cleanupOwnedComponents, createSharedOwnerToken, inspectOwnedComponents, writeOwnedTextFile, writeSkillOwnerMarker } from '../utils/ownership.js';
|
|
22
|
-
import { createPlatformInputEvidence, platformPackageInputDigest, readPlatformPackageContentDigest, writePlatformEmptyState } from '../utils/platform-empty-state.js';
|
|
25
|
+
import { cleanupOwnedComponents, createSharedOwnerToken, inspectOwnedComponents, renderOwnedTextFile, writeOwnedTextFile, writeSkillOwnerMarker } from '../utils/ownership.js';
|
|
26
|
+
import { createPlatformInputEvidence, platformPackageInputDigest, platformPermissionNotices, readPlatformPackageContentDigest, writePlatformEmptyState } from '../utils/platform-empty-state.js';
|
|
23
27
|
import { writePlatformSupplementState } from '../platforms/supplement-state.js';
|
|
24
28
|
import { atomicReplaceSafeFile, assertSafeFileMutationPath } from '../utils/safe-fs.js';
|
|
25
29
|
import { assertManagedCommandBindingIdentities, captureManagedCommandBindingRecoveryEvidence, publishManagedCommandBindings, listManagedCommands, readInstalledCommandProducer, revokeManagedCommandBindings } from '../utils/managed-command-store.js';
|
|
26
30
|
import { captureNativeToolChanges } from '../utils/native-tool-review.js';
|
|
27
31
|
import { captureManagedCommandReviewEvidence } from '../utils/managed-command-review.js';
|
|
28
32
|
import { readClaudeSettings } from '../adapters/helpers.js';
|
|
33
|
+
import { skillInvocationWarning } from '../utils/skill-invocation-warning.js';
|
|
29
34
|
import { readCodexConfigFile } from '../utils/codex-config.js';
|
|
30
35
|
import { parseOwnedTextHeader, readSkillOwnerMarker } from '../utils/ownership.js';
|
|
31
36
|
import { applyPlannedOperationAction, isNativeActivationOnlyTarget } from './rebuild-integration.js';
|
|
37
|
+
import { recoveryInterruptionCode } from '../recovery/interruption.js';
|
|
38
|
+
/** Resources touched by the frozen adapter plans, including host-managed writes. */
|
|
39
|
+
export function nativeInstallResources(plans) {
|
|
40
|
+
if (!plans.length)
|
|
41
|
+
return [{ kind: 'exclusive' }];
|
|
42
|
+
const paths = new Set();
|
|
43
|
+
for (const plan of plans) {
|
|
44
|
+
const { binding, evidence } = plan;
|
|
45
|
+
const { layout } = evidence;
|
|
46
|
+
paths.add(layout.packageRoot);
|
|
47
|
+
for (const { component } of evidence.ownership) {
|
|
48
|
+
if ('path' in component)
|
|
49
|
+
paths.add(component.path);
|
|
50
|
+
else if (component.kind === 'shared-config' && component.locator.kind === 'claude-permissions')
|
|
51
|
+
paths.add(component.locator.settingsPath);
|
|
52
|
+
else if (component.kind === 'shared-config' && component.locator.kind === 'cursor-workspace-hook')
|
|
53
|
+
paths.add(component.locator.hooksPath);
|
|
54
|
+
}
|
|
55
|
+
for (const projection of plan.projections) {
|
|
56
|
+
for (const supplement of projection.supplements)
|
|
57
|
+
paths.add(supplement.destination);
|
|
58
|
+
}
|
|
59
|
+
if (layout.marketplaceRoot) {
|
|
60
|
+
for (const file of evidence.marketplace?.files ?? [])
|
|
61
|
+
paths.add(path.join(layout.marketplaceRoot, file.relativePath));
|
|
62
|
+
}
|
|
63
|
+
// Grok inspects the entire project's packages and rules in one inventory.
|
|
64
|
+
// Keep peers out until this write and its confirming inspection finish.
|
|
65
|
+
if (binding.route === 'grok-directory') {
|
|
66
|
+
if (plan.effects.length)
|
|
67
|
+
paths.add(layout.activationPath);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
// These routes publish an entire, plugin-specific directory. activationPath
|
|
71
|
+
// is its parent and is never replaced by the directory publisher.
|
|
72
|
+
if (binding.route === 'opencode-directory' || binding.route === 'antigravity-directory')
|
|
73
|
+
continue;
|
|
74
|
+
paths.add(layout.activationPath);
|
|
75
|
+
if (binding.route === 'pi-package' || binding.route === 'cursor-workspace-hook')
|
|
76
|
+
continue;
|
|
77
|
+
for (const consumer of binding.consumers) {
|
|
78
|
+
if (!consumer.entry || consumer.entry.kind === 'generic')
|
|
79
|
+
return [{ kind: 'exclusive' }];
|
|
80
|
+
paths.add(consumer.entry.configRoot);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return [...paths].map((value) => ({ kind: 'path', value }));
|
|
84
|
+
}
|
|
85
|
+
function matchesGrokComponentOrder(before, after, publishedRoots) {
|
|
86
|
+
// Leave newly added or removed identities out of both sides. Every other
|
|
87
|
+
// row, including a surviving component of an upgraded package, anchors order.
|
|
88
|
+
const retained = (order, other) => {
|
|
89
|
+
const otherKeys = new Set(other.map(({ key }) => key));
|
|
90
|
+
return order.filter(({ sourceRoot, key }) => sourceRoot === null || !publishedRoots.has(sourceRoot) || otherKeys.has(key));
|
|
91
|
+
};
|
|
92
|
+
const previous = retained(before, after);
|
|
93
|
+
const current = retained(after, before);
|
|
94
|
+
return previous.length === current.length && previous.every((row, index) => row.key === current[index].key);
|
|
95
|
+
}
|
|
96
|
+
function grokSourceDigest(sources, root, name, scope, version) {
|
|
97
|
+
const index = sources.sources.findIndex((source) => path.normalize(source.path) === root);
|
|
98
|
+
const source = sources.sources[index];
|
|
99
|
+
if (!sources.overlaps.includes(name) && source?.name === name && source.version
|
|
100
|
+
&& (!version || source.version === version) && source.scope === scope && source.origin === 'native' && source.enabled === true) {
|
|
101
|
+
return sources.grokScopeEvidence?.sourceDigests[index];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function grokUserContentDigest({ installedRoot, owner, hasPackageHook }) {
|
|
105
|
+
try {
|
|
106
|
+
await assertSafeFileMutationPath({ filePath: path.join(installedRoot, '.grok-plugin', 'plugin.json'),
|
|
107
|
+
allowedRoot: path.dirname(path.dirname(installedRoot)), label: 'Grok installed package' });
|
|
108
|
+
const marker = await readSkillOwnerMarker({ skillRoot: owner.path, allowedRoot: owner.allowedRoot, expectedIdentity: owner.identity });
|
|
109
|
+
const projection = marker?.nativeProjection;
|
|
110
|
+
if (hasPackageHook && !projection?.components.some((component) => component.relativeOutputs.includes('hooks/hooks.json')))
|
|
111
|
+
return;
|
|
112
|
+
const digest = projection?.contentDigest;
|
|
113
|
+
if (digest && (await Promise.all([owner.path, installedRoot].map(readPlatformPackageContentDigest))).every((value) => value === digest))
|
|
114
|
+
return digest;
|
|
115
|
+
}
|
|
116
|
+
catch { /* Unverified bytes cannot explain the change of visible source. */ }
|
|
117
|
+
}
|
|
118
|
+
async function grokUserBehindProject(ctx, binding, before) {
|
|
119
|
+
const sources = before.prerequisites.nativeSources;
|
|
120
|
+
const evidence = sources?.grokScopeEvidence;
|
|
121
|
+
if (binding.route !== 'grok-directory' || before.package !== 'absent' || before.ownership !== 'absent'
|
|
122
|
+
|| sources?.observation !== 'complete' || !evidence?.userRegistrationDigest)
|
|
123
|
+
return;
|
|
124
|
+
const name = before.nativeIdentity?.packageId;
|
|
125
|
+
const user = sources.sources.find((source) => source.name === name && source.scope === 'user');
|
|
126
|
+
if (!user)
|
|
127
|
+
return;
|
|
128
|
+
const nativeDigest = grokSourceDigest(sources, user.path, user.name, 'user', binding.plugin.version);
|
|
129
|
+
if (!nativeDigest)
|
|
130
|
+
return;
|
|
131
|
+
const personal = { ...binding, route: 'grok-cli', scope: { kind: 'user' } };
|
|
132
|
+
const layout = await getDeploymentLayout(ctx, personal);
|
|
133
|
+
if (evidence.userRegistrationDigest !== artifactValueDigest([user.path, layout.packageRoot]))
|
|
134
|
+
return;
|
|
135
|
+
const owner = deploymentPackageComponent({ ...personal, physicalKey: getPhysicalKey(layout.physicalIdentity) }, layout);
|
|
136
|
+
const hasPackageHook = evidence.hookOrder.some((row) => row.sourceRoot === user.path);
|
|
137
|
+
return { installedRoot: user.path, owner, nativeDigest, hasPackageHook };
|
|
138
|
+
}
|
|
32
139
|
function nativeCopyIncomplete(binding, after, contentDigest) {
|
|
33
|
-
return ['
|
|
140
|
+
return ['antigravity-cli', 'grok-cli'].includes(binding.route)
|
|
34
141
|
&& after.nativePackageContentDigest !== contentDigest;
|
|
35
142
|
}
|
|
143
|
+
function piProjectInventoryKey(binding, settingsPath) {
|
|
144
|
+
if (binding.route !== 'pi-package' || binding.scope.kind !== 'project')
|
|
145
|
+
return undefined;
|
|
146
|
+
const product = selectNativeProduct(binding.consumers);
|
|
147
|
+
return product ? JSON.stringify([binding.scope.projectRoot, settingsPath, product.id]) : undefined;
|
|
148
|
+
}
|
|
36
149
|
function packageDeliveryConfirmed(binding, after, contentDigest, requireIndependentActivation) {
|
|
37
150
|
return after.package === 'present' && ['aw', 'shared'].includes(after.ownership)
|
|
38
151
|
&& !nativeCopyIncomplete(binding, after, contentDigest)
|
|
@@ -41,6 +154,29 @@ function packageDeliveryConfirmed(binding, after, contentDigest, requireIndepend
|
|
|
41
154
|
&& (binding.route !== 'cursor-workspace-hook' || after.workspaceOpen === 'present')
|
|
42
155
|
&& (binding.route !== 'claude-marketplace' || after.scopeRegistration === undefined || after.scopeRegistration === 'present');
|
|
43
156
|
}
|
|
157
|
+
function componentSupplementFiles(plan) {
|
|
158
|
+
return plan.projections.filter((projection) => plan.evidence.renderUnits?.some((unit) => unit.id === projection.renderUnitId && unit.output === 'supplement')).flatMap((projection) => projection.supplements
|
|
159
|
+
.filter((contribution) => contribution.kind === 'owned-file'));
|
|
160
|
+
}
|
|
161
|
+
export function nativeDeploymentHasVerifiedComponentWrite(plan, receipt) {
|
|
162
|
+
const { after, effects, unmet } = receipt;
|
|
163
|
+
if (receipt.bindingId !== plan.binding.id || after.physicalKey !== plan.binding.physicalKey)
|
|
164
|
+
return false;
|
|
165
|
+
const delivered = after.components.filter(({ id, presence, reasonCodes }) => presence === 'present' && !reasonCodes.length
|
|
166
|
+
&& !unmet.some((gap) => !isDeliveryCapabilityGap(gap) && (gap.componentId ?? gap.id) === id));
|
|
167
|
+
if (!delivered.length)
|
|
168
|
+
return false;
|
|
169
|
+
const bundle = plan.projections.find((projection) => projection.bundle)?.bundle;
|
|
170
|
+
const supplementFiles = componentSupplementFiles(plan);
|
|
171
|
+
return plan.effects.some((effect) => {
|
|
172
|
+
if (!effects.some(({ id, status, mutation }) => id === effect.id && status === 'applied' && mutation === 'confirmed'))
|
|
173
|
+
return false;
|
|
174
|
+
const deliversComponents = effect.kind === 'publish-package'
|
|
175
|
+
? !plan.evidence.retainPackage && bundle && packageDeliveryConfirmed(plan.binding, after, bundle.contentDigest, true)
|
|
176
|
+
: effect.kind === 'write-supplement' && supplementFiles.some((file) => file.destination === effect.destination);
|
|
177
|
+
return deliversComponents && effect.componentIds.some((id) => delivered.some((component) => component.id === id));
|
|
178
|
+
});
|
|
179
|
+
}
|
|
44
180
|
function recheckCopilotMarketplaceTimeout(receipt, fresh) {
|
|
45
181
|
const { ownership, registration, diagnostics } = receipt.after;
|
|
46
182
|
const [timeout] = diagnostics;
|
|
@@ -201,10 +337,12 @@ export const platformOwnership = {
|
|
|
201
337
|
};
|
|
202
338
|
async function requireWritable(component, executor = platformOwnership) {
|
|
203
339
|
const inspection = await inspectOwnedComponents({ components: [component], executor });
|
|
204
|
-
|
|
340
|
+
const state = inspection.components[0].state;
|
|
341
|
+
if (state !== 'present' && state !== 'absent')
|
|
205
342
|
throw new Error('operationPlanStale: deployment ownership changed.');
|
|
343
|
+
return state;
|
|
206
344
|
}
|
|
207
|
-
async function publishDirectory(source, component, nativeProjection) {
|
|
345
|
+
async function publishDirectory(source, component, nativeProjection, staged) {
|
|
208
346
|
if (component.kind !== 'owned-directory')
|
|
209
347
|
throw new Error('deploymentPackageOwnerInvalid');
|
|
210
348
|
await requireWritable(component);
|
|
@@ -212,17 +350,38 @@ async function publishDirectory(source, component, nativeProjection) {
|
|
|
212
350
|
allowedRoot: component.allowedRoot, label: 'Native package', createParent: true });
|
|
213
351
|
const staging = await fs.mkdtemp(path.join(component.allowedRoot, '.aw-package-'));
|
|
214
352
|
const candidate = path.join(staging, component.identity.artifactKey);
|
|
215
|
-
const
|
|
353
|
+
const verifiesContents = component.identity.platform === 'antigravity' && component.identity.scope === 'project';
|
|
354
|
+
const backupRoot = `${staging}.previous`;
|
|
355
|
+
const backup = verifiesContents ? path.join(backupRoot, component.identity.artifactKey) : backupRoot;
|
|
216
356
|
let moved = false;
|
|
217
357
|
try {
|
|
218
|
-
|
|
358
|
+
if (staged && nativeProjection) {
|
|
359
|
+
// A queued package can outlive its staging step. Verify its bytes before
|
|
360
|
+
// consuming it and keep the final rename on the destination filesystem.
|
|
361
|
+
if (await readPlatformPackageContentDigest(staged) !== nativeProjection.contentDigest) {
|
|
362
|
+
throw new Error('operationPlanStale: staged native package content changed.');
|
|
363
|
+
}
|
|
364
|
+
try {
|
|
365
|
+
await fs.rename(staged, candidate);
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
if (error.code !== 'EXDEV')
|
|
369
|
+
throw error;
|
|
370
|
+
await fs.copy(staged, candidate, { dereference: false });
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
else
|
|
374
|
+
await fs.copy(source, candidate, { dereference: false });
|
|
219
375
|
await writeSkillOwnerMarker({ skillRoot: candidate, allowedRoot: staging, identity: component.identity, nativeProjection });
|
|
220
|
-
await requireWritable(component);
|
|
221
|
-
if (await fs.pathExists(component.path)) {
|
|
376
|
+
const state = await requireWritable(component);
|
|
377
|
+
if (verifiesContents ? state === 'present' : await fs.pathExists(component.path)) {
|
|
222
378
|
await fs.move(component.path, backup);
|
|
223
379
|
moved = true;
|
|
224
380
|
}
|
|
225
381
|
try {
|
|
382
|
+
if (verifiesContents && moved && await requireWritable({ ...component, path: backup, allowedRoot: backupRoot }) !== 'present') {
|
|
383
|
+
throw new Error('operationPlanStale: deployment backup could not be verified.');
|
|
384
|
+
}
|
|
226
385
|
await fs.move(candidate, component.path);
|
|
227
386
|
}
|
|
228
387
|
catch (error) {
|
|
@@ -235,10 +394,12 @@ async function publishDirectory(source, component, nativeProjection) {
|
|
|
235
394
|
}
|
|
236
395
|
finally {
|
|
237
396
|
await fs.remove(staging);
|
|
397
|
+
if (verifiesContents)
|
|
398
|
+
await fs.rmdir(backupRoot).catch(() => undefined);
|
|
238
399
|
}
|
|
239
400
|
}
|
|
240
401
|
async function sharedReferences(context, binding, observation, layout) {
|
|
241
|
-
if (!['codex-marketplace', 'claude-marketplace', '
|
|
402
|
+
if (!['codex-marketplace', 'claude-marketplace', 'copilot-marketplace'].includes(binding.route))
|
|
242
403
|
return 'none';
|
|
243
404
|
const view = context.sharedReferenceView;
|
|
244
405
|
const same = (reference) => reference.pluginId === binding.plugin.pluginId
|
|
@@ -251,30 +412,6 @@ async function sharedReferences(context, binding, observation, layout) {
|
|
|
251
412
|
const host = binding.consumers.find((consumer) => consumer.entry?.kind === 'cli')?.entry;
|
|
252
413
|
if (!host || host.kind !== 'cli' || observation.registration === 'unknown')
|
|
253
414
|
return 'unknown';
|
|
254
|
-
if (binding.route === 'gemini-extension') {
|
|
255
|
-
try {
|
|
256
|
-
const ctx = readContext(context, binding.scope.kind === 'project' ? binding.scope.projectRoot : layout.packageRoot);
|
|
257
|
-
const snapshot = await readGeminiActivationSnapshot(ctx);
|
|
258
|
-
const rules = geminiActivationRules(snapshot, layout.nativeIdentity.packageId);
|
|
259
|
-
await assertGeminiProjectRules(ctx, binding, rules);
|
|
260
|
-
const home = geminiExtensionPaths(ctx).home;
|
|
261
|
-
const userActivation = geminiUserActivation(snapshot, layout.nativeIdentity.packageId, home);
|
|
262
|
-
if (userActivation === 'unknown')
|
|
263
|
-
return 'unknown';
|
|
264
|
-
if (binding.scope.kind === 'project' && observation.registration === 'present' && userActivation)
|
|
265
|
-
return 'present';
|
|
266
|
-
const currentPattern = binding.scope.kind === 'project' ? geminiScopePattern(binding.scope.projectRoot) : null;
|
|
267
|
-
if (rules.some((rule) => {
|
|
268
|
-
const pattern = rule.startsWith('!') ? rule.slice(1) : rule;
|
|
269
|
-
return pattern !== '*' && pattern !== geminiScopePattern(home) && pattern !== currentPattern;
|
|
270
|
-
}))
|
|
271
|
-
return 'present';
|
|
272
|
-
return view?.desiredComplete && view.scopes.includes('user') ? 'none' : 'unknown';
|
|
273
|
-
}
|
|
274
|
-
catch {
|
|
275
|
-
return 'unknown';
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
415
|
if (binding.route === 'claude-marketplace') {
|
|
279
416
|
try {
|
|
280
417
|
const installed = await jsonObject(path.join(host.configRoot, 'plugins', 'installed_plugins.json'));
|
|
@@ -337,6 +474,9 @@ export class PlatformRebuildSession {
|
|
|
337
474
|
units = new Map();
|
|
338
475
|
published = new Map();
|
|
339
476
|
nativeEffects = new Map();
|
|
477
|
+
piProjectRegisteredRoots = new Map();
|
|
478
|
+
grokPublications = new Map();
|
|
479
|
+
grokProjectRetirements = new Map();
|
|
340
480
|
exclusions = new Map();
|
|
341
481
|
contexts = new Set();
|
|
342
482
|
mutableChecks = new Map();
|
|
@@ -358,23 +498,6 @@ export class PlatformRebuildSession {
|
|
|
358
498
|
}
|
|
359
499
|
setOwnershipExecutor(executor) { this.ownership = executor; }
|
|
360
500
|
root() { return this.staging ??= fs.mkdtemp(path.join(os.tmpdir(), 'aw-deployment-')); }
|
|
361
|
-
nativeReadContext(input) {
|
|
362
|
-
const ctx = readContext(this.context, input.cwd);
|
|
363
|
-
if (input.platform === 'gemini')
|
|
364
|
-
ctx.nativeNodeCompileCacheDir = async () => {
|
|
365
|
-
const pending = this.root();
|
|
366
|
-
try {
|
|
367
|
-
return path.join(await pending, 'native-node-compile-cache');
|
|
368
|
-
}
|
|
369
|
-
catch (error) {
|
|
370
|
-
// An optional cache allocation must not poison later required staging.
|
|
371
|
-
if (this.staging === pending)
|
|
372
|
-
this.staging = undefined;
|
|
373
|
-
throw error;
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
return ctx;
|
|
377
|
-
}
|
|
378
501
|
ordinaryReadContext(ctx, platform) {
|
|
379
502
|
const batch = this.context.nativeObservationBatch;
|
|
380
503
|
// A locked re-Review starts its own observation batch. Cached targets of
|
|
@@ -383,6 +506,86 @@ export class PlatformRebuildSession {
|
|
|
383
506
|
? batch !== this.closedObservationBatch : this.targets.size === 0 && platform !== 'codex';
|
|
384
507
|
return open && batch ? { ...ctx, ...batch } : ctx;
|
|
385
508
|
}
|
|
509
|
+
recordGrokWrites(prepared, receipt, packagePublished, writtenFiles, shadowedUser) {
|
|
510
|
+
const { binding, operation, evidence: { layout } } = prepared.plan;
|
|
511
|
+
const sources = receipt.after.prerequisites.nativeSources;
|
|
512
|
+
const evidence = sources?.grokScopeEvidence;
|
|
513
|
+
if (!['grok-cli', 'grok-directory'].includes(binding.route) || operation !== 'ensure'
|
|
514
|
+
|| receipt.diagnostics.some((item) => item.severity === 'error') || sources?.observation !== 'complete' || !evidence)
|
|
515
|
+
return;
|
|
516
|
+
const scope = binding.scope.kind;
|
|
517
|
+
const scopeRoot = binding.scope.kind === 'project' ? binding.scope.projectRoot : layout.activationPath;
|
|
518
|
+
const { before, packageComponent: owner, bundle, contributions } = prepared.driverState;
|
|
519
|
+
const priorSources = before.prerequisites.nativeSources;
|
|
520
|
+
const identity = receipt.after.nativeIdentity;
|
|
521
|
+
const registrationId = identity?.registrationId;
|
|
522
|
+
const refreshed = binding.route === 'grok-cli' && registrationId && bundle
|
|
523
|
+
&& before.grokScopeAuthorization === 'granted' && receipt.after.grokScopeAuthorization === 'granted'
|
|
524
|
+
&& grokRegistrationOwned(binding, prepared.plan.evidence, before, identity)
|
|
525
|
+
&& grokRegistrationOwned(binding, prepared.plan.evidence, receipt.after, identity)
|
|
526
|
+
&& receipt.after.nativePackageContentDigest === bundle.contentDigest
|
|
527
|
+
&& prepared.plan.effects.some((effect) => effect.kind === 'refresh' && receipt.effects.some((result) => result.id === effect.id && result.status === 'applied' && result.mutation === 'confirmed'));
|
|
528
|
+
// A previous refusal can leave the AW source up to date. Only the confirmed
|
|
529
|
+
// native refresh explains a change to the User inventory in this operation.
|
|
530
|
+
const installedRoot = refreshed ? path.join(scopeRoot, 'installed-plugins', registrationId) : undefined;
|
|
531
|
+
const root = installedRoot ?? path.normalize(layout.packageRoot);
|
|
532
|
+
if ((refreshed || binding.route === 'grok-directory' && packagePublished) && priorSources?.observation === 'complete'
|
|
533
|
+
&& receipt.after.package === 'present' && receipt.after.ownership === 'aw' && bundle
|
|
534
|
+
&& owner?.kind === 'owned-directory' && owner.path === layout.packageRoot && identity?.route === binding.route
|
|
535
|
+
&& identity.sourceLocation === layout.packageRoot) {
|
|
536
|
+
const newlyInstalled = binding.route === 'grok-directory' && before.package === 'absent' && before.ownership === 'absent'
|
|
537
|
+
&& !priorSources.sources.some((source) => path.normalize(source.path) === root
|
|
538
|
+
|| source.name === identity.packageId && source.path !== shadowedUser?.installedRoot)
|
|
539
|
+
&& (!shadowedUser || !sources.sources.some((source) => source.path === shadowedUser.installedRoot));
|
|
540
|
+
const priorNativeDigest = before.package === 'present' && before.ownership === 'aw' && (refreshed || before.packageVersion)
|
|
541
|
+
? grokSourceDigest(priorSources, root, identity.packageId, scope, refreshed ? undefined : before.packageVersion) : undefined;
|
|
542
|
+
const nativeDigest = grokSourceDigest(sources, root, identity.packageId, scope, binding.plugin.version);
|
|
543
|
+
const knownHooks = !evidence.hookOrder.some((row) => row.sourceRoot === root) || prepared.plan.projections.some((projection) => projection.bundle
|
|
544
|
+
&& projection.components.some((component) => component.relativeOutputs.includes('hooks/hooks.json')));
|
|
545
|
+
if ((newlyInstalled || priorNativeDigest) && nativeDigest && knownHooks) {
|
|
546
|
+
this.grokPublications.set(root, { scope, scopeRoot, installedRoot, nativeDigest, priorNativeDigest, contentDigest: bundle.contentDigest,
|
|
547
|
+
owner, orderAfter: evidence, shadowedUser,
|
|
548
|
+
sourceOrderAfter: shadowedUser && sources.sources.map((source) => path.normalize(source.path)) });
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const prior = priorSources?.grokScopeEvidence?.instructions;
|
|
552
|
+
for (const { effectId, component } of contributions) {
|
|
553
|
+
if (component.kind !== 'owned-text-file' || !prior)
|
|
554
|
+
continue;
|
|
555
|
+
const written = writtenFiles.get(component.path);
|
|
556
|
+
const rows = evidence.instructions.filter((row) => row.rulePath === component.path);
|
|
557
|
+
const previous = prior.filter((row) => row.rulePath === component.path);
|
|
558
|
+
if (written && rows.length === 1 && previous.length <= 1 && receipt.effects.some((effect) => effect.id === effectId && effect.status === 'applied' && effect.mutation === 'confirmed')) {
|
|
559
|
+
this.grokPublications.set(component.path, { scope, scopeRoot, nativeDigest: rows[0].digest,
|
|
560
|
+
priorNativeDigest: previous[0]?.digest, contentDigest: written.digest, owner: component });
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
recordGrokProjectRetirement(projectRoot, project, user, removed) {
|
|
565
|
+
const old = project.nativeIdentity;
|
|
566
|
+
const replacement = user.nativeIdentity;
|
|
567
|
+
if (old?.route !== 'grok-directory' || project.ownership !== 'aw' || project.package !== 'present'
|
|
568
|
+
|| replacement?.route !== 'grok-cli' || replacement.packageId !== old.packageId || !replacement.registrationId
|
|
569
|
+
|| user.ownership !== 'aw' || user.registration !== 'present' || user.nativePackage !== 'present' || !user.nativePackageContentDigest
|
|
570
|
+
|| path.dirname(old.sourceLocation) !== path.join(projectRoot, '.grok', 'plugins') || !removed.includes(path.basename(old.sourceLocation)))
|
|
571
|
+
return;
|
|
572
|
+
const before = project.prerequisites.nativeSources;
|
|
573
|
+
const personal = user.prerequisites.nativeSources;
|
|
574
|
+
if (before?.observation !== 'complete' || personal?.observation !== 'complete')
|
|
575
|
+
return;
|
|
576
|
+
const source = personal.sources.find(({ name, path: location }) => name === old.packageId
|
|
577
|
+
&& path.basename(location) === replacement.registrationId && path.basename(path.dirname(location)) === 'installed-plugins');
|
|
578
|
+
const projectDigest = grokSourceDigest(before, old.sourceLocation, old.packageId, 'project');
|
|
579
|
+
const userDigest = source && grokSourceDigest(personal, source.path, old.packageId, 'user');
|
|
580
|
+
if (!projectDigest || !source || !userDigest)
|
|
581
|
+
return;
|
|
582
|
+
// Retirement can reveal an inherited static Skill provider only.
|
|
583
|
+
if (personal.grokScopeEvidence?.hookOrder.some((row) => row.sourceRoot === source.path))
|
|
584
|
+
return;
|
|
585
|
+
this.grokProjectRetirements.set(old.sourceLocation, { projectRoot, name: old.packageId, projectPackage: old.sourceLocation,
|
|
586
|
+
projectDigest, userPackage: source.path, userDigest, userSource: replacement.sourceLocation,
|
|
587
|
+
userContentDigest: user.nativePackageContentDigest, userPhysicalKey: user.physicalKey });
|
|
588
|
+
}
|
|
386
589
|
async dispose() {
|
|
387
590
|
for (const result of await Promise.allSettled(this.units.values()))
|
|
388
591
|
if (result.status === 'fulfilled')
|
|
@@ -395,7 +598,10 @@ export class PlatformRebuildSession {
|
|
|
395
598
|
this.units.clear();
|
|
396
599
|
this.published.clear();
|
|
397
600
|
this.nativeEffects.clear();
|
|
601
|
+
this.piProjectRegisteredRoots.clear();
|
|
398
602
|
this.exclusions.clear();
|
|
603
|
+
this.grokPublications.clear();
|
|
604
|
+
this.grokProjectRetirements.clear();
|
|
399
605
|
this.contexts.clear();
|
|
400
606
|
this.mutableChecks.clear();
|
|
401
607
|
this.requestedOperations.clear();
|
|
@@ -405,7 +611,7 @@ export class PlatformRebuildSession {
|
|
|
405
611
|
}
|
|
406
612
|
freezeMarketplaceCandidates() { this.marketplaceCandidatesFrozen = true; }
|
|
407
613
|
key(input) { return artifactValueDigest({ plugin: sourceIdentity(input), platform: input.platform, scope: input.scope, cwd: input.scope === 'project' ? input.cwd : null, operation: operation(input) }); }
|
|
408
|
-
resolve(input) {
|
|
614
|
+
resolve(input, placementProbeGroup) {
|
|
409
615
|
const key = this.key(input);
|
|
410
616
|
// Inspection of a shared package does not request activation in that scope.
|
|
411
617
|
if (!input.readOnlyInspectionPlan)
|
|
@@ -414,13 +620,14 @@ export class PlatformRebuildSession {
|
|
|
414
620
|
if (!result) {
|
|
415
621
|
result = (async () => {
|
|
416
622
|
const adapter = this.adapterFor(input.platform);
|
|
417
|
-
const ctx =
|
|
623
|
+
const ctx = input.readOnlyInspectionPlan && input.observationBatch ? { ...readContext(this.context, input.cwd), ...input.observationBatch }
|
|
624
|
+
: this.ordinaryReadContext(readContext(this.context, input.cwd), input.platform);
|
|
418
625
|
const plugin = sourceIdentity(input);
|
|
419
626
|
const recoveryCandidates = (this.context.recoveryCandidates ?? []).filter((candidate) => candidate.binding.platform === input.platform
|
|
420
627
|
&& candidate.binding.plugin.sourceIdentity === plugin.sourceIdentity && candidate.binding.plugin.pluginId === plugin.pluginId
|
|
421
628
|
&& candidate.binding.scope.kind === input.scope && (candidate.binding.scope.kind !== 'project' || candidate.binding.scope.projectRoot === input.cwd));
|
|
422
629
|
const scope = input.scope === 'project' ? { kind: 'project', projectRoot: input.cwd } : { kind: 'user' };
|
|
423
|
-
const discovery = await adapter.discover(ctx);
|
|
630
|
+
const discovery = await adapter.discover(placementProbeGroup ? { ...ctx, placementProbeGroup } : ctx);
|
|
424
631
|
const resolution = await adapter.resolve(ctx, { plugin, scope, operation: operation(input), discovery, recoveryCandidates });
|
|
425
632
|
this.exclusions.set(key, resolution.exclusions.flatMap((exclusion) => {
|
|
426
633
|
if (!exclusion.productId)
|
|
@@ -447,7 +654,13 @@ export class PlatformRebuildSession {
|
|
|
447
654
|
}
|
|
448
655
|
/** Resolve the whole selected scope before any physical unit is rendered. */
|
|
449
656
|
async resolveAll(inputs) {
|
|
450
|
-
|
|
657
|
+
const first = inputs[0];
|
|
658
|
+
const samePlacement = supportsSharedNativeProbe && first && inputs.length > 1
|
|
659
|
+
&& this.context.batchInstallPlatform === first.platform && this.context.nativeObservationBatch?.scriptFreePlacement === true
|
|
660
|
+
&& inputs.every((input) => input.platform === first.platform && input.scope === first.scope && input.cwd === first.cwd
|
|
661
|
+
&& operation(input) === 'ensure');
|
|
662
|
+
const group = samePlacement ? { scope: first.scope, probes: new Map() } : undefined;
|
|
663
|
+
await Promise.allSettled(inputs.map((input) => this.resolve(input, group)));
|
|
451
664
|
}
|
|
452
665
|
async freezeSharedPreApplyActions(targets) {
|
|
453
666
|
const prepared = (await Promise.allSettled(this.targets.values())).flatMap((result) => result.status === 'fulfilled' ? [result.value] : []);
|
|
@@ -455,7 +668,7 @@ export class PlatformRebuildSession {
|
|
|
455
668
|
if (target.identity.scope !== 'project' || !target.operationActions?.some((action) => action.kind === 'runPreApply'))
|
|
456
669
|
continue;
|
|
457
670
|
const plans = target.platformDeployment?.plans ?? [];
|
|
458
|
-
if (!plans.length || plans.some((plan) => !['codex-marketplace', 'claude-marketplace', '
|
|
671
|
+
if (!plans.length || plans.some((plan) => !['codex-marketplace', 'claude-marketplace', 'copilot-marketplace'].includes(plan.binding.route)
|
|
459
672
|
|| plan.effects.some((effect) => effect.physicalKey !== plan.binding.physicalKey)
|
|
460
673
|
|| plan.projections.some((projection) => projection.supplements.length > 0)
|
|
461
674
|
|| !plan.evidence.renderUnits?.some((unit) => unit.output === 'package' && unit.renderScope.kind === 'user')))
|
|
@@ -616,12 +829,13 @@ export class PlatformRebuildSession {
|
|
|
616
829
|
if (verifyInitial)
|
|
617
830
|
await verifyInitial();
|
|
618
831
|
else
|
|
619
|
-
await result.platformDeployment?.verify();
|
|
832
|
+
await result.platformDeployment?.verify(input.observationBatch);
|
|
620
833
|
return result;
|
|
621
834
|
}
|
|
622
835
|
async build(input, receiveInitialVerifier) {
|
|
623
|
-
const ctx = this.
|
|
624
|
-
const ordinaryCtx =
|
|
836
|
+
const ctx = readContext(this.context, input.cwd);
|
|
837
|
+
const ordinaryCtx = input.readOnlyInspectionPlan && input.observationBatch ? { ...ctx, ...input.observationBatch }
|
|
838
|
+
: this.ordinaryReadContext(ctx, input.platform);
|
|
625
839
|
const resolution = await this.resolve(input);
|
|
626
840
|
if (!resolution.bindings.length)
|
|
627
841
|
throw Object.assign(new Error(`platformUnavailable: ${resolution.exclusions.map((item) => item.reasonCode).join(', ') || input.platform}`), { deploymentExclusions: this.exclusions.get(this.key(input)) ?? [] });
|
|
@@ -688,8 +902,13 @@ export class PlatformRebuildSession {
|
|
|
688
902
|
env: this.context.env, referencePlugins: this.context.referencePlugins });
|
|
689
903
|
const platformRoot = path.join(input.plugin.rootDir, input.platform);
|
|
690
904
|
const staticResourceRoot = await fs.pathExists(platformRoot) ? platformRoot : input.plugin.rootDir;
|
|
905
|
+
// Grok prepares the package before its rules. Only roles prepared for this same target can receive the text.
|
|
906
|
+
const grokRoleUnit = input.platform === 'grok' && unit.output === 'supplement'
|
|
907
|
+
? bindingEntry.layout.renderUnits.find((candidate) => candidate.output === 'package'
|
|
908
|
+
&& artifactValueDigest(candidate.renderScope) === artifactValueDigest(unit.renderScope)) : undefined;
|
|
691
909
|
const prepared = await preparePlatformComponents({ plugin: input.plugin, platform: input.platform, staticResourceRoot,
|
|
692
910
|
renderScope: unit.renderScope.kind, kinds: unit.kinds, capabilities, config, cwd: input.cwd,
|
|
911
|
+
hasInstructionAgentRecipients: grokRoleUnit && preparedUnits.get(grokRoleUnit.id)?.prepared.expected.components.some(({ kind }) => kind === 'agent'),
|
|
693
912
|
commandEnv: this.context.env, signal: this.context.signal, scriptTimeoutMs: this.context.scriptTimeoutMs,
|
|
694
913
|
preparedResults: this.context.preparedArtifactRenderResults });
|
|
695
914
|
const finalized = await finalizePlatformSkillProducers({ plugin: input.plugin, plugins: this.context.referencePlugins,
|
|
@@ -708,11 +927,13 @@ export class PlatformRebuildSession {
|
|
|
708
927
|
const blockedReceipts = [];
|
|
709
928
|
const cleanupResults = [];
|
|
710
929
|
const checks = new Map();
|
|
930
|
+
const shadowedUsers = new Map();
|
|
711
931
|
let initialDiscoveryCheck;
|
|
712
932
|
const priorProducers = new Map();
|
|
713
933
|
const priorResourceRoots = new Map();
|
|
714
934
|
const bindingRecoveryEvidence = [];
|
|
715
935
|
const emptyStates = new Map();
|
|
936
|
+
const gapStates = new Map();
|
|
716
937
|
const inputDigests = new Map();
|
|
717
938
|
const supplementInputDigests = new Map();
|
|
718
939
|
const commandInventory = await listManagedCommands(this.context.env);
|
|
@@ -767,16 +988,26 @@ export class PlatformRebuildSession {
|
|
|
767
988
|
files: sameScope.flatMap((candidate) => candidate.prepared.resources.files),
|
|
768
989
|
commandResources: sameScope.flatMap((candidate) => candidate.prepared.resources.commandResources),
|
|
769
990
|
digest: artifactValueDigest(sameScope.map((candidate) => candidate.prepared.resources.digest)) };
|
|
770
|
-
|
|
991
|
+
const projection = await adapter.project({ ...ctx, stagingRoot: path.join(await this.root(), 'projection'), commandResolver: unit.finalized.commandResolver }, {
|
|
771
992
|
binding: entry.binding, renderUnit: unit.unit, capabilities: adapter.capabilities({ ...entry, renderUnit: unit.unit, profile: getQualifiedPlatformProfile(input.platform) }),
|
|
772
|
-
components, resources, policy: components.length ?
|
|
773
|
-
})
|
|
993
|
+
components, resources, policy: components.length ? unit.finalized.invocationPolicy.policy : { platform: input.platform, permissions: [] }
|
|
994
|
+
});
|
|
995
|
+
for (const notice of unit.finalized.invocationPolicy.diagnostics) {
|
|
996
|
+
projection.diagnostics.push({ ...notice, subject: { ...notice.subject, scope: entry.binding.scope.kind } });
|
|
997
|
+
}
|
|
998
|
+
projections.push(projection);
|
|
774
999
|
}
|
|
775
1000
|
const policyKey = input.platform === 'codex' || input.platform === 'claude' ? await getInvocationPolicyPhysicalKey(ctx, entry.binding) : undefined;
|
|
1001
|
+
const expected = mergeExpectedComponentSets(units.map((unit) => unit.prepared.expected));
|
|
776
1002
|
const currentComponents = [deploymentPackageComponent(entry.binding, entry.layout),
|
|
777
1003
|
...projections.flatMap((projection) => projection.supplements.map((contribution) => contributionComponent(entry.binding, contribution, policyKey && (contribution.mergeKey?.startsWith('claude-permissions:') || input.platform === 'codex' && contribution.destination.endsWith('.rules'))
|
|
778
1004
|
? policyKey : entry.layout.renderUnits.find((unit) => unit.id === projection.renderUnitId).physicalKey)))];
|
|
779
1005
|
const historical = await ownedSupplements(entry.binding, entry.layout.supplementRoot, entry.layout.renderUnits.find((unit) => unit.output === 'supplement')?.physicalKey);
|
|
1006
|
+
const antigravityProject = isAntigravityProjectDirectory(entry.binding);
|
|
1007
|
+
const legacyPackage = entry.observation.antigravityLegacyProjectPackage?.state === 'owned'
|
|
1008
|
+
? antigravityLegacyProjectComponent(entry.binding, entry.layout) : undefined;
|
|
1009
|
+
if (legacyPackage)
|
|
1010
|
+
historical.push(legacyPackage);
|
|
780
1011
|
if (entry.binding.platform === 'codex' && policyKey)
|
|
781
1012
|
historical.push(...await ownedSupplements(entry.binding, path.join(entry.layout.activationPath, 'rules'), policyKey));
|
|
782
1013
|
if (entry.binding.platform === 'claude' && policyKey) {
|
|
@@ -791,6 +1022,10 @@ export class PlatformRebuildSession {
|
|
|
791
1022
|
component.locator.command = cursorWorkspaceOpenCommand(entry.binding, ctx.platform);
|
|
792
1023
|
historical.push(component);
|
|
793
1024
|
}
|
|
1025
|
+
for (const slot of gapSupplementFiles(entry.binding, entry.layout, expected.unmet)) {
|
|
1026
|
+
if (!historical.some((component) => 'path' in component && component.path === slot.path))
|
|
1027
|
+
historical.push(slot);
|
|
1028
|
+
}
|
|
794
1029
|
const components = [...currentComponents, ...historical.filter((component) => !currentComponents.some((current) => 'path' in current && 'path' in component && current.path === component.path
|
|
795
1030
|
|| current.kind === 'shared-config' && component.kind === 'shared-config' && artifactValueDigest(current.locator) === artifactValueDigest(component.locator)))];
|
|
796
1031
|
for (const component of components)
|
|
@@ -808,15 +1043,16 @@ export class PlatformRebuildSession {
|
|
|
808
1043
|
const inspected = await inspectOwnedComponents({ components, executor: this.ownership });
|
|
809
1044
|
const managedCommandReview = await captureManagedCommandReviewEvidence({ binding: entry.binding,
|
|
810
1045
|
renderUnits: entry.layout.renderUnits, components: units.flatMap((unit) => unit.prepared.expected.components), projections });
|
|
811
|
-
const currentMutable = async () => {
|
|
812
|
-
const observation = await adapter.inspect(ctx, entry.binding);
|
|
1046
|
+
const currentMutable = async (batch) => {
|
|
1047
|
+
const observation = await adapter.inspect(batch ? { ...ctx, ...batch } : ctx, entry.binding);
|
|
813
1048
|
return { observation, references: await sharedReferences(this.context, entry.binding, observation, entry.layout),
|
|
814
|
-
geminiActivation: entry.binding.route === 'gemini-extension' ? geminiActivationEvidence(await readGeminiActivationSnapshot(ctx)) : undefined,
|
|
815
1049
|
paths: await Promise.all(components.map(async (component) => 'path' in component ? pathEvidence(component.path) : {
|
|
816
1050
|
ownership: await inspectOwnedComponents({ components: [component], executor: this.ownership }), contentDigest: await ownedContentDigest(component),
|
|
817
1051
|
})) };
|
|
818
1052
|
};
|
|
1053
|
+
const shadowedUser = operation(input) === 'ensure' ? await grokUserBehindProject(ctx, entry.binding, entry.observation) : undefined;
|
|
819
1054
|
const fingerprintParts = async (discovery) => ({
|
|
1055
|
+
...(shadowedUser && { grokUserContent: await grokUserContentDigest(shadowedUser) }),
|
|
820
1056
|
managedCommandReview,
|
|
821
1057
|
source: removing ? null : await pathEvidence(input.plugin.rootDir),
|
|
822
1058
|
discovery: discovery ? discovery.value : removing ? { consumers: entry.binding.consumers, executables: await Promise.all(entry.binding.consumers.map((consumer) => consumer.entry?.kind === 'cli' ? pathEvidence(consumer.entry.executable) : null)) } : await adapter.discover(ctx),
|
|
@@ -832,12 +1068,15 @@ export class PlatformRebuildSession {
|
|
|
832
1068
|
});
|
|
833
1069
|
// Discovery and inspection are independent reads for these routes. Settle
|
|
834
1070
|
// both before comparing or throwing, while preserving immutable priority.
|
|
835
|
-
const parallelNativeReads = ['
|
|
1071
|
+
const parallelNativeReads = ['copilot-marketplace', 'pi-package'].includes(entry.binding.route);
|
|
836
1072
|
const initialReads = parallelNativeReads
|
|
837
1073
|
? await Promise.allSettled([fingerprintParts(), currentMutable()]) : null;
|
|
838
1074
|
if (initialReads?.[0].status === 'rejected')
|
|
839
1075
|
throw initialReads[0].reason;
|
|
840
1076
|
const initialParts = initialReads?.[0].status === 'fulfilled' ? initialReads[0].value : await fingerprintParts();
|
|
1077
|
+
if (shadowedUser && initialParts.grokUserContent) {
|
|
1078
|
+
shadowedUsers.set(entry.binding.id, { ...shadowedUser, contentDigest: initialParts.grokUserContent });
|
|
1079
|
+
}
|
|
841
1080
|
if (!removing && ordinaryEvidence && ordinaryEvidence.discovery !== artifactValueDigest(initialParts.discovery)) {
|
|
842
1081
|
throw new Error('operationPlanStale: client discovery changed after the ordinary observation.');
|
|
843
1082
|
}
|
|
@@ -850,31 +1089,215 @@ export class PlatformRebuildSession {
|
|
|
850
1089
|
if (ordinaryObservation !== undefined && ordinaryObservation !== artifactValueDigest(mutableBaseline.observation)) {
|
|
851
1090
|
throw new Error('operationPlanStale: deployment evidence changed after the ordinary observation.');
|
|
852
1091
|
}
|
|
853
|
-
const preparationObservation = entry.binding.route === '
|
|
1092
|
+
const preparationObservation = entry.binding.route === 'antigravity-cli' || antigravityProject
|
|
854
1093
|
? mutableBaseline.observation : entry.observation;
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
1094
|
+
const piInventoryKey = piProjectInventoryKey(entry.binding, entry.layout.activationPath);
|
|
1095
|
+
const matchesMutable = (current) => {
|
|
1096
|
+
const currentDigest = artifactValueDigest(current);
|
|
1097
|
+
if (currentDigest === artifactValueDigest(mutableBaseline))
|
|
1098
|
+
return true;
|
|
1099
|
+
const registered = piInventoryKey && this.piProjectRegisteredRoots.get(piInventoryKey);
|
|
1100
|
+
if (!registered || operation(input) !== 'ensure' || !piProjectEmptyDeliveryObserved(entry.binding, mutableBaseline.observation)
|
|
1101
|
+
|| current.observation.registration !== 'absent' || !piProjectListContainsOnly(current.observation, registered))
|
|
863
1102
|
return false;
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
1103
|
+
// The first successful register in an empty Project can expose its
|
|
1104
|
+
// section. Compare every other fact with the original empty target.
|
|
1105
|
+
const { observation: before, ...baseline } = mutableBaseline;
|
|
1106
|
+
return currentDigest === artifactValueDigest({ ...baseline,
|
|
1107
|
+
observation: { ...before, registration: 'absent',
|
|
1108
|
+
diagnostics: before.diagnostics.filter(({ code }) => code !== 'piProjectRegistrationNotVisible') } });
|
|
1109
|
+
};
|
|
1110
|
+
const matchesAfterGrokPublications = async (current) => {
|
|
1111
|
+
const { binding } = entry;
|
|
1112
|
+
const scopeRoot = binding.route === 'grok-cli' ? entry.layout.activationPath
|
|
1113
|
+
: binding.route === 'grok-directory' && binding.scope.kind === 'project' ? binding.scope.projectRoot : null;
|
|
1114
|
+
const publications = scopeRoot && operation(input) === 'ensure' ? [...this.grokPublications.values()].filter((item) => item.scope === binding.scope.kind && item.scopeRoot === scopeRoot && item.owner.identity.pluginId !== binding.plugin.pluginId) : [];
|
|
1115
|
+
const retirements = binding.route === 'grok-directory' && operation(input) === 'ensure'
|
|
1116
|
+
? [...this.grokProjectRetirements.values()].filter((item) => item.projectRoot === scopeRoot) : [];
|
|
1117
|
+
const baselineDigest = artifactValueDigest(mutableBaseline);
|
|
1118
|
+
if (!publications.length && !retirements.length)
|
|
1119
|
+
return artifactValueDigest(current) === baselineDigest;
|
|
1120
|
+
const before = mutableBaseline.observation.prerequisites.nativeSources;
|
|
1121
|
+
const after = current.observation.prerequisites.nativeSources;
|
|
1122
|
+
const priorEvidence = before?.grokScopeEvidence;
|
|
1123
|
+
const scopeEvidence = after?.grokScopeEvidence;
|
|
1124
|
+
if (before?.observation !== 'complete' || after?.observation !== 'complete' || !scopeEvidence || !priorEvidence
|
|
1125
|
+
|| scopeEvidence.scopeDigest !== priorEvidence.scopeDigest)
|
|
1126
|
+
return false;
|
|
1127
|
+
const paths = after.sources.map((source) => path.normalize(source.path));
|
|
1128
|
+
const priorPaths = before.sources.map((source) => path.normalize(source.path));
|
|
1129
|
+
if (new Set(paths).size !== paths.length || new Set(priorPaths).size !== priorPaths.length)
|
|
1130
|
+
return false;
|
|
1131
|
+
const sources = [...after.sources];
|
|
1132
|
+
const sourceDigests = [...scopeEvidence.sourceDigests];
|
|
1133
|
+
const addedSources = new Set();
|
|
1134
|
+
const publishedRoots = new Set();
|
|
1135
|
+
const orderChecks = [priorEvidence];
|
|
1136
|
+
const instructions = [...scopeEvidence.instructions];
|
|
1137
|
+
const retiredSources = new Set();
|
|
1138
|
+
let adjusted = false;
|
|
1139
|
+
for (const retirement of retirements) {
|
|
1140
|
+
const { name, projectPackage, projectDigest, userPackage, userDigest, userSource, userContentDigest, userPhysicalKey } = retirement;
|
|
1141
|
+
if (!priorPaths.includes(projectPackage))
|
|
1142
|
+
continue;
|
|
1143
|
+
if (name === entry.layout.nativeIdentity.packageId || priorPaths.includes(userPackage) || paths.includes(projectPackage)
|
|
1144
|
+
|| grokSourceDigest(before, projectPackage, name, 'project') !== projectDigest
|
|
1145
|
+
|| grokSourceDigest(after, userPackage, name, 'user') !== userDigest
|
|
1146
|
+
|| await pathEvidence(projectPackage) !== null)
|
|
1147
|
+
return false;
|
|
1148
|
+
await assertSafeFileMutationPath({ filePath: path.join(userPackage, '.grok-plugin', 'plugin.json'),
|
|
1149
|
+
allowedRoot: path.dirname(path.dirname(userPackage)), label: 'Grok installed package' });
|
|
1150
|
+
const [installed, source, marker] = await Promise.all([readPlatformPackageContentDigest(userPackage), readPlatformPackageContentDigest(userSource),
|
|
1151
|
+
readSkillOwnerMarker({ skillRoot: userSource, allowedRoot: path.dirname(userSource) })]);
|
|
1152
|
+
if (installed !== userContentDigest || source !== userContentDigest || marker?.physicalKey !== userPhysicalKey)
|
|
1153
|
+
return false;
|
|
1154
|
+
// The Project copy hid this exact User copy. Both may leave their
|
|
1155
|
+
// old positions, and the remaining sources and components keep theirs.
|
|
1156
|
+
retiredSources.add(projectPackage);
|
|
1157
|
+
addedSources.add(userPackage);
|
|
1158
|
+
publishedRoots.add(projectPackage);
|
|
1159
|
+
publishedRoots.add(userPackage);
|
|
1160
|
+
adjusted = true;
|
|
1161
|
+
}
|
|
1162
|
+
for (const { owner, scopeRoot: publishedRoot, installedRoot, nativeDigest, contentDigest, priorNativeDigest, orderAfter, shadowedUser } of publications) {
|
|
1163
|
+
ctx.signal?.throwIfAborted();
|
|
1164
|
+
if (owner.kind === 'owned-directory') {
|
|
1165
|
+
const root = installedRoot ?? owner.path;
|
|
1166
|
+
const index = paths.indexOf(root);
|
|
1167
|
+
if (scopeEvidence.sourceDigests[index] !== nativeDigest || after.sources[index]?.name === entry.layout.nativeIdentity.packageId)
|
|
1168
|
+
return false;
|
|
1169
|
+
const priorIndex = priorPaths.indexOf(root);
|
|
1170
|
+
const priorDigest = priorEvidence.sourceDigests[priorIndex];
|
|
1171
|
+
if (shadowedUser) {
|
|
1172
|
+
const hidden = shadowedUser.installedRoot;
|
|
1173
|
+
if (paths.includes(hidden) || await grokUserContentDigest(shadowedUser) !== shadowedUser.contentDigest)
|
|
1174
|
+
return false;
|
|
1175
|
+
if (priorIndex < 0) {
|
|
1176
|
+
if (grokSourceDigest(before, hidden, owner.identity.plugin, 'user') !== shadowedUser.nativeDigest)
|
|
1177
|
+
return false;
|
|
1178
|
+
retiredSources.add(hidden);
|
|
1179
|
+
publishedRoots.add(hidden);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
if (priorDigest !== nativeDigest) {
|
|
1183
|
+
if (priorDigest !== priorNativeDigest)
|
|
1184
|
+
return false;
|
|
1185
|
+
publishedRoots.add(root);
|
|
1186
|
+
if (orderAfter)
|
|
1187
|
+
orderChecks.push(orderAfter);
|
|
1188
|
+
// Restore the frozen source at its current position. Moving a
|
|
1189
|
+
// source or changing any other source still invalidates the plan.
|
|
1190
|
+
if (priorIndex < 0)
|
|
1191
|
+
addedSources.add(root);
|
|
1192
|
+
else {
|
|
1193
|
+
sources[index] = before.sources[priorIndex];
|
|
1194
|
+
sourceDigests[index] = priorDigest;
|
|
1195
|
+
}
|
|
1196
|
+
adjusted = true;
|
|
1197
|
+
}
|
|
1198
|
+
const marker = await readSkillOwnerMarker({ skillRoot: owner.path, allowedRoot: owner.allowedRoot,
|
|
1199
|
+
expectedIdentity: owner.identity }).catch(() => null);
|
|
1200
|
+
const observedContent = marker?.nativeProjection?.contentDigest === contentDigest
|
|
1201
|
+
? await readPlatformPackageContentDigest(owner.path).catch(() => undefined) : undefined;
|
|
1202
|
+
if (observedContent !== contentDigest)
|
|
1203
|
+
return false;
|
|
1204
|
+
if (installedRoot) {
|
|
1205
|
+
try {
|
|
1206
|
+
await assertSafeFileMutationPath({ filePath: path.join(installedRoot, '.grok-plugin', 'plugin.json'),
|
|
1207
|
+
allowedRoot: publishedRoot, label: 'Grok installed package' });
|
|
1208
|
+
if (await readPlatformPackageContentDigest(installedRoot) !== contentDigest)
|
|
1209
|
+
return false;
|
|
1210
|
+
}
|
|
1211
|
+
catch {
|
|
1212
|
+
ctx.signal?.throwIfAborted();
|
|
1213
|
+
return false;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
const matches = instructions.filter((row) => row.rulePath === owner.path);
|
|
1219
|
+
if (matches.length !== 1 || matches[0].digest !== nativeDigest)
|
|
1220
|
+
return false;
|
|
1221
|
+
const index = instructions.indexOf(matches[0]);
|
|
1222
|
+
const prior = priorEvidence.instructions.find((row) => row.rulePath === owner.path);
|
|
1223
|
+
if (prior?.digest !== nativeDigest) {
|
|
1224
|
+
if (prior?.digest !== priorNativeDigest)
|
|
1225
|
+
return false;
|
|
1226
|
+
instructions.splice(index, 1, ...(prior ? [prior] : []));
|
|
1227
|
+
adjusted = true;
|
|
1228
|
+
}
|
|
1229
|
+
// The written hash includes the exact owner header. Grok's size
|
|
1230
|
+
// and token count alone cannot detect a same-length external edit.
|
|
1231
|
+
try {
|
|
1232
|
+
await assertSafeFileMutationPath({ filePath: owner.path, allowedRoot: publishedRoot, label: 'Grok rule' });
|
|
1233
|
+
const bytes = await fs.readFile(owner.path);
|
|
1234
|
+
if (crypto.createHash('sha256').update(bytes).digest('hex') !== contentDigest)
|
|
1235
|
+
return false;
|
|
1236
|
+
}
|
|
1237
|
+
catch {
|
|
1238
|
+
ctx.signal?.throwIfAborted();
|
|
1239
|
+
return false;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
ctx.signal?.throwIfAborted();
|
|
1244
|
+
if (!adjusted)
|
|
1245
|
+
return artifactValueDigest(current) === baselineDigest;
|
|
1246
|
+
for (const { sourceOrderAfter } of publications) {
|
|
1247
|
+
if (!sourceOrderAfter)
|
|
1248
|
+
continue;
|
|
1249
|
+
// Sources that remained visible since the Project publication keep their receipt order.
|
|
1250
|
+
if (artifactValueDigest(sourceOrderAfter.filter((root) => paths.includes(root)))
|
|
1251
|
+
!== artifactValueDigest(paths.filter((root) => sourceOrderAfter.includes(root))))
|
|
1252
|
+
return false;
|
|
1253
|
+
}
|
|
1254
|
+
// The reviewed order anchors surviving rows. Each publication's receipt
|
|
1255
|
+
// also anchors its new rows against later cross-package moves.
|
|
1256
|
+
for (const previous of orderChecks) {
|
|
1257
|
+
if (!matchesGrokComponentOrder(previous.hookOrder, scopeEvidence.hookOrder, publishedRoots)
|
|
1258
|
+
|| !scopeEvidence.resourceOrder.every((order, index) => matchesGrokComponentOrder(previous.resourceOrder[index], order, publishedRoots)))
|
|
1259
|
+
return false;
|
|
1260
|
+
}
|
|
1261
|
+
const normalizedSources = { ...after, sources: sources.filter((_, index) => !addedSources.has(paths[index])),
|
|
1262
|
+
configurationEvidence: before.configurationEvidence, grokScopeEvidence: { ...scopeEvidence, instructions,
|
|
1263
|
+
hookOrder: priorEvidence.hookOrder, resourceOrder: priorEvidence.resourceOrder,
|
|
1264
|
+
sourceDigests: sourceDigests.filter((_, index) => !addedSources.has(paths[index])) } };
|
|
1265
|
+
const observation = { ...current.observation, prerequisites: { ...current.observation.prerequisites, nativeSources: normalizedSources } };
|
|
1266
|
+
const normalizedBefore = { ...before, sources: before.sources.filter((_, index) => !retiredSources.has(priorPaths[index])),
|
|
1267
|
+
grokScopeEvidence: { ...priorEvidence, sourceDigests: priorEvidence.sourceDigests.filter((_, index) => !retiredSources.has(priorPaths[index])) } };
|
|
1268
|
+
const baselineObservation = { ...mutableBaseline.observation, prerequisites: { ...mutableBaseline.observation.prerequisites,
|
|
1269
|
+
nativeSources: normalizedBefore } };
|
|
1270
|
+
return artifactValueDigest({ ...current, observation }) === artifactValueDigest({ ...mutableBaseline, observation: baselineObservation });
|
|
1271
|
+
};
|
|
1272
|
+
const check = async (discovery, batch) => {
|
|
1273
|
+
const reads = parallelNativeReads ? await Promise.allSettled([fingerprintParts(discovery), currentMutable(batch)]) : null;
|
|
1274
|
+
if (reads?.[0].status === 'rejected')
|
|
1275
|
+
throw reads[0].reason;
|
|
1276
|
+
const parts = reads?.[0].status === 'fulfilled' ? reads[0].value : await fingerprintParts(discovery);
|
|
1277
|
+
if (artifactValueDigest(parts) !== initial) {
|
|
1278
|
+
return artifactValueDigest(parts.discovery) !== artifactValueDigest(initialParts.discovery)
|
|
1279
|
+
? 'clientDiscoveryChanged' : 'deploymentInputsChanged';
|
|
1280
|
+
}
|
|
1281
|
+
if (reads?.[1].status === 'rejected')
|
|
1282
|
+
throw reads[1].reason;
|
|
1283
|
+
const current = reads?.[1].status === 'fulfilled' ? reads[1].value : await currentMutable(batch);
|
|
1284
|
+
if (parallelNativeReads ? matchesMutable(current) : await matchesAfterGrokPublications(current))
|
|
1285
|
+
return true;
|
|
1286
|
+
if (current.references !== mutableBaseline.references)
|
|
1287
|
+
return 'deploymentReferencesChanged';
|
|
1288
|
+
if (artifactValueDigest(current.paths) !== artifactValueDigest(mutableBaseline.paths))
|
|
1289
|
+
return 'deploymentPathsChanged';
|
|
1290
|
+
return 'deploymentObservationChanged';
|
|
867
1291
|
};
|
|
868
|
-
checks.set(entry.binding.id, () => check());
|
|
869
|
-
if (resolution.bindings.length === 1 &&
|
|
1292
|
+
checks.set(entry.binding.id, (batch) => check(undefined, batch));
|
|
1293
|
+
if (resolution.bindings.length === 1 && entry.binding.route === 'pi-package') {
|
|
870
1294
|
initialDiscoveryCheck = () => check({ value: initialParts.discovery });
|
|
871
1295
|
}
|
|
872
1296
|
this.mutableChecks.set(entry.binding.id, { physicalKey: entry.binding.physicalKey,
|
|
873
1297
|
marketplaceRoot: entry.layout.marketplaceRoot, sourceId: entry.binding.plugin.sourceId,
|
|
874
1298
|
sourceIdentity: entry.binding.plugin.sourceIdentity,
|
|
875
|
-
...(entry.binding.route === 'gemini-extension' ? { geminiActivationSnapshot: () => mutableBaseline.geminiActivation } : {}),
|
|
876
1299
|
assertStable: async () => {
|
|
877
|
-
if (
|
|
1300
|
+
if (await checks.get(entry.binding.id)() !== true)
|
|
878
1301
|
throw new Error('operationPlanStale: deployment evidence changed before source registration.');
|
|
879
1302
|
},
|
|
880
1303
|
acceptMarketplaceRegistration: async () => {
|
|
@@ -900,7 +1323,7 @@ export class PlatformRebuildSession {
|
|
|
900
1323
|
// registration. The reviewed package, references and bytes stay frozen.
|
|
901
1324
|
mutableBaseline = current;
|
|
902
1325
|
},
|
|
903
|
-
rebase: async (
|
|
1326
|
+
rebase: async (writtenFiles) => {
|
|
904
1327
|
const reads = parallelNativeReads
|
|
905
1328
|
? await Promise.allSettled([fingerprintParts(), currentMutable()]) : null;
|
|
906
1329
|
if (reads?.[0].status === 'rejected')
|
|
@@ -914,11 +1337,18 @@ export class PlatformRebuildSession {
|
|
|
914
1337
|
if (reads?.[1].status === 'rejected')
|
|
915
1338
|
throw reads[1].reason;
|
|
916
1339
|
const mutable = reads?.[1].status === 'fulfilled' ? reads[1].value : await currentMutable();
|
|
917
|
-
if (artifactValueDigest(mutable.geminiActivation ?? null) !== artifactValueDigest(geminiExpected ?? mutableBaseline.geminiActivation ?? null)) {
|
|
918
|
-
throw new Error('operationPlanStale: Gemini activation changed outside the checked native mutation.');
|
|
919
|
-
}
|
|
920
1340
|
mutableBaseline = mutable;
|
|
921
|
-
|
|
1341
|
+
// The same rebase already hashes the exact paths. Match the owner's
|
|
1342
|
+
// header and the desired bytes without opening each file again.
|
|
1343
|
+
const verifiedSupplementIds = writtenFiles?.size ? components.flatMap((component, index) => {
|
|
1344
|
+
if (component.kind !== 'owned-text-file')
|
|
1345
|
+
return [];
|
|
1346
|
+
const written = writtenFiles.get(component.path);
|
|
1347
|
+
const observed = mutable.paths[index];
|
|
1348
|
+
return written && observed && typeof observed === 'object' && 'digest' in observed && observed.digest === written.digest
|
|
1349
|
+
? written.componentIds : [];
|
|
1350
|
+
}) : [];
|
|
1351
|
+
return { observation: mutable.observation, verifiedSupplementIds };
|
|
922
1352
|
} });
|
|
923
1353
|
const evidence = { fingerprint: initial, managedCommandReview, layout: entry.layout, renderUnits: entry.layout.renderUnits,
|
|
924
1354
|
ownership: await Promise.all(inspected.components.map(async ({ component, state }) => ({ component, state,
|
|
@@ -927,6 +1357,7 @@ export class PlatformRebuildSession {
|
|
|
927
1357
|
sharedReferences: await sharedReferences(this.context, entry.binding, preparationObservation, entry.layout),
|
|
928
1358
|
nativeIdentity: preparationObservation.nativeIdentity ?? entry.layout.nativeIdentity,
|
|
929
1359
|
contentMatches: projections.some((projection) => projection.bundle !== null)
|
|
1360
|
+
&& (!antigravityProject || preparationObservation.ownership === 'aw')
|
|
930
1361
|
&& await readPlatformPackageContentDigest(entry.layout.packageRoot) === projections.find((projection) => projection.bundle !== null)?.bundle?.contentDigest };
|
|
931
1362
|
if (entry.binding.platform === 'codex') {
|
|
932
1363
|
const hostEntry = entry.binding.consumers.find((consumer) => consumer.entry?.kind === 'cli'
|
|
@@ -945,49 +1376,54 @@ export class PlatformRebuildSession {
|
|
|
945
1376
|
? enabled[entry.layout.nativeIdentity.registrationId] === true : 'unknown';
|
|
946
1377
|
}
|
|
947
1378
|
}
|
|
948
|
-
if (entry.binding.
|
|
949
|
-
evidence.userActivationEnabled = 'unknown';
|
|
950
|
-
const view = this.context.sharedReferenceView;
|
|
951
|
-
try {
|
|
952
|
-
const snapshot = await readGeminiActivationSnapshot(ctx, mutableBaseline.geminiActivation);
|
|
953
|
-
const rules = geminiActivationRules(snapshot, entry.layout.nativeIdentity.packageId);
|
|
954
|
-
await assertGeminiProjectRules(ctx, entry.binding, rules);
|
|
955
|
-
const actual = geminiUserActivation(snapshot, entry.layout.nativeIdentity.packageId, geminiExtensionPaths(ctx).home);
|
|
956
|
-
if (actual !== 'unknown' && preparationObservation.registration !== 'unknown'
|
|
957
|
-
&& (entry.binding.scope.kind === 'user' || view?.desiredComplete && view.scopes.includes('user'))) {
|
|
958
|
-
// Shared User renderScope does not establish User demand. A fresh
|
|
959
|
-
// project starts disabled globally; an existing global intent stays.
|
|
960
|
-
evidence.userActivationEnabled = preparationObservation.registration === 'present' ? actual : entry.binding.scope.kind === 'user'
|
|
961
|
-
|| view?.desired.some((reference) => reference.scope === 'user' && reference.platform === 'gemini'
|
|
962
|
-
&& reference.pluginId === entry.binding.plugin.pluginId && reference.sourceIdentity === entry.binding.plugin.sourceIdentity) === true;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
catch { /* Invalid or ambiguous native configuration remains blocked. */ }
|
|
966
|
-
}
|
|
967
|
-
if (entry.binding.scope.kind === 'project' && ['codex', 'copilot', 'gemini'].includes(entry.binding.platform)) {
|
|
1379
|
+
if (entry.binding.scope.kind === 'project' && ['codex', 'copilot'].includes(entry.binding.platform)) {
|
|
968
1380
|
const plannedUser = [...this.requestedOperations.values()].find((request) => request.scope === 'user'
|
|
969
1381
|
&& request.platform === input.platform && sourceIdentity(request).sourceIdentity === entry.binding.plugin.sourceIdentity
|
|
970
1382
|
&& sourceIdentity(request).pluginId === entry.binding.plugin.pluginId);
|
|
971
|
-
if (plannedUser
|
|
1383
|
+
if (plannedUser) {
|
|
972
1384
|
evidence.userActivationEnabled = !['remove', 'cleanup'].includes(operation(plannedUser));
|
|
973
1385
|
}
|
|
974
1386
|
}
|
|
975
|
-
const
|
|
976
|
-
|
|
1387
|
+
const priorPackage = inspected.components.find((slot) => 'path' in slot.component
|
|
1388
|
+
&& slot.component.path === entry.layout.packageRoot && ['present', 'partial'].includes(slot.state))?.component;
|
|
1389
|
+
if (!removing && expected.unmet.length && priorPackage?.kind === 'owned-directory') {
|
|
1390
|
+
const complete = hasCompleteDeliveryDeclaration(expected);
|
|
1391
|
+
const old = await readSkillOwnerMarker({ skillRoot: priorPackage.path, allowedRoot: priorPackage.allowedRoot,
|
|
1392
|
+
expectedIdentity: priorPackage.identity }).catch(() => null);
|
|
1393
|
+
const next = new Set(projections.filter((item) => item.bundle).flatMap((item) => item.components.map(({ id }) => id)));
|
|
1394
|
+
const dropsPriorComponent = !old?.nativeProjection || old.nativeProjection.components.some(({ id }) => !next.has(id));
|
|
1395
|
+
const currentDigest = evidence.ownership.find((slot) => slot.component === priorPackage)?.contentDigest;
|
|
1396
|
+
// The marker identifies the directory. Only its recorded digest proves
|
|
1397
|
+
// that replacing or withdrawing the whole tree would discard exclusively AW bytes.
|
|
1398
|
+
const previousContentsVerified = !!old?.nativeProjection && old.nativeProjection.contentDigest === currentDigest;
|
|
1399
|
+
const hasNativeCopy = ['grok-cli', 'antigravity-cli'].includes(entry.binding.route) && preparationObservation.registration === 'present';
|
|
1400
|
+
const previousCopyUnconfirmed = hasNativeCopy && (!old?.nativeProjection
|
|
1401
|
+
|| old.nativeProjection.contentDigest !== preparationObservation.nativePackageContentDigest);
|
|
1402
|
+
evidence.retainPackage = expected.unmet.some((gap) => !isDeliveryCapabilityGap(gap)) || previousCopyUnconfirmed
|
|
1403
|
+
|| !evidence.contentMatches && (!previousContentsVerified || dropsPriorComponent
|
|
1404
|
+
&& (!complete || evidence.sharedReferences !== 'none' || preparationObservation.ownership !== 'aw'));
|
|
1405
|
+
}
|
|
977
1406
|
if (!removing) {
|
|
978
1407
|
const inputEvidence = await createPlatformInputEvidence({ plugin: input.plugin, binding: entry.binding, units: units.map((unit) => unit.evidenceInput) });
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1408
|
+
const packageComponents = projections.find((projection) => projection.bundle)?.components;
|
|
1409
|
+
inputDigests.set(entry.binding.id, platformPackageInputDigest(inputEvidence, packageComponents));
|
|
1410
|
+
if (expected.unmet.every(isDeliveryCapabilityGap)) {
|
|
1411
|
+
const permissionNotices = platformPermissionNotices(projections.flatMap(({ diagnostics }) => diagnostics));
|
|
1412
|
+
const noticeFields = permissionNotices.length ? { permissionNotices } : {};
|
|
1413
|
+
if (expected.unmet.length || expected.components.length && permissionNotices.length)
|
|
1414
|
+
gapStates.set(entry.binding.id, { ...inputEvidence,
|
|
1415
|
+
kind: 'aw-platform-empty-state', result: 'capability-gaps', gaps: expected.unmet,
|
|
1416
|
+
installedComponentIds: expected.components.map(({ id }) => id), ...noticeFields });
|
|
1417
|
+
if (expected.components.length === 0 && expected.unmet.length === 0) {
|
|
1418
|
+
emptyStates.set(entry.binding.id, { ...inputEvidence, kind: 'aw-platform-empty-state', result: 'intentional-empty', ...noticeFields });
|
|
983
1419
|
}
|
|
984
1420
|
else if (entry.layout.supplementRoot && input.plugin.manifest.artifacts) {
|
|
985
1421
|
const supplement = inputEvidence.units.find((unit) => unit.output === 'supplement');
|
|
986
1422
|
if (supplement) {
|
|
987
1423
|
supplementInputDigests.set(entry.binding.id, supplement.inputDigest);
|
|
988
|
-
if (
|
|
989
|
-
emptyStates.set(entry.binding.id, { ...inputEvidence, kind: 'aw-platform-empty-state',
|
|
990
|
-
|
|
1424
|
+
if (!expected.unmet.length && !projections.some((projection) => projection.bundle)) {
|
|
1425
|
+
emptyStates.set(entry.binding.id, { ...inputEvidence, kind: 'aw-platform-empty-state',
|
|
1426
|
+
result: 'intentional-empty-package', installedComponentIds: expected.components.map(({ id }) => id).sort(), ...noticeFields });
|
|
991
1427
|
}
|
|
992
1428
|
}
|
|
993
1429
|
}
|
|
@@ -1009,15 +1445,15 @@ export class PlatformRebuildSession {
|
|
|
1009
1445
|
target.ownedComponents = plans.flatMap((plan) => plan.evidence.ownership.map((item) => item.component));
|
|
1010
1446
|
target.desiredOwnedComponents = target.ownedComponents;
|
|
1011
1447
|
let frozenNativeTools;
|
|
1012
|
-
const verifyChecks = async (selected) => {
|
|
1448
|
+
const verifyChecks = async (selected, batch) => {
|
|
1013
1449
|
for (const check of selected)
|
|
1014
|
-
if (
|
|
1450
|
+
if (await check(batch) !== true)
|
|
1015
1451
|
throw new Error('operationPlanStale: deployment evidence changed.');
|
|
1016
1452
|
for (const plan of plans)
|
|
1017
1453
|
if (!await this.verifyMarketplace(plan))
|
|
1018
1454
|
throw new Error('operationPlanStale: marketplace evidence changed.');
|
|
1019
1455
|
};
|
|
1020
|
-
const verify = () => verifyChecks(checks.values());
|
|
1456
|
+
const verify = (batch) => verifyChecks(checks.values(), batch);
|
|
1021
1457
|
const canVerifyAtExecution = () => {
|
|
1022
1458
|
const prepared = deployments[0];
|
|
1023
1459
|
if (!prepared || deployments.length !== 1 || plans.length !== 1 || plans[0] !== prepared.plan || blockedReceipts.length
|
|
@@ -1028,13 +1464,37 @@ export class PlatformRebuildSession {
|
|
|
1028
1464
|
&& driverState.before.package === 'absent' && driverState.before.ownership === 'absent'
|
|
1029
1465
|
&& plan.evidence.sharedReferences === 'none' && plan.evidence.ownership.every((item) => item.state === 'absent')
|
|
1030
1466
|
&& plan.effects.every((effect) => ['publish-package', 'register'].includes(effect.kind));
|
|
1031
|
-
|
|
1032
|
-
|
|
1467
|
+
const checkedBatch = this.context.batchInstallPlatform === plan.binding.platform && plan.binding.platform !== 'codex';
|
|
1468
|
+
return plan.operation === 'ensure' && (checkedBatch || ['copilot-marketplace', 'pi-package'].includes(plan.binding.route))
|
|
1469
|
+
&& plan.binding.platform === target.identity.platform && plan.expected.components.length > 0 && plan.expected.unmet.every(isDeliveryCapabilityGap)
|
|
1033
1470
|
&& driverState.before.package !== 'unknown' && (driverState.before.registration !== 'unknown' || hiddenEmptyPiProject)
|
|
1034
1471
|
&& ['absent', 'aw', 'shared'].includes(driverState.before.ownership)
|
|
1035
1472
|
&& plan.effects.every((effect) => ['publish-package', 'register', 'refresh', 'activate'].includes(effect.kind));
|
|
1036
1473
|
};
|
|
1037
|
-
|
|
1474
|
+
let privateStaging;
|
|
1475
|
+
let stagedPackage;
|
|
1476
|
+
const packagePlan = plans.length === 1 ? plans[0] : undefined;
|
|
1477
|
+
const bundle = packagePlan?.projections.find((projection) => projection.bundle)?.bundle;
|
|
1478
|
+
// Registration mutates a shared client. Copy independent bytes outside its
|
|
1479
|
+
// namespace first; publication still checks the original frozen live plan.
|
|
1480
|
+
const privatePackage = packagePlan && bundle && packagePlan.operation === 'ensure'
|
|
1481
|
+
&& ['pi-package', 'claude-marketplace'].includes(packagePlan.binding.route)
|
|
1482
|
+
&& packagePlan.effects.some((effect) => effect.kind === 'publish-package') ? {
|
|
1483
|
+
prepare: async () => {
|
|
1484
|
+
privateStaging = await fs.mkdtemp(path.join(await this.root(), 'private-package-'));
|
|
1485
|
+
stagedPackage = path.join(privateStaging, input.plugin.manifest.name);
|
|
1486
|
+
await fs.copy(bundle.stagingRoot, stagedPackage, { dereference: false });
|
|
1487
|
+
},
|
|
1488
|
+
dispose: async () => {
|
|
1489
|
+
if (privateStaging)
|
|
1490
|
+
await fs.remove(privateStaging);
|
|
1491
|
+
privateStaging = undefined;
|
|
1492
|
+
stagedPackage = undefined;
|
|
1493
|
+
},
|
|
1494
|
+
} : undefined;
|
|
1495
|
+
target.platformDeployment = { deployments, plans, blockedReceipts, cleanupResults, privatePackage,
|
|
1496
|
+
writesManagedCommands: [...preparedUnits.values()].some((unit) => unit.finalized.commandCandidates.length > 0)
|
|
1497
|
+
|| [...priorProducers.values()].some((producers) => producers.length > 0),
|
|
1038
1498
|
canVerifyAtExecution,
|
|
1039
1499
|
captureNativeToolChanges: async () => {
|
|
1040
1500
|
const signature = artifactValueDigest(deployments.map(({ plan }) => ({ bindingId: plan.binding.id,
|
|
@@ -1065,14 +1525,15 @@ export class PlatformRebuildSession {
|
|
|
1065
1525
|
if (!['ensure', 'reinstall'].includes(plan.operation) || !plan.expected.components.length)
|
|
1066
1526
|
continue;
|
|
1067
1527
|
const receipt = receipts.find((entry) => entry.bindingId === plan.binding.id);
|
|
1068
|
-
if (!receipt)
|
|
1528
|
+
if (!receipt || options?.deliveredSkillsOnly && plan.evidence.retainPackage)
|
|
1069
1529
|
continue;
|
|
1070
1530
|
const after = options?.refresh ? await adapter.inspect(ctx, plan.binding) : receipt.after;
|
|
1071
|
-
const supplementFiles =
|
|
1072
|
-
.filter((contribution) => contribution.kind === 'owned-file'));
|
|
1531
|
+
const supplementFiles = componentSupplementFiles(plan);
|
|
1073
1532
|
const supplementIds = new Set(supplementFiles.flatMap((contribution) => contribution.componentIds));
|
|
1074
|
-
|
|
1075
|
-
|
|
1533
|
+
if (!options?.deliveredSkillsOnly) {
|
|
1534
|
+
const supplements = await inspectStaticSupplements(ctx, plan.binding, plan.expected.components.filter((component) => supplementIds.has(component.id)));
|
|
1535
|
+
after.components = [...after.components.filter((component) => !supplementIds.has(component.id)), ...supplements.components];
|
|
1536
|
+
}
|
|
1076
1537
|
if (options?.refresh) {
|
|
1077
1538
|
receipt.after = after;
|
|
1078
1539
|
receipt.diagnostics.push(...after.diagnostics);
|
|
@@ -1081,25 +1542,77 @@ export class PlatformRebuildSession {
|
|
|
1081
1542
|
.flatMap((projection) => projection.components.map((component) => component.id)));
|
|
1082
1543
|
const bundle = plan.projections.find((projection) => projection.bundle)?.bundle;
|
|
1083
1544
|
const requiredActivation = requiredDeploymentActivation(plan.binding, after, requireIndependentActivation);
|
|
1084
|
-
if (!requireIndependentActivation && requiredActivation === 'enabled') {
|
|
1545
|
+
if (!options?.deliveredSkillsOnly && !requireIndependentActivation && requiredActivation === 'enabled') {
|
|
1085
1546
|
receipt.diagnostics = receipt.diagnostics.filter((entry) => entry.code !== 'codexProjectActivationUnconfirmed');
|
|
1086
1547
|
}
|
|
1087
1548
|
const nativeContentIncomplete = bundle && nativeCopyIncomplete(plan.binding, after, bundle.contentDigest);
|
|
1549
|
+
// Partial execution already verified the frozen plan and recorded each package publication.
|
|
1550
|
+
const publication = options?.deliveredSkillsOnly && plan.effects.find((effect) => effect.kind === 'publish-package');
|
|
1088
1551
|
const packageIncomplete = bundle && (!packageDeliveryConfirmed(plan.binding, after, bundle.contentDigest, requireIndependentActivation)
|
|
1089
|
-
||
|
|
1552
|
+
|| (options?.deliveredSkillsOnly
|
|
1553
|
+
? !plan.evidence.contentMatches && !receipt.effects.some((effect) => publication && effect.id === publication.id
|
|
1554
|
+
&& effect.status === 'applied' && effect.mutation === 'confirmed')
|
|
1555
|
+
: await readPlatformPackageContentDigest(plan.evidence.layout.packageRoot) !== bundle.contentDigest));
|
|
1090
1556
|
const delivered = new Set(after.components.filter((component) => component.presence === 'present' && !component.reasonCodes.length)
|
|
1091
1557
|
.map((component) => component.id));
|
|
1558
|
+
const roleIds = plan.expected.components.filter((component) => component.kind === 'agent' && delivered.has(component.id)
|
|
1559
|
+
&& packageIds.has(component.id) && !packageIncomplete && !plan.evidence.retainPackage).map(({ id }) => id);
|
|
1560
|
+
const roleDiagnostic = piAgentConsumerDiagnostic(plan.binding, after, roleIds);
|
|
1561
|
+
if (roleDiagnostic)
|
|
1562
|
+
receipt.diagnostics.push(roleDiagnostic);
|
|
1092
1563
|
const gaps = plan.expected.components.filter((component) => packageIncomplete && packageIds.has(component.id) || !delivered.has(component.id));
|
|
1564
|
+
if (bundle && !packageIncomplete && !plan.evidence.retainPackage) {
|
|
1565
|
+
for (const unitId of plan.binding.renderUnitIds) {
|
|
1566
|
+
const unit = preparedUnits.get(unitId);
|
|
1567
|
+
if (!unit?.finalized.skills.length)
|
|
1568
|
+
continue;
|
|
1569
|
+
const capabilityInput = { binding: plan.binding, renderUnit: unit.unit,
|
|
1570
|
+
observation: after, profile: getQualifiedPlatformProfile(input.platform) };
|
|
1571
|
+
const capabilities = adapter.capabilities(capabilityInput);
|
|
1572
|
+
const cliReaders = unit.unit.consumers.filter(({ product }) => product === 'cli');
|
|
1573
|
+
// Only attribute a shared package's limitation to Desktop if the same
|
|
1574
|
+
// check passes for its CLI readers and an App reader was observed.
|
|
1575
|
+
const codexCliCapabilities = plan.binding.platform === 'codex'
|
|
1576
|
+
&& cliReaders.some(({ availability }) => availability === 'available')
|
|
1577
|
+
&& unit.unit.consumers.some(({ product, availability }) => product === 'app' && availability === 'available')
|
|
1578
|
+
&& unit.unit.consumers.every(({ product, availability, entry }) => product === 'app'
|
|
1579
|
+
|| product === 'cli' && availability === 'available' && entry?.kind === 'cli')
|
|
1580
|
+
? adapter.capabilities({ ...capabilityInput, renderUnit: { ...unit.unit, consumers: cliReaders } }) : undefined;
|
|
1581
|
+
const antigravityReaders = plan.binding.platform === 'antigravity'
|
|
1582
|
+
? unit.unit.consumers.flatMap((reader) => reader.availability === 'available' && reader.product !== 'generic'
|
|
1583
|
+
? [{ id: reader.id, product: reader.product,
|
|
1584
|
+
unsupported: getAntigravityUnsupportedSkillControls(capabilityInput.profile, plan.binding.scope.kind, reader) }]
|
|
1585
|
+
: []) : [];
|
|
1586
|
+
for (const skill of unit.finalized.skills) {
|
|
1587
|
+
if (!packageIds.has(skill.componentId) || !delivered.has(skill.componentId))
|
|
1588
|
+
continue;
|
|
1589
|
+
const component = unit.prepared.expected.components.find((item) => item.id === skill.componentId);
|
|
1590
|
+
const requested = getComponentFeatureRequirements(component, { skillText: skill.tree.files['SKILL.md'].toString('utf8') });
|
|
1591
|
+
const warning = skillInvocationWarning(component.name, requested, { pluginId: plan.binding.plugin.pluginId, target: plan.binding.platform, scope: plan.binding.scope.kind }, capabilities, codexCliCapabilities, antigravityReaders.map((reader) => ({ ...reader,
|
|
1592
|
+
observed: after.skillInvocationPolicies?.find(({ componentId, productId }) => componentId === component.id
|
|
1593
|
+
&& productId === reader.id)?.features })));
|
|
1594
|
+
if (warning)
|
|
1595
|
+
receipt.diagnostics.push(warning);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
if (options?.deliveredSkillsOnly)
|
|
1600
|
+
continue;
|
|
1093
1601
|
const inputDigest = supplementInputDigests.get(plan.binding.id);
|
|
1094
1602
|
if (inputDigest && [...supplementIds].every((id) => delivered.has(id))
|
|
1095
|
-
&&
|
|
1603
|
+
&& receipt.unmet.every(isDeliveryCapabilityGap) && !receipt.diagnostics.some((diagnostic) => diagnostic.severity === 'error')) {
|
|
1096
1604
|
try {
|
|
1097
1605
|
await writePlatformSupplementState(ctx, plan.binding, inputDigest, supplementFiles.map((file) => ({
|
|
1098
1606
|
id: file.id, fileName: path.basename(file.destination), contentDigest: file.contentDigest,
|
|
1099
1607
|
})));
|
|
1100
1608
|
const emptyPackage = emptyStates.get(plan.binding.id);
|
|
1101
|
-
if (!gaps.length && emptyPackage
|
|
1609
|
+
if (!gaps.length && emptyPackage?.result === 'intentional-empty-package'
|
|
1610
|
+
&& supplementIds.size === emptyPackage.installedComponentIds.length
|
|
1611
|
+
&& emptyPackage.installedComponentIds.every((id) => supplementIds.has(id))
|
|
1612
|
+
&& after.package === 'absent' && ['absent', 'not-applicable'].includes(after.registration)) {
|
|
1613
|
+
// The package absence and permission notices describe the same binding.
|
|
1102
1614
|
await writePlatformEmptyState({ state: emptyPackage, env: this.context.env });
|
|
1615
|
+
continue;
|
|
1103
1616
|
}
|
|
1104
1617
|
}
|
|
1105
1618
|
catch {
|
|
@@ -1109,23 +1622,32 @@ export class PlatformRebuildSession {
|
|
|
1109
1622
|
subject: { target: plan.binding.platform, pluginId: plan.binding.plugin.pluginId, scope: plan.binding.scope.kind } });
|
|
1110
1623
|
}
|
|
1111
1624
|
}
|
|
1112
|
-
if (!gaps.length)
|
|
1625
|
+
if (!gaps.length) {
|
|
1626
|
+
const gapState = gapStates.get(plan.binding.id);
|
|
1627
|
+
if (gapState && !receipt.diagnostics.some((entry) => entry.severity === 'error')) {
|
|
1628
|
+
if (gapState.result === 'capability-gaps' && !gapState.gaps.length) {
|
|
1629
|
+
// A notice alone is optional status evidence. Failure to retain it does not undo verified delivery.
|
|
1630
|
+
await writePlatformEmptyState({ state: gapState, env: this.context.env }).catch(() => ctx.signal?.throwIfAborted());
|
|
1631
|
+
}
|
|
1632
|
+
else {
|
|
1633
|
+
await writePlatformEmptyState({ state: gapState, env: this.context.env });
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1113
1636
|
continue;
|
|
1637
|
+
}
|
|
1114
1638
|
incomplete = true;
|
|
1115
1639
|
const code = plan.binding.route === 'grok-directory' && requiredActivation === 'blocked' ? 'grokProjectAuthorizationDenied'
|
|
1116
1640
|
: plan.binding.route === 'codex-marketplace' && requireIndependentActivation && after.scopeActivation === 'unknown'
|
|
1117
1641
|
? 'codexProjectActivationUnconfirmed'
|
|
1118
1642
|
: nativeContentIncomplete ? 'nativeInstallContentPostcheckFailed' : 'deploymentPostcheckFailed';
|
|
1119
1643
|
receipt.diagnostics.push({ code, severity: 'error',
|
|
1120
|
-
message: code === 'nativeInstallContentPostcheckFailed'
|
|
1121
|
-
?
|
|
1122
|
-
: code === '
|
|
1123
|
-
? '
|
|
1124
|
-
: code === '
|
|
1125
|
-
? '
|
|
1126
|
-
:
|
|
1127
|
-
? 'Codex reports effective activation but does not distinguish this project from User inheritance.'
|
|
1128
|
-
: 'The final observation does not confirm the requested deployment. Check status and sync the affected target.',
|
|
1644
|
+
message: code === 'nativeInstallContentPostcheckFailed'
|
|
1645
|
+
? 'The installed native copy does not confirm the frozen package bytes. Check status and sync the affected target.'
|
|
1646
|
+
: code === 'grokProjectAuthorizationDenied'
|
|
1647
|
+
? 'Grok denied authorization for the selected project. Review the project in Grok before syncing.'
|
|
1648
|
+
: code === 'codexProjectActivationUnconfirmed'
|
|
1649
|
+
? 'Codex reports effective activation but does not distinguish this project from User inheritance.'
|
|
1650
|
+
: 'The final observation does not confirm the requested deployment. Check status and sync the affected target.',
|
|
1129
1651
|
subject: { target: plan.binding.platform, pluginId: plan.binding.plugin.pluginId, scope: plan.binding.scope.kind } });
|
|
1130
1652
|
receipt.unmet.push(...gaps.map((component) => ({ id: `postcheck:${plan.binding.id}:${component.id}`,
|
|
1131
1653
|
componentId: component.id, kind: component.kind, reasonCode: code, requiredFeatures: [],
|
|
@@ -1147,22 +1669,21 @@ export class PlatformRebuildSession {
|
|
|
1147
1669
|
cleanupResults.length = 0;
|
|
1148
1670
|
const receipts = [...blockedReceipts];
|
|
1149
1671
|
for (const prepared of deployments) {
|
|
1672
|
+
const supplementFiles = componentSupplementFiles(prepared.plan);
|
|
1673
|
+
const writtenFiles = new Map();
|
|
1150
1674
|
const commandPreparationFailed = prepared.plan.binding.renderUnitIds.some((unitId) => preparedUnits.get(unitId)?.finalized.producerResolutions
|
|
1151
|
-
.some((resolution) => resolution.state === 'failed'
|
|
1675
|
+
.some((resolution) => resolution.state === 'failed'));
|
|
1152
1676
|
let receipt;
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1677
|
+
const peers = prepared.plan.binding.route === 'codex-marketplace' ? [...this.mutableChecks.values()].filter((check) => check.physicalKey !== prepared.plan.binding.physicalKey && check.marketplaceRoot === prepared.plan.evidence.layout.marketplaceRoot
|
|
1678
|
+
&& check.sourceId === prepared.plan.binding.plugin.sourceId && check.sourceIdentity === prepared.plan.binding.plugin.sourceIdentity) : [];
|
|
1679
|
+
const nativeServices = createNativeLifecycleServices(ctx, prepared.plan.evidence, peers.length ? async () => {
|
|
1680
|
+
for (const peer of peers)
|
|
1681
|
+
await peer.assertStable();
|
|
1682
|
+
} : undefined);
|
|
1158
1683
|
try {
|
|
1159
|
-
receipt = await adapter.lifecycle.execute({ ...
|
|
1684
|
+
receipt = await adapter.lifecycle.execute({ ...ctx, nativeEffects: this.nativeEffects, inspect: (binding) => adapter.inspect(ctx, binding), services: {
|
|
1160
1685
|
...nativeServices,
|
|
1161
1686
|
registerMarketplace: async (binding, identity) => {
|
|
1162
|
-
const peers = binding.route === 'codex-marketplace' ? [...this.mutableChecks.values()].filter((check) => check.physicalKey !== binding.physicalKey && check.marketplaceRoot === prepared.plan.evidence.layout.marketplaceRoot
|
|
1163
|
-
&& check.sourceId === binding.plugin.sourceId && check.sourceIdentity === binding.plugin.sourceIdentity) : [];
|
|
1164
|
-
for (const peer of peers)
|
|
1165
|
-
await peer.assertStable();
|
|
1166
1687
|
const outcome = await nativeServices.registerMarketplace(binding, identity);
|
|
1167
1688
|
if (outcome.mutation === 'confirmed') {
|
|
1168
1689
|
ctx.codexObservationSession?.invalidate(prepared.plan.evidence.layout.marketplaceName ?? undefined);
|
|
@@ -1174,7 +1695,12 @@ export class PlatformRebuildSession {
|
|
|
1174
1695
|
verifyEvidence: async (plan) => {
|
|
1175
1696
|
const verified = verifiedPlan === plan;
|
|
1176
1697
|
verifiedPlan = undefined;
|
|
1177
|
-
|
|
1698
|
+
if (verified)
|
|
1699
|
+
return true;
|
|
1700
|
+
const evidence = await checks.get(plan.binding.id)();
|
|
1701
|
+
if (evidence !== true)
|
|
1702
|
+
return evidence;
|
|
1703
|
+
return await this.verifyMarketplace(plan) || 'marketplaceChanged';
|
|
1178
1704
|
},
|
|
1179
1705
|
publishPackage: async (_binding, bundle, _destination, component) => {
|
|
1180
1706
|
if (!('path' in component) || component.path !== _destination)
|
|
@@ -1185,9 +1711,10 @@ export class PlatformRebuildSession {
|
|
|
1185
1711
|
publication = publishDirectory(bundle.stagingRoot, component, {
|
|
1186
1712
|
components: prepared.plan.projections.filter((projection) => projection.bundle !== null).flatMap((projection) => projection.components),
|
|
1187
1713
|
inputDigest: inputDigests.get(prepared.plan.binding.id), contentDigest: bundle.contentDigest,
|
|
1188
|
-
|
|
1714
|
+
...(bundle.piExtensionDigest ? { piExtensionDigest: bundle.piExtensionDigest } : {}),
|
|
1715
|
+
preparation: prepared.plan.expected.unmet.some((gap) => !isDeliveryCapabilityGap(gap)) || commandPreparationFailed ? 'partial' : 'complete',
|
|
1189
1716
|
physicalIdentity: (await getDeploymentLayout(ctx, prepared.plan.binding)).physicalIdentity,
|
|
1190
|
-
});
|
|
1717
|
+
}, stagedPackage);
|
|
1191
1718
|
this.published.set(prepared.plan.binding.physicalKey, publication);
|
|
1192
1719
|
}
|
|
1193
1720
|
return publication;
|
|
@@ -1197,7 +1724,12 @@ export class PlatformRebuildSession {
|
|
|
1197
1724
|
if (component.kind === 'owned-directory')
|
|
1198
1725
|
return publishDirectory(contribution.stagingPath, component);
|
|
1199
1726
|
if (component.kind === 'owned-text-file') {
|
|
1200
|
-
|
|
1727
|
+
const content = await fs.readFile(contribution.stagingPath, 'utf8');
|
|
1728
|
+
await writeOwnedTextFile({ ...component, content });
|
|
1729
|
+
if (supplementFiles.includes(contribution)) {
|
|
1730
|
+
writtenFiles.set(component.path, { componentIds: contribution.componentIds,
|
|
1731
|
+
digest: crypto.createHash('sha256').update(renderOwnedTextFile(content, component.identity)).digest('hex') });
|
|
1732
|
+
}
|
|
1201
1733
|
}
|
|
1202
1734
|
else if (component.kind === 'shared-config' && component.locator.kind === 'cursor-workspace-hook') {
|
|
1203
1735
|
const locator = component.locator;
|
|
@@ -1219,7 +1751,17 @@ export class PlatformRebuildSession {
|
|
|
1219
1751
|
throw new Error('platformContributionUnsupported');
|
|
1220
1752
|
return { mutation: 'confirmed', changed: true };
|
|
1221
1753
|
},
|
|
1222
|
-
removeOwned: async (
|
|
1754
|
+
removeOwned: async (binding, component) => {
|
|
1755
|
+
if (isAntigravityProjectDirectory(binding) && component.kind === 'owned-directory'
|
|
1756
|
+
&& component.path !== prepared.plan.evidence.layout.packageRoot && prepared.driverState.bundle) {
|
|
1757
|
+
const replacement = prepared.driverState.packageComponent;
|
|
1758
|
+
if (replacement?.kind !== 'owned-directory' || await requireWritable(replacement, this.ownership) !== 'present'
|
|
1759
|
+
|| await readPlatformPackageContentDigest(replacement.path) !== prepared.driverState.bundle.contentDigest) {
|
|
1760
|
+
throw Object.assign(new Error('The Antigravity replacement package could not be verified.'), {
|
|
1761
|
+
code: 'operationPlanStale', mutation: 'none',
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1223
1765
|
const result = await cleanupOwnedComponents({ components: [component], executor: this.ownership });
|
|
1224
1766
|
cleanupResults.push(result);
|
|
1225
1767
|
if (result.failures.length || result.residual.length || result.quarantined.length) {
|
|
@@ -1231,16 +1773,19 @@ export class PlatformRebuildSession {
|
|
|
1231
1773
|
} }, prepared);
|
|
1232
1774
|
}
|
|
1233
1775
|
catch (error) {
|
|
1234
|
-
const diagnostic = { code: 'platformExecutionFailed', severity: 'error',
|
|
1776
|
+
const diagnostic = { code: recoveryInterruptionCode(error) ?? 'platformExecutionFailed', severity: 'error',
|
|
1235
1777
|
message: error instanceof Error ? error.message : String(error),
|
|
1236
1778
|
subject: { target: prepared.plan.binding.platform, pluginId: prepared.plan.binding.plugin.pluginId, scope: prepared.plan.binding.scope.kind } };
|
|
1237
1779
|
receipt = { bindingId: prepared.plan.binding.id, effects: prepared.plan.effects.map((effect) => ({
|
|
1238
1780
|
id: effect.id, status: 'unknown', mutation: 'possible', diagnostics: [diagnostic]
|
|
1239
1781
|
})),
|
|
1240
1782
|
after: await adapter.inspect(ctx, prepared.plan.binding).catch(() => prepared.driverState.before),
|
|
1241
|
-
unmet:
|
|
1783
|
+
unmet: prepared.plan.expected.unmet.map((gap) => ({ ...gap, productIds: prepared.plan.binding.consumers.map(({ id }) => id) })),
|
|
1784
|
+
reload: 'unknown', diagnostics: [diagnostic] };
|
|
1242
1785
|
}
|
|
1243
1786
|
receipts.push(receipt);
|
|
1787
|
+
if (receipt.diagnostics.some(({ code }) => code === 'processCleanupUnconfirmed'))
|
|
1788
|
+
return receipts;
|
|
1244
1789
|
if ((prepared.plan.operation === 'remove' || prepared.plan.operation === 'cleanup'
|
|
1245
1790
|
|| prepared.plan.expected.components.length === 0 && prepared.plan.expected.unmet.length === 0)
|
|
1246
1791
|
&& prepared.plan.evidence.sharedReferences !== 'none' && receipt.after.package === 'present') {
|
|
@@ -1262,9 +1807,14 @@ export class PlatformRebuildSession {
|
|
|
1262
1807
|
try {
|
|
1263
1808
|
if (receipt.effects.some((effect) => effect.mutation !== 'none')) {
|
|
1264
1809
|
for (const [bindingId, check] of this.mutableChecks)
|
|
1265
|
-
if (check.physicalKey === prepared.plan.binding.physicalKey
|
|
1266
|
-
|
|
1267
|
-
|
|
1810
|
+
if (check.physicalKey === prepared.plan.binding.physicalKey) {
|
|
1811
|
+
const { observation: fresh, verifiedSupplementIds } = await check.rebase(bindingId === receipt.bindingId ? writtenFiles : undefined);
|
|
1812
|
+
if (verifiedSupplementIds.length) {
|
|
1813
|
+
receipt.after.components = [
|
|
1814
|
+
...receipt.after.components.filter(({ id }) => !verifiedSupplementIds.includes(id)),
|
|
1815
|
+
...verifiedSupplementIds.map((id) => ({ id, presence: 'present', reasonCodes: [] })),
|
|
1816
|
+
];
|
|
1817
|
+
}
|
|
1268
1818
|
if (bindingId === receipt.bindingId && prepared.plan.binding.route === 'copilot-marketplace'
|
|
1269
1819
|
&& publication?.mutation === 'confirmed') {
|
|
1270
1820
|
recheckCopilotMarketplaceTimeout(receipt, fresh);
|
|
@@ -1273,13 +1823,22 @@ export class PlatformRebuildSession {
|
|
|
1273
1823
|
}
|
|
1274
1824
|
}
|
|
1275
1825
|
catch (error) {
|
|
1276
|
-
receipt.diagnostics.push({ code: 'operationPlanStale', severity: 'error', message: error instanceof Error ? error.message : String(error),
|
|
1826
|
+
receipt.diagnostics.push({ code: recoveryInterruptionCode(error) ?? 'operationPlanStale', severity: 'error', message: error instanceof Error ? error.message : String(error),
|
|
1277
1827
|
subject: { target: prepared.plan.binding.platform, pluginId: prepared.plan.binding.plugin.pluginId, scope: prepared.plan.binding.scope.kind } });
|
|
1278
1828
|
continue;
|
|
1279
1829
|
}
|
|
1280
1830
|
if (prepared.plan.evidence.retainPackage || receipt.diagnostics.some((diagnostic) => diagnostic.code === 'operationPlanStale')
|
|
1281
1831
|
|| receipt.effects.some((effect) => ['failed', 'unknown', 'blocked', 'skipped'].includes(effect.status)))
|
|
1282
1832
|
continue;
|
|
1833
|
+
this.recordGrokWrites(prepared, receipt, publication?.mutation === 'confirmed', writtenFiles, shadowedUsers.get(prepared.plan.binding.id));
|
|
1834
|
+
const piInventoryKey = piProjectInventoryKey(prepared.plan.binding, prepared.plan.evidence.layout.activationPath);
|
|
1835
|
+
if (piInventoryKey && piProjectEmptyDeliveryObserved(prepared.plan.binding, prepared.driverState.before)
|
|
1836
|
+
&& receipt.after.registration === 'present' && receipt.after.ownership === 'aw' && receipt.after.configuration?.activation === 'enabled'
|
|
1837
|
+
&& prepared.plan.effects.some((effect) => effect.kind === 'register' && receipt.effects.some((result) => result.id === effect.id && result.status === 'applied' && result.mutation === 'confirmed'))) {
|
|
1838
|
+
const registered = this.piProjectRegisteredRoots.get(piInventoryKey) ?? new Set();
|
|
1839
|
+
registered.add(prepared.plan.evidence.layout.packageRoot);
|
|
1840
|
+
this.piProjectRegisteredRoots.set(piInventoryKey, registered);
|
|
1841
|
+
}
|
|
1283
1842
|
try {
|
|
1284
1843
|
const candidates = [...preparedUnits.values()].flatMap((unit) => unit.finalized.commandCandidates)
|
|
1285
1844
|
.filter((candidate) => candidate.producer.kind !== 'package' && candidate.producer.placementKey === prepared.plan.binding.physicalKey);
|
|
@@ -1299,10 +1858,12 @@ export class PlatformRebuildSession {
|
|
|
1299
1858
|
&& !receipt.diagnostics.some((diagnostic) => diagnostic.severity === 'error')
|
|
1300
1859
|
&& packageDeliveryConfirmed(prepared.plan.binding, receipt.after, bundle.contentDigest, requireIndependentActivation)
|
|
1301
1860
|
&& await readPlatformPackageContentDigest(root) === bundle.contentDigest) {
|
|
1861
|
+
const marker = await readSkillOwnerMarker({ skillRoot: root, allowedRoot: packageOwner.allowedRoot, expectedIdentity: packageOwner.identity });
|
|
1302
1862
|
const projection = { components: mappings, contentDigest: bundle.contentDigest,
|
|
1303
|
-
inputDigest: inputDigests.get(prepared.plan.binding.id), preparation: prepared.plan.expected.unmet.
|
|
1863
|
+
inputDigest: inputDigests.get(prepared.plan.binding.id), preparation: prepared.plan.expected.unmet.some((gap) => !isDeliveryCapabilityGap(gap)) || commandPreparationFailed ? 'partial' : 'complete',
|
|
1864
|
+
...(bundle.piExtensionDigest && marker?.nativeProjection?.piExtensionDigest === bundle.piExtensionDigest
|
|
1865
|
+
? { piExtensionDigest: bundle.piExtensionDigest } : {}),
|
|
1304
1866
|
physicalIdentity: (await getDeploymentLayout(ctx, prepared.plan.binding)).physicalIdentity };
|
|
1305
|
-
const marker = await readSkillOwnerMarker({ skillRoot: root, allowedRoot: packageOwner.allowedRoot, expectedIdentity: packageOwner.identity });
|
|
1306
1867
|
if (marker && (!marker.nativeProjection || artifactValueDigest(marker.nativeProjection) !== artifactValueDigest(projection))) {
|
|
1307
1868
|
await writeSkillOwnerMarker({ skillRoot: root, allowedRoot: packageOwner.allowedRoot, identity: packageOwner.identity, nativeProjection: projection });
|
|
1308
1869
|
for (const check of this.mutableChecks.values())
|
|
@@ -1320,25 +1881,34 @@ export class PlatformRebuildSession {
|
|
|
1320
1881
|
await revokeManagedCommandBindings(producer, this.context.env);
|
|
1321
1882
|
}
|
|
1322
1883
|
}
|
|
1323
|
-
const emptyState = emptyStates.get(prepared.plan.binding.id);
|
|
1884
|
+
const emptyState = gapStates.get(prepared.plan.binding.id) ?? emptyStates.get(prepared.plan.binding.id);
|
|
1324
1885
|
const removedByCommand = piProjectRemovalConfirmed(prepared.plan, receipt);
|
|
1325
1886
|
const inactiveScope = removedByCommand || receipt.after.registration === 'absent'
|
|
1326
1887
|
|| receipt.after.package === 'absent' && receipt.after.registration === 'not-applicable'
|
|
1327
1888
|
|| receipt.after.scopeRegistration === 'absent'
|
|
1328
1889
|
|| prepared.plan.binding.scope.kind === 'project'
|
|
1329
|
-
&& ['codex-marketplace', '
|
|
1890
|
+
&& ['codex-marketplace', 'copilot-marketplace'].includes(prepared.plan.binding.route)
|
|
1330
1891
|
&& receipt.after.configuration?.activation === 'absent'
|
|
1331
1892
|
|| receipt.after.consumers.every((consumer) => ['disabled', 'not-applicable'].includes(consumer.activation));
|
|
1332
|
-
if (emptyState && !prepared.plan.expected.components.length &&
|
|
1333
|
-
&& !receipt.diagnostics.some((diagnostic) => diagnostic.severity === 'error')
|
|
1334
|
-
&& (receipt.after.registration !== 'unknown' || removedByCommand) && receipt.after.package !== 'unknown'
|
|
1335
|
-
&& !['foreign', 'unknown'].includes(receipt.after.ownership)
|
|
1336
|
-
&& inactiveScope) {
|
|
1893
|
+
if (emptyState && !prepared.plan.expected.components.length && receipt.unmet.every(isDeliveryCapabilityGap)
|
|
1894
|
+
&& !receipt.diagnostics.some((diagnostic) => diagnostic.severity === 'error')) {
|
|
1337
1895
|
const residual = await inspectOwnedComponents({ components: prepared.plan.evidence.ownership
|
|
1338
|
-
.filter((slot) => !('path' in slot.component) || slot.component.path !==
|
|
1896
|
+
.filter((slot) => !('path' in slot.component) || slot.component.path !== root)
|
|
1339
1897
|
.map((slot) => slot.component), executor: this.ownership });
|
|
1340
|
-
|
|
1898
|
+
const hiddenEmptyPi = emptyState.result === 'capability-gaps' && piProjectEmptyDeliveryObserved(prepared.plan.binding, receipt.after);
|
|
1899
|
+
const clear = (receipt.after.registration !== 'unknown' || removedByCommand || hiddenEmptyPi)
|
|
1900
|
+
&& (emptyState.result !== 'capability-gaps' || prepared.plan.binding.route !== 'pi-package' || receipt.after.configuration?.activation === 'absent')
|
|
1901
|
+
&& receipt.after.package !== 'unknown' && !['foreign', 'unknown'].includes(receipt.after.ownership)
|
|
1902
|
+
&& (inactiveScope || hiddenEmptyPi)
|
|
1903
|
+
&& (emptyState.result === 'intentional-empty' || receipt.after.package === 'absent')
|
|
1904
|
+
&& residual.components.every((slot) => slot.state === 'absent');
|
|
1905
|
+
if (clear)
|
|
1341
1906
|
await writePlatformEmptyState({ state: emptyState, env: this.context.env });
|
|
1907
|
+
else if (emptyState.result === 'capability-gaps')
|
|
1908
|
+
receipt.diagnostics.push({ code: 'previousDeploymentRetained', severity: 'error',
|
|
1909
|
+
message: 'Previous output or registration could not be confirmed absent. Check the scoped deployment before retrying.',
|
|
1910
|
+
subject: { target: prepared.plan.binding.platform, pluginId: prepared.plan.binding.plugin.pluginId, scope: prepared.plan.binding.scope.kind },
|
|
1911
|
+
detail: { reasonCode: 'previousDeploymentRetained', path: root } });
|
|
1342
1912
|
}
|
|
1343
1913
|
}
|
|
1344
1914
|
catch (error) {
|