@lesliechan721/aw 0.1.0-beta.84 → 0.1.0-beta.86
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/command-runtime-config.d.mts +9 -0
- package/dist/authoring/assets/command-runtime-config.mjs +106 -0
- package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
- package/dist/authoring/scripts/validate-plugin.mjs +17 -22
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/scripts/aw-skill-eval-materializer.d.ts +4 -0
- package/dist/scripts/aw-skill-eval-materializer.js +27 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
- package/dist/scripts/bundle-plugins.js +1 -1
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/test-plugin-scripts.js +13 -2
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +1 -1
- package/dist/src/commands/aw-capabilities.js +2 -2
- package/dist/src/commands/catalog-source.d.ts +2 -1
- package/dist/src/commands/catalog-source.js +8 -7
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/deployment-confirmation.d.ts +8 -1
- package/dist/src/commands/deployment-confirmation.js +79 -11
- package/dist/src/commands/deployment-confirmation.js.map +1 -1
- package/dist/src/commands/lifecycle-command-package.d.ts +44 -0
- package/dist/src/commands/lifecycle-command-package.js +195 -0
- package/dist/src/commands/lifecycle-command-package.js.map +1 -0
- package/dist/src/commands/managed-commands.d.ts +6 -0
- package/dist/src/commands/managed-commands.js +203 -152
- package/dist/src/commands/managed-commands.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +22 -21
- package/dist/src/commands/operation-plan.js +2 -5
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/permission-batch.d.ts +5 -0
- package/dist/src/commands/permission-batch.js +80 -0
- package/dist/src/commands/permission-batch.js.map +1 -0
- package/dist/src/commands/plugin-capabilities.js +17 -13
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.d.ts +8 -2
- package/dist/src/commands/public-config-confirmation.js +22 -5
- package/dist/src/commands/public-config-confirmation.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +7 -12
- package/dist/src/commands/public-lifecycle-result.js +136 -40
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.js +49 -8
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +21 -5
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +4 -0
- package/dist/src/commands/rebuild-command.js +150 -48
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +12 -3
- package/dist/src/commands/rebuild-integration.js +52 -164
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +2 -1
- package/dist/src/commands/rebuild-operations.js +7 -2
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +12 -5
- package/dist/src/commands/rebuild-platform-integration.js +691 -186
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/commands/skill-eval.js +10 -1
- package/dist/src/commands/skill-eval.js.map +1 -1
- package/dist/src/generators/local-plugin.js +14 -15
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +18 -4
- package/dist/src/generators/permissions.js +76 -22
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +84 -44
- 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/command-receipt.js +7 -8
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/component-delivery.d.ts +28 -0
- package/dist/src/output/component-delivery.js +138 -0
- package/dist/src/output/component-delivery.js.map +1 -0
- package/dist/src/output/public-result.d.ts +17 -0
- package/dist/src/output/public-result.js +121 -25
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/rebuild-progress.js +7 -4
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.js +51 -31
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/output/skill-invocation-notices.d.ts +2 -0
- package/dist/src/output/skill-invocation-notices.js +40 -4
- package/dist/src/output/skill-invocation-notices.js.map +1 -1
- package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
- package/dist/src/platforms/antigravity-permissions.js +388 -0
- package/dist/src/platforms/antigravity-permissions.js.map +1 -0
- package/dist/src/platforms/capabilities.d.ts +4 -1
- package/dist/src/platforms/capabilities.js +93 -9
- package/dist/src/platforms/capabilities.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +46 -2
- package/dist/src/platforms/discovery.d.ts +13 -0
- package/dist/src/platforms/discovery.js +170 -30
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/grok-permission-config.d.ts +22 -0
- package/dist/src/platforms/grok-permission-config.js +184 -0
- package/dist/src/platforms/grok-permission-config.js.map +1 -0
- package/dist/src/platforms/grok-permission-document.d.ts +4 -0
- package/dist/src/platforms/grok-permission-document.js +145 -0
- package/dist/src/platforms/grok-permission-document.js.map +1 -0
- package/dist/src/platforms/grok-permissions.d.ts +17 -0
- package/dist/src/platforms/grok-permissions.js +311 -0
- package/dist/src/platforms/grok-permissions.js.map +1 -0
- package/dist/src/platforms/host-permission-policy.d.ts +38 -0
- package/dist/src/platforms/host-permission-policy.js +86 -0
- package/dist/src/platforms/host-permission-policy.js.map +1 -0
- package/dist/src/platforms/inspection-grok.js +165 -11
- package/dist/src/platforms/inspection-grok.js.map +1 -1
- package/dist/src/platforms/inspection-native.js +53 -18
- 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 +4 -2
- package/dist/src/platforms/inspection-query.js +24 -8
- 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 +36 -4
- package/dist/src/platforms/inspection.js.map +1 -1
- package/dist/src/platforms/layout.d.ts +13 -0
- package/dist/src/platforms/layout.js +90 -12
- package/dist/src/platforms/layout.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.d.ts +1 -0
- package/dist/src/platforms/lifecycle-native.js +25 -1
- 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 +98 -25
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
- package/dist/src/platforms/opencode-permission-config.js +253 -0
- package/dist/src/platforms/opencode-permission-config.js.map +1 -0
- package/dist/src/platforms/opencode-permissions.d.ts +39 -0
- package/dist/src/platforms/opencode-permissions.js +212 -0
- package/dist/src/platforms/opencode-permissions.js.map +1 -0
- package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
- package/dist/src/platforms/opencode-related-permissions.js +177 -0
- package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
- package/dist/src/platforms/permission-ownership.d.ts +89 -0
- package/dist/src/platforms/permission-ownership.js +543 -0
- package/dist/src/platforms/permission-ownership.js.map +1 -0
- package/dist/src/platforms/permission-sidecar.d.ts +70 -0
- package/dist/src/platforms/permission-sidecar.js +215 -0
- package/dist/src/platforms/permission-sidecar.js.map +1 -0
- package/dist/src/platforms/projection-code-extension.js +2 -1
- package/dist/src/platforms/projection-code-extension.js.map +1 -1
- package/dist/src/platforms/projection.js +127 -29
- 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 +8 -1
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +2 -0
- package/dist/src/portable/recovery.js +45 -8
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +3 -1
- package/dist/src/recovery/coordinator.js +101 -37
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/install-concurrency.js +3 -2
- package/dist/src/recovery/install-concurrency.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.d.ts +7 -0
- package/dist/src/recovery/joint-coordinator.js +270 -64
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.d.ts +14 -2
- package/dist/src/recovery/joint-demand.js +54 -7
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/joint-install-execution.js +2 -1
- package/dist/src/recovery/joint-install-execution.js.map +1 -1
- package/dist/src/recovery/receipt.d.ts +15 -4
- package/dist/src/recovery/receipt.js +23 -0
- package/dist/src/recovery/receipt.js.map +1 -1
- package/dist/src/recovery/retirement.js +11 -17
- package/dist/src/recovery/retirement.js.map +1 -1
- package/dist/src/recovery/status.d.ts +20 -8
- package/dist/src/recovery/status.js +411 -91
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/eval-source-input.d.ts +1 -0
- package/dist/src/review/eval-source-input.js +7 -1
- package/dist/src/review/eval-source-input.js.map +1 -1
- package/dist/src/review/platform-profile.js +2 -1
- package/dist/src/review/platform-profile.js.map +1 -1
- package/dist/src/review/review-selection.js +12 -5
- package/dist/src/review/review-selection.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +2 -1
- package/dist/src/review/skill-materialization.js +45 -43
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/review/source-binding.js +5 -1
- package/dist/src/review/source-binding.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +101 -57
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +72 -7
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +6 -2
- package/dist/src/tui/controller.js +17 -4
- 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 +52 -10
- package/dist/src/tui/deployment-view.js.map +1 -1
- package/dist/src/tui/diagnostic-projection.d.ts +7 -1
- package/dist/src/tui/diagnostic-projection.js +55 -5
- 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.js +3 -1
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
- package/dist/src/tui/operation-history.d.ts +6 -0
- package/dist/src/tui/operation-history.js +20 -2
- package/dist/src/tui/operation-history.js.map +1 -1
- package/dist/src/tui/operation-review-planner.js +130 -70
- package/dist/src/tui/operation-review-planner.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.js +34 -16
- 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/types.d.ts +10 -21
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +3 -36
- package/dist/src/utils/artifact-plan.js +16 -78
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +1 -60
- package/dist/src/utils/artifact-renderer.js +31 -57
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +3 -26
- package/dist/src/utils/artifact-request.js +13 -36
- package/dist/src/utils/artifact-request.js.map +1 -1
- package/dist/src/utils/artifact-sources.d.ts +0 -8
- package/dist/src/utils/artifact-sources.js +0 -8
- package/dist/src/utils/artifact-sources.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +2 -7
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-source-references.js +22 -3
- 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 +8 -11
- package/dist/src/utils/component-command-preparation.js +110 -210
- 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-cli-review.d.ts +43 -0
- package/dist/src/utils/managed-command-cli-review.js +389 -0
- package/dist/src/utils/managed-command-cli-review.js.map +1 -0
- package/dist/src/utils/managed-command-closure.d.ts +14 -3
- package/dist/src/utils/managed-command-closure.js +144 -23
- package/dist/src/utils/managed-command-closure.js.map +1 -1
- package/dist/src/utils/managed-command-errors.d.ts +5 -0
- package/dist/src/utils/managed-command-errors.js +10 -0
- package/dist/src/utils/managed-command-errors.js.map +1 -0
- package/dist/src/utils/managed-command-materialization.d.ts +77 -113
- package/dist/src/utils/managed-command-materialization.js +324 -323
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-preparation.d.ts +28 -65
- package/dist/src/utils/managed-command-preparation.js +33 -140
- package/dist/src/utils/managed-command-preparation.js.map +1 -1
- package/dist/src/utils/managed-command-review.d.ts +11 -4
- package/dist/src/utils/managed-command-review.js +33 -21
- package/dist/src/utils/managed-command-review.js.map +1 -1
- package/dist/src/utils/managed-command-runtime.d.ts +1 -0
- package/dist/src/utils/managed-command-runtime.js +6 -3
- package/dist/src/utils/managed-command-runtime.js.map +1 -1
- package/dist/src/utils/managed-command-snapshots.d.ts +17 -0
- package/dist/src/utils/managed-command-snapshots.js +84 -0
- package/dist/src/utils/managed-command-snapshots.js.map +1 -0
- package/dist/src/utils/managed-command-store.d.ts +65 -78
- package/dist/src/utils/managed-command-store.js +446 -383
- 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 -1
- 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 -0
- package/dist/src/utils/native-cli.js +166 -53
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/native-tool-context.d.ts +6 -3
- package/dist/src/utils/native-tool-context.js +3 -1
- package/dist/src/utils/native-tool-context.js.map +1 -1
- package/dist/src/utils/native-tool-review.d.ts +2 -12
- package/dist/src/utils/native-tool-review.js +6 -108
- package/dist/src/utils/native-tool-review.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +8 -0
- package/dist/src/utils/ownership.js +17 -3
- 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 -6
- package/dist/src/utils/platform-empty-state.js +146 -75
- package/dist/src/utils/platform-empty-state.js.map +1 -1
- package/dist/src/utils/plugin-config-command-apply.d.ts +33 -0
- package/dist/src/utils/plugin-config-command-apply.js +134 -0
- package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
- package/dist/src/utils/plugin-config-impact.d.ts +19 -9
- package/dist/src/utils/plugin-config-impact.js +56 -37
- package/dist/src/utils/plugin-config-impact.js.map +1 -1
- package/dist/src/utils/plugin-config-write.d.ts +19 -19
- package/dist/src/utils/plugin-config-write.js +196 -770
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-scripts.js +19 -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/rendered-contract.js +12 -6
- package/dist/src/utils/rendered-contract.js.map +1 -1
- package/dist/src/utils/skill-invocation-warning.d.ts +8 -3
- package/dist/src/utils/skill-invocation-warning.js +27 -1
- package/dist/src/utils/skill-invocation-warning.js.map +1 -1
- package/package.json +4 -3
- package/dist/src/platforms/managed-command-placement.d.ts +0 -8
- package/dist/src/platforms/managed-command-placement.js +0 -79
- package/dist/src/platforms/managed-command-placement.js.map +0 -1
- package/dist/src/utils/managed-command-evidence.d.ts +0 -7
- package/dist/src/utils/managed-command-evidence.js +0 -10
- package/dist/src/utils/managed-command-evidence.js.map +0 -1
|
@@ -2,27 +2,35 @@ 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 {
|
|
5
|
+
import { sealPermissionBatches } from './permission-batch.js';
|
|
6
|
+
import { COMMAND_ROUTE_UNREACHABLE, HOST_PERMISSION_ADDITIONAL_IMPACT, publicHostPermissionResource } from '../output/component-delivery.js';
|
|
7
|
+
import { createMarketplaceManifestEntry, getComponentFeatureRequirements, normalizeStaticPluginComponents } from '@lesliechan721/aw-plugin-core/manifest';
|
|
8
|
+
import { selectNativeProduct, supportsSharedNativeProbe } from '../platforms/discovery.js';
|
|
6
9
|
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 {
|
|
10
|
+
import { getAntigravityUnsupportedSkillControls, getQualifiedPlatformProfile } from '../platforms/capabilities.js';
|
|
11
|
+
import { getDeploymentLayout, getDeploymentResourceKey, getInvocationPolicyPhysicalKey, scopedPermissionPath, isAntigravityProjectDirectory } from '../platforms/layout.js';
|
|
12
|
+
import { getPhysicalKey, identityDigest } from '../platforms/identity.js';
|
|
13
|
+
import { antigravityLegacyProjectComponent, deploymentPackageComponent, inspectStaticSupplements, requiredDeploymentActivation } from '../platforms/inspection.js';
|
|
14
|
+
import { hasCompleteDeliveryDeclaration } from '../platforms/lifecycle.js';
|
|
15
|
+
import { piAgentConsumerDiagnostic, piProjectListContainsOnly } from '../platforms/inspection-pi.js';
|
|
16
|
+
import { grokRegistrationOwned, piProjectEmptyDeliveryObserved, piProjectRegistrationHidden, piProjectRemovalConfirmed } from '../platforms/lifecycle-native.js';
|
|
11
17
|
import { createNativeLifecycleServices } from '../platforms/lifecycle-native-services.js';
|
|
12
18
|
import { cursorWorkspaceOpenCommand } from '../platforms/projection.js';
|
|
19
|
+
import { grokProjectPermissionsAuthorized } from '../platforms/grok-permission-config.js';
|
|
20
|
+
import { isPermissionHost } from '../platforms/host-permission-policy.js';
|
|
21
|
+
import { hostPermissionFingerprint, missingPermissionOwnershipWarning, pendingRelatedProjectNotices, permissionComponent, permissionOwnerContentDigest, updateHostPermissions } from '../platforms/permission-ownership.js';
|
|
13
22
|
import { cursorHookEntryCommand, cursorHooks } from '../platforms/cursor-workspace-hook.js';
|
|
14
|
-
import { ownedSupplementFile, staticSupplementFiles } from '../platforms/supplement-layout.js';
|
|
23
|
+
import { gapSupplementFiles, ownedSupplementFile, staticSupplementFiles } from '../platforms/supplement-layout.js';
|
|
15
24
|
import { projectPlatformMarketplace } from '../platforms/projection-marketplace.js';
|
|
16
25
|
import { readStrictNamespacedMarketplaceRoot } from '../utils/local-marketplace.js';
|
|
26
|
+
import { isDeliveryCapabilityGap } from '../utils/component-gap.js';
|
|
17
27
|
import { artifactValueDigest, mergeExpectedComponentSets } from '../utils/artifact-plan.js';
|
|
18
28
|
import { preparePlatformComponents, resolveArtifactRenderConfig } from '../utils/artifact-renderer.js';
|
|
19
29
|
import { finalizePlatformSkillProducers } from '../utils/component-command-preparation.js';
|
|
20
30
|
import { cleanupOwnedComponents, createSharedOwnerToken, inspectOwnedComponents, renderOwnedTextFile, writeOwnedTextFile, writeSkillOwnerMarker } from '../utils/ownership.js';
|
|
21
|
-
import { createPlatformInputEvidence, platformPackageInputDigest, readPlatformPackageContentDigest, writePlatformEmptyState } from '../utils/platform-empty-state.js';
|
|
31
|
+
import { createPlatformInputEvidence, platformPackageInputDigest, platformPermissionNotices, readPlatformPackageContentDigest, writePlatformEmptyState } from '../utils/platform-empty-state.js';
|
|
22
32
|
import { writePlatformSupplementState } from '../platforms/supplement-state.js';
|
|
23
33
|
import { atomicReplaceSafeFile, assertSafeFileMutationPath } from '../utils/safe-fs.js';
|
|
24
|
-
import { assertManagedCommandBindingIdentities, captureManagedCommandBindingRecoveryEvidence, publishManagedCommandBindings, listManagedCommands, readInstalledCommandProducer, revokeManagedCommandBindings } from '../utils/managed-command-store.js';
|
|
25
|
-
import { captureNativeToolChanges } from '../utils/native-tool-review.js';
|
|
26
34
|
import { captureManagedCommandReviewEvidence } from '../utils/managed-command-review.js';
|
|
27
35
|
import { readClaudeSettings } from '../adapters/helpers.js';
|
|
28
36
|
import { skillInvocationWarning } from '../utils/skill-invocation-warning.js';
|
|
@@ -35,15 +43,26 @@ export function nativeInstallResources(plans) {
|
|
|
35
43
|
if (!plans.length)
|
|
36
44
|
return [{ kind: 'exclusive' }];
|
|
37
45
|
const paths = new Set();
|
|
46
|
+
const readPaths = new Set();
|
|
38
47
|
for (const plan of plans) {
|
|
39
48
|
const { binding, evidence } = plan;
|
|
40
49
|
const { layout } = evidence;
|
|
41
50
|
paths.add(layout.packageRoot);
|
|
51
|
+
for (const project of evidence.permissionBatch?.relatedProjects ?? [])
|
|
52
|
+
paths.add(project.path);
|
|
42
53
|
for (const { component } of evidence.ownership) {
|
|
43
54
|
if ('path' in component)
|
|
44
55
|
paths.add(component.path);
|
|
45
56
|
else if (component.kind === 'shared-config' && component.locator.kind === 'claude-permissions')
|
|
46
57
|
paths.add(component.locator.settingsPath);
|
|
58
|
+
else if (component.kind === 'shared-config' && component.locator.kind === 'host-permissions') {
|
|
59
|
+
const { settingsPath } = component.locator;
|
|
60
|
+
// A plugin with no current permissions may still own rules from an earlier version.
|
|
61
|
+
if (plan.effects.some((effect) => effect.destination === settingsPath))
|
|
62
|
+
paths.add(settingsPath);
|
|
63
|
+
else
|
|
64
|
+
readPaths.add(settingsPath);
|
|
65
|
+
}
|
|
47
66
|
else if (component.kind === 'shared-config' && component.locator.kind === 'cursor-workspace-hook')
|
|
48
67
|
paths.add(component.locator.hooksPath);
|
|
49
68
|
}
|
|
@@ -55,9 +74,19 @@ export function nativeInstallResources(plans) {
|
|
|
55
74
|
for (const file of evidence.marketplace?.files ?? [])
|
|
56
75
|
paths.add(path.join(layout.marketplaceRoot, file.relativePath));
|
|
57
76
|
}
|
|
77
|
+
// Grok inspects the entire project's packages and rules in one inventory.
|
|
78
|
+
// Keep peers out until this write and its confirming inspection finish.
|
|
79
|
+
if (binding.route === 'grok-directory') {
|
|
80
|
+
const entry = binding.consumers.find((consumer) => consumer.entry?.kind === 'cli')?.entry;
|
|
81
|
+
if (entry?.kind === 'cli')
|
|
82
|
+
readPaths.add(path.join(entry.configRoot, 'config.toml'));
|
|
83
|
+
if (plan.effects.length)
|
|
84
|
+
paths.add(layout.activationPath);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
58
87
|
// These routes publish an entire, plugin-specific directory. activationPath
|
|
59
88
|
// is its parent and is never replaced by the directory publisher.
|
|
60
|
-
if (binding.route === 'opencode-directory' || binding.route === 'antigravity-directory'
|
|
89
|
+
if (binding.route === 'opencode-directory' || binding.route === 'antigravity-directory')
|
|
61
90
|
continue;
|
|
62
91
|
paths.add(layout.activationPath);
|
|
63
92
|
if (binding.route === 'pi-package' || binding.route === 'cursor-workspace-hook')
|
|
@@ -68,12 +97,75 @@ export function nativeInstallResources(plans) {
|
|
|
68
97
|
paths.add(consumer.entry.configRoot);
|
|
69
98
|
}
|
|
70
99
|
}
|
|
71
|
-
return [
|
|
100
|
+
return [
|
|
101
|
+
...Array.from(paths, (value) => ({ kind: 'path', value })),
|
|
102
|
+
...[...readPaths].filter((value) => !paths.has(value)).map((value) => ({ kind: 'path', value, access: 'read' })),
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
function matchesGrokComponentOrder(before, after, publishedRoots) {
|
|
106
|
+
// Leave newly added or removed identities out of both sides. Every other
|
|
107
|
+
// row, including a surviving component of an upgraded package, anchors order.
|
|
108
|
+
const retained = (order, other) => {
|
|
109
|
+
const otherKeys = new Set(other.map(({ key }) => key));
|
|
110
|
+
return order.filter(({ sourceRoot, key }) => sourceRoot === null || !publishedRoots.has(sourceRoot) || otherKeys.has(key));
|
|
111
|
+
};
|
|
112
|
+
const previous = retained(before, after);
|
|
113
|
+
const current = retained(after, before);
|
|
114
|
+
return previous.length === current.length && previous.every((row, index) => row.key === current[index].key);
|
|
115
|
+
}
|
|
116
|
+
function grokSourceDigest(sources, root, name, scope, version) {
|
|
117
|
+
const index = sources.sources.findIndex((source) => path.normalize(source.path) === root);
|
|
118
|
+
const source = sources.sources[index];
|
|
119
|
+
if (!sources.overlaps.includes(name) && source?.name === name && source.version
|
|
120
|
+
&& (!version || source.version === version) && source.scope === scope && source.origin === 'native' && source.enabled === true) {
|
|
121
|
+
return sources.grokScopeEvidence?.sourceDigests[index];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async function grokUserContentDigest({ installedRoot, owner, hasPackageHook }) {
|
|
125
|
+
try {
|
|
126
|
+
await assertSafeFileMutationPath({ filePath: path.join(installedRoot, '.grok-plugin', 'plugin.json'),
|
|
127
|
+
allowedRoot: path.dirname(path.dirname(installedRoot)), label: 'Grok installed package' });
|
|
128
|
+
const marker = await readSkillOwnerMarker({ skillRoot: owner.path, allowedRoot: owner.allowedRoot, expectedIdentity: owner.identity });
|
|
129
|
+
const projection = marker?.nativeProjection;
|
|
130
|
+
if (hasPackageHook && !projection?.components.some((component) => component.relativeOutputs.includes('hooks/hooks.json')))
|
|
131
|
+
return;
|
|
132
|
+
const digest = projection?.contentDigest;
|
|
133
|
+
if (digest && (await Promise.all([owner.path, installedRoot].map(readPlatformPackageContentDigest))).every((value) => value === digest))
|
|
134
|
+
return digest;
|
|
135
|
+
}
|
|
136
|
+
catch { /* Unverified bytes cannot explain the change of visible source. */ }
|
|
137
|
+
}
|
|
138
|
+
async function grokUserBehindProject(ctx, binding, before) {
|
|
139
|
+
const sources = before.prerequisites.nativeSources;
|
|
140
|
+
const evidence = sources?.grokScopeEvidence;
|
|
141
|
+
if (binding.route !== 'grok-directory' || before.package !== 'absent' || before.ownership !== 'absent'
|
|
142
|
+
|| sources?.observation !== 'complete' || !evidence?.userRegistrationDigest)
|
|
143
|
+
return;
|
|
144
|
+
const name = before.nativeIdentity?.packageId;
|
|
145
|
+
const user = sources.sources.find((source) => source.name === name && source.scope === 'user');
|
|
146
|
+
if (!user)
|
|
147
|
+
return;
|
|
148
|
+
const nativeDigest = grokSourceDigest(sources, user.path, user.name, 'user', binding.plugin.version);
|
|
149
|
+
if (!nativeDigest)
|
|
150
|
+
return;
|
|
151
|
+
const personal = { ...binding, route: 'grok-cli', scope: { kind: 'user' } };
|
|
152
|
+
const layout = await getDeploymentLayout(ctx, personal);
|
|
153
|
+
if (evidence.userRegistrationDigest !== artifactValueDigest([user.path, layout.packageRoot]))
|
|
154
|
+
return;
|
|
155
|
+
const owner = deploymentPackageComponent({ ...personal, physicalKey: getPhysicalKey(layout.physicalIdentity) }, layout);
|
|
156
|
+
const hasPackageHook = evidence.hookOrder.some((row) => row.sourceRoot === user.path);
|
|
157
|
+
return { installedRoot: user.path, owner, nativeDigest, hasPackageHook };
|
|
72
158
|
}
|
|
73
159
|
function nativeCopyIncomplete(binding, after, contentDigest) {
|
|
74
160
|
return ['antigravity-cli', 'grok-cli'].includes(binding.route)
|
|
75
161
|
&& after.nativePackageContentDigest !== contentDigest;
|
|
76
162
|
}
|
|
163
|
+
function piProjectInventoryKey(binding, settingsPath) {
|
|
164
|
+
if (binding.route !== 'pi-package' || binding.scope.kind !== 'project')
|
|
165
|
+
return undefined;
|
|
166
|
+
const product = selectNativeProduct(binding.consumers);
|
|
167
|
+
return product ? JSON.stringify([binding.scope.projectRoot, settingsPath, product.id]) : undefined;
|
|
168
|
+
}
|
|
77
169
|
function packageDeliveryConfirmed(binding, after, contentDigest, requireIndependentActivation) {
|
|
78
170
|
return after.package === 'present' && ['aw', 'shared'].includes(after.ownership)
|
|
79
171
|
&& !nativeCopyIncomplete(binding, after, contentDigest)
|
|
@@ -91,7 +183,7 @@ export function nativeDeploymentHasVerifiedComponentWrite(plan, receipt) {
|
|
|
91
183
|
if (receipt.bindingId !== plan.binding.id || after.physicalKey !== plan.binding.physicalKey)
|
|
92
184
|
return false;
|
|
93
185
|
const delivered = after.components.filter(({ id, presence, reasonCodes }) => presence === 'present' && !reasonCodes.length
|
|
94
|
-
&& !unmet.some((gap) => (gap.componentId ?? gap.id) === id));
|
|
186
|
+
&& !unmet.some((gap) => !isDeliveryCapabilityGap(gap) && (gap.componentId ?? gap.id) === id));
|
|
95
187
|
if (!delivered.length)
|
|
96
188
|
return false;
|
|
97
189
|
const bundle = plan.projections.find((projection) => projection.bundle)?.bundle;
|
|
@@ -134,10 +226,12 @@ async function pathEvidence(location) {
|
|
|
134
226
|
throw new Error('deploymentEvidenceInvalid: a deployment resource is not a regular file.');
|
|
135
227
|
return { mode: stat.mode & 0o777, digest: crypto.createHash('sha256').update(await fs.readFile(location)).digest('hex') };
|
|
136
228
|
}
|
|
137
|
-
async function ownedContentDigest(component) {
|
|
229
|
+
async function ownedContentDigest(component, ctx) {
|
|
138
230
|
if (component.kind === 'owned-directory' || component.kind === 'skill-directory')
|
|
139
231
|
return readPlatformPackageContentDigest(component.path);
|
|
140
232
|
if (component.kind === 'shared-config') {
|
|
233
|
+
if (component.locator.kind === 'host-permissions')
|
|
234
|
+
return permissionOwnerContentDigest(ctx, component.locator);
|
|
141
235
|
let value;
|
|
142
236
|
if (component.locator.kind === 'claude-permissions') {
|
|
143
237
|
const permissions = (await readClaudeSettings(component.locator.settingsPath)).awGenerated?.permissions?.[component.locator.ownerKey];
|
|
@@ -187,7 +281,7 @@ async function ownedSupplements(binding, root, physicalKey) {
|
|
|
187
281
|
return result;
|
|
188
282
|
}
|
|
189
283
|
function readContext(context, cwd) {
|
|
190
|
-
return { cwd, env: context.env, runner: context.nativeCliRunner, signal: context.signal,
|
|
284
|
+
return { cwd, invocationCwd: context.invocationCwd, env: context.env, runner: context.nativeCliRunner, signal: context.signal,
|
|
191
285
|
codexObservationSession: context.codexObservationSession };
|
|
192
286
|
}
|
|
193
287
|
function operation(input) {
|
|
@@ -214,6 +308,9 @@ function contributionComponent(binding, contribution, physicalKey) {
|
|
|
214
308
|
sourceIdentity: binding.plugin.sourceIdentity, physicalKey,
|
|
215
309
|
platform: binding.platform, scope: binding.scope.kind, artifactKey: path.basename(contribution.destination) };
|
|
216
310
|
if (contribution.kind === 'config-entry') {
|
|
311
|
+
if (isPermissionHost(binding.platform) && contribution.mergeKey?.startsWith(`${binding.platform}-permissions:`)) {
|
|
312
|
+
return permissionComponent(binding, contribution.destination, physicalKey);
|
|
313
|
+
}
|
|
217
314
|
if (binding.platform === 'claude' && contribution.mergeKey?.startsWith('claude-permissions:')) {
|
|
218
315
|
const owner = { ...identity, artifactKey: contribution.mergeKey.replace(':', '-') };
|
|
219
316
|
return { kind: 'shared-config', identity: owner, label: contribution.destination,
|
|
@@ -265,8 +362,10 @@ export const platformOwnership = {
|
|
|
265
362
|
};
|
|
266
363
|
async function requireWritable(component, executor = platformOwnership) {
|
|
267
364
|
const inspection = await inspectOwnedComponents({ components: [component], executor });
|
|
268
|
-
|
|
365
|
+
const state = inspection.components[0].state;
|
|
366
|
+
if (state !== 'present' && state !== 'absent')
|
|
269
367
|
throw new Error('operationPlanStale: deployment ownership changed.');
|
|
368
|
+
return state;
|
|
270
369
|
}
|
|
271
370
|
async function publishDirectory(source, component, nativeProjection, staged) {
|
|
272
371
|
if (component.kind !== 'owned-directory')
|
|
@@ -276,7 +375,9 @@ async function publishDirectory(source, component, nativeProjection, staged) {
|
|
|
276
375
|
allowedRoot: component.allowedRoot, label: 'Native package', createParent: true });
|
|
277
376
|
const staging = await fs.mkdtemp(path.join(component.allowedRoot, '.aw-package-'));
|
|
278
377
|
const candidate = path.join(staging, component.identity.artifactKey);
|
|
279
|
-
const
|
|
378
|
+
const verifiesContents = component.identity.platform === 'antigravity' && component.identity.scope === 'project';
|
|
379
|
+
const backupRoot = `${staging}.previous`;
|
|
380
|
+
const backup = verifiesContents ? path.join(backupRoot, component.identity.artifactKey) : backupRoot;
|
|
280
381
|
let moved = false;
|
|
281
382
|
try {
|
|
282
383
|
if (staged && nativeProjection) {
|
|
@@ -297,12 +398,15 @@ async function publishDirectory(source, component, nativeProjection, staged) {
|
|
|
297
398
|
else
|
|
298
399
|
await fs.copy(source, candidate, { dereference: false });
|
|
299
400
|
await writeSkillOwnerMarker({ skillRoot: candidate, allowedRoot: staging, identity: component.identity, nativeProjection });
|
|
300
|
-
await requireWritable(component);
|
|
301
|
-
if (await fs.pathExists(component.path)) {
|
|
401
|
+
const state = await requireWritable(component);
|
|
402
|
+
if (verifiesContents ? state === 'present' : await fs.pathExists(component.path)) {
|
|
302
403
|
await fs.move(component.path, backup);
|
|
303
404
|
moved = true;
|
|
304
405
|
}
|
|
305
406
|
try {
|
|
407
|
+
if (verifiesContents && moved && await requireWritable({ ...component, path: backup, allowedRoot: backupRoot }) !== 'present') {
|
|
408
|
+
throw new Error('operationPlanStale: deployment backup could not be verified.');
|
|
409
|
+
}
|
|
306
410
|
await fs.move(candidate, component.path);
|
|
307
411
|
}
|
|
308
412
|
catch (error) {
|
|
@@ -315,6 +419,8 @@ async function publishDirectory(source, component, nativeProjection, staged) {
|
|
|
315
419
|
}
|
|
316
420
|
finally {
|
|
317
421
|
await fs.remove(staging);
|
|
422
|
+
if (verifiesContents)
|
|
423
|
+
await fs.rmdir(backupRoot).catch(() => undefined);
|
|
318
424
|
}
|
|
319
425
|
}
|
|
320
426
|
async function sharedReferences(context, binding, observation, layout) {
|
|
@@ -393,6 +499,25 @@ export class PlatformRebuildSession {
|
|
|
393
499
|
units = new Map();
|
|
394
500
|
published = new Map();
|
|
395
501
|
nativeEffects = new Map();
|
|
502
|
+
piProjectRegisteredRoots = new Map();
|
|
503
|
+
// A sibling target can update the same permission file. Only the exact pair
|
|
504
|
+
// of host and sidecar bytes confirmed by our own write inherits its baseline.
|
|
505
|
+
permissionWrites = new Map();
|
|
506
|
+
openCodeProjectBatches = new Map();
|
|
507
|
+
pendingOpenCodeProjectNotices(interrupted) {
|
|
508
|
+
return [...this.openCodeProjectBatches.values()].flatMap((batch) => pendingRelatedProjectNotices(batch, interrupted));
|
|
509
|
+
}
|
|
510
|
+
grokPermissionWrites = new Map();
|
|
511
|
+
recordPermissionWrite(target, previous, current, host) {
|
|
512
|
+
const last = this.permissionWrites.get(target);
|
|
513
|
+
this.permissionWrites.set(target, { previous: last?.current === previous ? last.previous : previous, current });
|
|
514
|
+
if (host && host.previous !== host.current) {
|
|
515
|
+
const earlier = this.grokPermissionWrites.get(target);
|
|
516
|
+
this.grokPermissionWrites.set(target, { previous: earlier && earlier.current === host.previous ? earlier.previous : host.previous, current: host.current });
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
grokPublications = new Map();
|
|
520
|
+
grokProjectRetirements = new Map();
|
|
396
521
|
exclusions = new Map();
|
|
397
522
|
contexts = new Set();
|
|
398
523
|
mutableChecks = new Map();
|
|
@@ -422,10 +547,88 @@ export class PlatformRebuildSession {
|
|
|
422
547
|
? batch !== this.closedObservationBatch : this.targets.size === 0 && platform !== 'codex';
|
|
423
548
|
return open && batch ? { ...ctx, ...batch } : ctx;
|
|
424
549
|
}
|
|
550
|
+
recordGrokWrites(prepared, receipt, packagePublished, writtenFiles, shadowedUser) {
|
|
551
|
+
const { binding, operation, evidence: { layout } } = prepared.plan;
|
|
552
|
+
const sources = receipt.after.prerequisites.nativeSources;
|
|
553
|
+
const evidence = sources?.grokScopeEvidence;
|
|
554
|
+
if (!['grok-cli', 'grok-directory'].includes(binding.route) || operation !== 'ensure'
|
|
555
|
+
|| receipt.diagnostics.some((item) => item.severity === 'error') || sources?.observation !== 'complete' || !evidence)
|
|
556
|
+
return;
|
|
557
|
+
const scope = binding.scope.kind;
|
|
558
|
+
const scopeRoot = binding.scope.kind === 'project' ? binding.scope.projectRoot : layout.activationPath;
|
|
559
|
+
const { before, packageComponent: owner, bundle, contributions } = prepared.driverState;
|
|
560
|
+
const priorSources = before.prerequisites.nativeSources;
|
|
561
|
+
const identity = receipt.after.nativeIdentity;
|
|
562
|
+
const registrationId = identity?.registrationId;
|
|
563
|
+
const refreshed = binding.route === 'grok-cli' && registrationId && bundle
|
|
564
|
+
&& before.grokScopeAuthorization === 'granted' && receipt.after.grokScopeAuthorization === 'granted'
|
|
565
|
+
&& grokRegistrationOwned(binding, prepared.plan.evidence, before, identity)
|
|
566
|
+
&& grokRegistrationOwned(binding, prepared.plan.evidence, receipt.after, identity)
|
|
567
|
+
&& receipt.after.nativePackageContentDigest === bundle.contentDigest
|
|
568
|
+
&& prepared.plan.effects.some((effect) => effect.kind === 'refresh' && receipt.effects.some((result) => result.id === effect.id && result.status === 'applied' && result.mutation === 'confirmed'));
|
|
569
|
+
// A previous refusal can leave the AW source up to date. Only the confirmed
|
|
570
|
+
// native refresh explains a change to the User inventory in this operation.
|
|
571
|
+
const installedRoot = refreshed ? path.join(scopeRoot, 'installed-plugins', registrationId) : undefined;
|
|
572
|
+
const root = installedRoot ?? path.normalize(layout.packageRoot);
|
|
573
|
+
if ((refreshed || binding.route === 'grok-directory' && packagePublished) && priorSources?.observation === 'complete'
|
|
574
|
+
&& receipt.after.package === 'present' && receipt.after.ownership === 'aw' && bundle
|
|
575
|
+
&& owner?.kind === 'owned-directory' && owner.path === layout.packageRoot && identity?.route === binding.route
|
|
576
|
+
&& identity.sourceLocation === layout.packageRoot) {
|
|
577
|
+
const newlyInstalled = binding.route === 'grok-directory' && before.package === 'absent' && before.ownership === 'absent'
|
|
578
|
+
&& !priorSources.sources.some((source) => path.normalize(source.path) === root
|
|
579
|
+
|| source.name === identity.packageId && source.path !== shadowedUser?.installedRoot)
|
|
580
|
+
&& (!shadowedUser || !sources.sources.some((source) => source.path === shadowedUser.installedRoot));
|
|
581
|
+
const priorNativeDigest = before.package === 'present' && before.ownership === 'aw' && (refreshed || before.packageVersion)
|
|
582
|
+
? grokSourceDigest(priorSources, root, identity.packageId, scope, refreshed ? undefined : before.packageVersion) : undefined;
|
|
583
|
+
const nativeDigest = grokSourceDigest(sources, root, identity.packageId, scope, binding.plugin.version);
|
|
584
|
+
const knownHooks = !evidence.hookOrder.some((row) => row.sourceRoot === root) || prepared.plan.projections.some((projection) => projection.bundle
|
|
585
|
+
&& projection.components.some((component) => component.relativeOutputs.includes('hooks/hooks.json')));
|
|
586
|
+
if ((newlyInstalled || priorNativeDigest) && nativeDigest && knownHooks) {
|
|
587
|
+
this.grokPublications.set(root, { scope, scopeRoot, installedRoot, nativeDigest, priorNativeDigest, contentDigest: bundle.contentDigest,
|
|
588
|
+
owner, orderAfter: evidence, shadowedUser,
|
|
589
|
+
sourceOrderAfter: shadowedUser && sources.sources.map((source) => path.normalize(source.path)) });
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const prior = priorSources?.grokScopeEvidence?.instructions;
|
|
593
|
+
for (const { effectId, component } of contributions) {
|
|
594
|
+
if (component.kind !== 'owned-text-file' || !prior)
|
|
595
|
+
continue;
|
|
596
|
+
const written = writtenFiles.get(component.path);
|
|
597
|
+
const rows = evidence.instructions.filter((row) => row.rulePath === component.path);
|
|
598
|
+
const previous = prior.filter((row) => row.rulePath === component.path);
|
|
599
|
+
if (written && rows.length === 1 && previous.length <= 1 && receipt.effects.some((effect) => effect.id === effectId && effect.status === 'applied' && effect.mutation === 'confirmed')) {
|
|
600
|
+
this.grokPublications.set(component.path, { scope, scopeRoot, nativeDigest: rows[0].digest,
|
|
601
|
+
priorNativeDigest: previous[0]?.digest, contentDigest: written.digest, owner: component });
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
recordGrokProjectRetirement(projectRoot, project, user, removed) {
|
|
606
|
+
const old = project.nativeIdentity;
|
|
607
|
+
const replacement = user.nativeIdentity;
|
|
608
|
+
if (old?.route !== 'grok-directory' || project.ownership !== 'aw' || project.package !== 'present'
|
|
609
|
+
|| replacement?.route !== 'grok-cli' || replacement.packageId !== old.packageId || !replacement.registrationId
|
|
610
|
+
|| user.ownership !== 'aw' || user.registration !== 'present' || user.nativePackage !== 'present' || !user.nativePackageContentDigest
|
|
611
|
+
|| path.dirname(old.sourceLocation) !== path.join(projectRoot, '.grok', 'plugins') || !removed.includes(path.basename(old.sourceLocation)))
|
|
612
|
+
return;
|
|
613
|
+
const before = project.prerequisites.nativeSources;
|
|
614
|
+
const personal = user.prerequisites.nativeSources;
|
|
615
|
+
if (before?.observation !== 'complete' || personal?.observation !== 'complete')
|
|
616
|
+
return;
|
|
617
|
+
const source = personal.sources.find(({ name, path: location }) => name === old.packageId
|
|
618
|
+
&& path.basename(location) === replacement.registrationId && path.basename(path.dirname(location)) === 'installed-plugins');
|
|
619
|
+
const projectDigest = grokSourceDigest(before, old.sourceLocation, old.packageId, 'project');
|
|
620
|
+
const userDigest = source && grokSourceDigest(personal, source.path, old.packageId, 'user');
|
|
621
|
+
if (!projectDigest || !source || !userDigest)
|
|
622
|
+
return;
|
|
623
|
+
// Retirement can reveal an inherited static Skill provider only.
|
|
624
|
+
if (personal.grokScopeEvidence?.hookOrder.some((row) => row.sourceRoot === source.path))
|
|
625
|
+
return;
|
|
626
|
+
this.grokProjectRetirements.set(old.sourceLocation, { projectRoot, name: old.packageId, projectPackage: old.sourceLocation,
|
|
627
|
+
projectDigest, userPackage: source.path, userDigest, userSource: replacement.sourceLocation,
|
|
628
|
+
userContentDigest: user.nativePackageContentDigest, userPhysicalKey: user.physicalKey });
|
|
629
|
+
}
|
|
425
630
|
async dispose() {
|
|
426
|
-
|
|
427
|
-
if (result.status === 'fulfilled')
|
|
428
|
-
await result.value.finalized.cleanup();
|
|
631
|
+
await Promise.allSettled(this.units.values());
|
|
429
632
|
if (this.staging)
|
|
430
633
|
await fs.remove(await this.staging);
|
|
431
634
|
this.staging = undefined;
|
|
@@ -434,7 +637,10 @@ export class PlatformRebuildSession {
|
|
|
434
637
|
this.units.clear();
|
|
435
638
|
this.published.clear();
|
|
436
639
|
this.nativeEffects.clear();
|
|
640
|
+
this.piProjectRegisteredRoots.clear();
|
|
437
641
|
this.exclusions.clear();
|
|
642
|
+
this.grokPublications.clear();
|
|
643
|
+
this.grokProjectRetirements.clear();
|
|
438
644
|
this.contexts.clear();
|
|
439
645
|
this.mutableChecks.clear();
|
|
440
646
|
this.requestedOperations.clear();
|
|
@@ -444,7 +650,7 @@ export class PlatformRebuildSession {
|
|
|
444
650
|
}
|
|
445
651
|
freezeMarketplaceCandidates() { this.marketplaceCandidatesFrozen = true; }
|
|
446
652
|
key(input) { return artifactValueDigest({ plugin: sourceIdentity(input), platform: input.platform, scope: input.scope, cwd: input.scope === 'project' ? input.cwd : null, operation: operation(input) }); }
|
|
447
|
-
resolve(input) {
|
|
653
|
+
resolve(input, placementProbeGroup) {
|
|
448
654
|
const key = this.key(input);
|
|
449
655
|
// Inspection of a shared package does not request activation in that scope.
|
|
450
656
|
if (!input.readOnlyInspectionPlan)
|
|
@@ -460,7 +666,7 @@ export class PlatformRebuildSession {
|
|
|
460
666
|
&& candidate.binding.plugin.sourceIdentity === plugin.sourceIdentity && candidate.binding.plugin.pluginId === plugin.pluginId
|
|
461
667
|
&& candidate.binding.scope.kind === input.scope && (candidate.binding.scope.kind !== 'project' || candidate.binding.scope.projectRoot === input.cwd));
|
|
462
668
|
const scope = input.scope === 'project' ? { kind: 'project', projectRoot: input.cwd } : { kind: 'user' };
|
|
463
|
-
const discovery = await adapter.discover(ctx);
|
|
669
|
+
const discovery = await adapter.discover(placementProbeGroup ? { ...ctx, placementProbeGroup } : ctx);
|
|
464
670
|
const resolution = await adapter.resolve(ctx, { plugin, scope, operation: operation(input), discovery, recoveryCandidates });
|
|
465
671
|
this.exclusions.set(key, resolution.exclusions.flatMap((exclusion) => {
|
|
466
672
|
if (!exclusion.productId)
|
|
@@ -487,7 +693,13 @@ export class PlatformRebuildSession {
|
|
|
487
693
|
}
|
|
488
694
|
/** Resolve the whole selected scope before any physical unit is rendered. */
|
|
489
695
|
async resolveAll(inputs) {
|
|
490
|
-
|
|
696
|
+
const first = inputs[0];
|
|
697
|
+
const samePlacement = supportsSharedNativeProbe && first && inputs.length > 1
|
|
698
|
+
&& this.context.batchInstallPlatform === first.platform && this.context.nativeObservationBatch?.scriptFreePlacement === true
|
|
699
|
+
&& inputs.every((input) => input.platform === first.platform && input.scope === first.scope && input.cwd === first.cwd
|
|
700
|
+
&& operation(input) === 'ensure');
|
|
701
|
+
const group = samePlacement ? { scope: first.scope, probes: new Map() } : undefined;
|
|
702
|
+
await Promise.allSettled(inputs.map((input) => this.resolve(input, group)));
|
|
491
703
|
}
|
|
492
704
|
async freezeSharedPreApplyActions(targets) {
|
|
493
705
|
const prepared = (await Promise.allSettled(this.targets.values())).flatMap((result) => result.status === 'fulfilled' ? [result.value] : []);
|
|
@@ -527,6 +739,7 @@ export class PlatformRebuildSession {
|
|
|
527
739
|
this.marketplaceTargets.add(target);
|
|
528
740
|
targets = [...this.marketplaceTargets];
|
|
529
741
|
await this.freezeSharedPreApplyActions(targets);
|
|
742
|
+
await sealPermissionBatches(targets, (target) => readContext(this.context, target.identity.cwd), this.adapterFor);
|
|
530
743
|
const retained = new Map(targets.flatMap((target) => (target.platformDeployment?.plans ?? [])
|
|
531
744
|
.filter((plan) => plan.evidence.retainPackage).map((plan) => [plan.binding.physicalKey, plan.expected.unmet])));
|
|
532
745
|
for (const target of targets)
|
|
@@ -607,10 +820,6 @@ export class PlatformRebuildSession {
|
|
|
607
820
|
prepared.plans.splice(prepared.plans.findIndex((plan) => plan.binding.id === deployment.plan.binding.id), 1, next.prepared.plan);
|
|
608
821
|
}
|
|
609
822
|
}
|
|
610
|
-
for (const target of targets)
|
|
611
|
-
if (target.platformDeployment) {
|
|
612
|
-
target.nativeToolChanges = await target.platformDeployment.captureNativeToolChanges();
|
|
613
|
-
}
|
|
614
823
|
}
|
|
615
824
|
async verifyMarketplace(plan) {
|
|
616
825
|
if (!plan.evidence.layout.marketplaceRoot || !plan.evidence.marketplace)
|
|
@@ -729,14 +938,19 @@ export class PlatformRebuildSession {
|
|
|
729
938
|
env: this.context.env, referencePlugins: this.context.referencePlugins });
|
|
730
939
|
const platformRoot = path.join(input.plugin.rootDir, input.platform);
|
|
731
940
|
const staticResourceRoot = await fs.pathExists(platformRoot) ? platformRoot : input.plugin.rootDir;
|
|
941
|
+
// Grok prepares the package before its rules. Only roles prepared for this same target can receive the text.
|
|
942
|
+
const grokRoleUnit = input.platform === 'grok' && unit.output === 'supplement'
|
|
943
|
+
? bindingEntry.layout.renderUnits.find((candidate) => candidate.output === 'package'
|
|
944
|
+
&& artifactValueDigest(candidate.renderScope) === artifactValueDigest(unit.renderScope)) : undefined;
|
|
732
945
|
const prepared = await preparePlatformComponents({ plugin: input.plugin, platform: input.platform, staticResourceRoot,
|
|
733
946
|
renderScope: unit.renderScope.kind, kinds: unit.kinds, capabilities, config, cwd: input.cwd,
|
|
947
|
+
hasInstructionAgentRecipients: grokRoleUnit && preparedUnits.get(grokRoleUnit.id)?.prepared.expected.components.some(({ kind }) => kind === 'agent'),
|
|
734
948
|
commandEnv: this.context.env, signal: this.context.signal, scriptTimeoutMs: this.context.scriptTimeoutMs,
|
|
735
949
|
preparedResults: this.context.preparedArtifactRenderResults });
|
|
736
950
|
const finalized = await finalizePlatformSkillProducers({ plugin: input.plugin, plugins: this.context.referencePlugins,
|
|
737
951
|
platform: input.platform, renderUnit: commonUnit, prepared, skillWorkRoot: path.join(await this.root(), artifactValueDigest(unit.physicalKey).slice(7), 'skills'),
|
|
738
952
|
cwd: input.cwd, env: this.context.env, signal: this.context.signal, scriptTimeoutMs: this.context.scriptTimeoutMs,
|
|
739
|
-
|
|
953
|
+
commandRecord: input.commandRecord });
|
|
740
954
|
return { unit: commonUnit, prepared: finalized.prepared, finalized,
|
|
741
955
|
evidenceInput: { renderUnit: commonUnit, capabilities, config } };
|
|
742
956
|
})();
|
|
@@ -749,57 +963,20 @@ export class PlatformRebuildSession {
|
|
|
749
963
|
const blockedReceipts = [];
|
|
750
964
|
const cleanupResults = [];
|
|
751
965
|
const checks = new Map();
|
|
966
|
+
const shadowedUsers = new Map();
|
|
752
967
|
let initialDiscoveryCheck;
|
|
753
|
-
const priorProducers = new Map();
|
|
754
|
-
const priorResourceRoots = new Map();
|
|
755
|
-
const bindingRecoveryEvidence = [];
|
|
756
968
|
const emptyStates = new Map();
|
|
969
|
+
const gapStates = new Map();
|
|
757
970
|
const inputDigests = new Map();
|
|
758
971
|
const supplementInputDigests = new Map();
|
|
759
|
-
const commandInventory = await listManagedCommands(this.context.env);
|
|
760
|
-
for (const entry of observed)
|
|
761
|
-
priorProducers.set(entry.binding.id, commandInventory.commands.flatMap((command) => {
|
|
762
|
-
if (command.owner.kind !== 'plugin')
|
|
763
|
-
return [];
|
|
764
|
-
const producer = command.owner.producer;
|
|
765
|
-
return producer.kind !== 'package' && producer.sourceId === entry.binding.plugin.sourceId
|
|
766
|
-
&& producer.sourceIdentity === entry.binding.plugin.sourceIdentity && producer.pluginName === input.plugin.manifest.name
|
|
767
|
-
&& producer.platform === entry.binding.platform && producer.placementKey === entry.binding.physicalKey ? [producer] : [];
|
|
768
|
-
}));
|
|
769
|
-
for (const entry of observed) {
|
|
770
|
-
const component = deploymentPackageComponent(entry.binding, entry.layout);
|
|
771
|
-
if (component.kind !== 'owned-directory')
|
|
772
|
-
continue;
|
|
773
|
-
const marker = await readSkillOwnerMarker({ skillRoot: component.path, allowedRoot: component.allowedRoot,
|
|
774
|
-
expectedIdentity: component.identity }).catch(() => null);
|
|
775
|
-
for (const mapping of marker?.nativeProjection?.components ?? []) {
|
|
776
|
-
if (!mapping.relativeOutputs.includes(`skills/${mapping.nativeName}/SKILL.md`))
|
|
777
|
-
continue;
|
|
778
|
-
const root = path.join(component.path, 'skills', mapping.nativeName);
|
|
779
|
-
const record = await readInstalledCommandProducer(root).catch(() => null);
|
|
780
|
-
const producer = record?.producer;
|
|
781
|
-
if (!producer || producer.kind === 'package' || producer.sourceId !== entry.binding.plugin.sourceId
|
|
782
|
-
|| producer.sourceIdentity !== entry.binding.plugin.sourceIdentity || producer.pluginName !== input.plugin.manifest.name
|
|
783
|
-
|| producer.platform !== entry.binding.platform || producer.placementKey !== entry.binding.physicalKey
|
|
784
|
-
|| mapping.id !== (producer.kind === 'static-skill' ? `skill:${producer.key}` : producer.key))
|
|
785
|
-
continue;
|
|
786
|
-
priorProducers.get(entry.binding.id).push(producer);
|
|
787
|
-
priorResourceRoots.set(entry.binding.id, [...priorResourceRoots.get(entry.binding.id) ?? [], root]);
|
|
788
|
-
if (!removing) {
|
|
789
|
-
// An unreadable index has no authority. Only the installed canonical
|
|
790
|
-
// producer and its owned resources can establish its former identity.
|
|
791
|
-
const recovery = await captureManagedCommandBindingRecoveryEvidence({ producer, resourceRoot: root,
|
|
792
|
-
env: this.context.env }).catch(() => null);
|
|
793
|
-
if (recovery)
|
|
794
|
-
bindingRecoveryEvidence.push(recovery);
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
await assertManagedCommandBindingIdentities({ producers: [...preparedUnits.values()].flatMap((unit) => unit.finalized.commandCandidates),
|
|
799
|
-
env: this.context.env, bindingRecoveryEvidence });
|
|
800
972
|
for (const entry of observed) {
|
|
801
973
|
const units = entry.binding.renderUnitIds.flatMap((id) => preparedUnits.has(id) ? [preparedUnits.get(id)] : []);
|
|
802
974
|
const projections = [];
|
|
975
|
+
const hostEntry = entry.binding.consumers[0]?.entry;
|
|
976
|
+
const hostRoot = hostEntry && hostEntry.kind !== 'generic' ? hostEntry.configRoot : undefined;
|
|
977
|
+
const grokProjectBlocked = entry.binding.platform === 'grok' && entry.binding.scope.kind === 'project'
|
|
978
|
+
&& (entry.observation.grokScopeAuthorization !== 'granted' || !hostRoot
|
|
979
|
+
|| !await grokProjectPermissionsAuthorized(ctx, hostRoot, entry.binding.scope.projectRoot));
|
|
803
980
|
for (const unit of units) {
|
|
804
981
|
const sameScope = units.filter((candidate) => artifactValueDigest(candidate.unit.renderScope) === artifactValueDigest(unit.unit.renderScope));
|
|
805
982
|
const components = mergeExpectedComponentSets(sameScope.map((candidate) => candidate.prepared.expected)).components;
|
|
@@ -808,18 +985,36 @@ export class PlatformRebuildSession {
|
|
|
808
985
|
files: sameScope.flatMap((candidate) => candidate.prepared.resources.files),
|
|
809
986
|
commandResources: sameScope.flatMap((candidate) => candidate.prepared.resources.commandResources),
|
|
810
987
|
digest: artifactValueDigest(sameScope.map((candidate) => candidate.prepared.resources.digest)) };
|
|
811
|
-
|
|
988
|
+
const projection = await adapter.project({ ...ctx, stagingRoot: path.join(await this.root(), 'projection') }, {
|
|
812
989
|
binding: entry.binding, renderUnit: unit.unit, capabilities: adapter.capabilities({ ...entry, renderUnit: unit.unit, profile: getQualifiedPlatformProfile(input.platform) }),
|
|
813
|
-
components, resources, policy:
|
|
814
|
-
|
|
990
|
+
components, resources, policy: unit.finalized.invocationPolicy.policy,
|
|
991
|
+
...(grokProjectBlocked ? { grokScopeAuthorization: 'denied' } : {})
|
|
992
|
+
});
|
|
993
|
+
for (const notice of unit.finalized.invocationPolicy.diagnostics) {
|
|
994
|
+
projection.diagnostics.push({ ...notice, subject: { ...notice.subject, scope: entry.binding.scope.kind } });
|
|
995
|
+
}
|
|
996
|
+
projections.push(projection);
|
|
815
997
|
}
|
|
816
|
-
const
|
|
998
|
+
const hostPolicyPath = isPermissionHost(input.platform) && (input.platform !== 'antigravity' || entry.binding.route === 'antigravity-cli')
|
|
999
|
+
? await scopedPermissionPath(ctx, input.platform, entry.binding.scope, hostEntry && hostEntry.kind !== 'generic' ? hostEntry.configRoot : undefined)
|
|
1000
|
+
: undefined;
|
|
1001
|
+
const policyKey = hostPolicyPath || input.platform === 'codex' || input.platform === 'claude'
|
|
1002
|
+
? await getInvocationPolicyPhysicalKey(ctx, entry.binding) : undefined;
|
|
1003
|
+
const expected = mergeExpectedComponentSets(units.map((unit) => unit.prepared.expected));
|
|
817
1004
|
const currentComponents = [deploymentPackageComponent(entry.binding, entry.layout),
|
|
818
|
-
...projections.flatMap((projection) => projection.supplements.map((contribution) => contributionComponent(entry.binding, contribution, policyKey && (contribution.mergeKey?.startsWith(
|
|
1005
|
+
...projections.flatMap((projection) => projection.supplements.map((contribution) => contributionComponent(entry.binding, contribution, policyKey && (contribution.mergeKey?.startsWith(`${input.platform}-permissions:`) || input.platform === 'codex' && contribution.destination.endsWith('.rules'))
|
|
819
1006
|
? policyKey : entry.layout.renderUnits.find((unit) => unit.id === projection.renderUnitId).physicalKey)))];
|
|
820
1007
|
const historical = await ownedSupplements(entry.binding, entry.layout.supplementRoot, entry.layout.renderUnits.find((unit) => unit.output === 'supplement')?.physicalKey);
|
|
1008
|
+
const antigravityProject = isAntigravityProjectDirectory(entry.binding);
|
|
1009
|
+
const legacyPackage = entry.observation.antigravityLegacyProjectPackage?.state === 'owned'
|
|
1010
|
+
? antigravityLegacyProjectComponent(entry.binding, entry.layout) : undefined;
|
|
1011
|
+
if (legacyPackage)
|
|
1012
|
+
historical.push(legacyPackage);
|
|
821
1013
|
if (entry.binding.platform === 'codex' && policyKey)
|
|
822
1014
|
historical.push(...await ownedSupplements(entry.binding, path.join(entry.layout.activationPath, 'rules'), policyKey));
|
|
1015
|
+
if (hostPolicyPath && policyKey && !grokProjectBlocked) {
|
|
1016
|
+
historical.push(permissionComponent(entry.binding, hostPolicyPath, policyKey));
|
|
1017
|
+
}
|
|
823
1018
|
if (entry.binding.platform === 'claude' && policyKey) {
|
|
824
1019
|
const destination = path.join(entry.layout.activationPath, entry.binding.scope.kind === 'project' ? 'settings.local.json' : 'settings.json');
|
|
825
1020
|
historical.push(contributionComponent(entry.binding, { id: 'policy:claude-permissions', componentIds: [], kind: 'config-entry',
|
|
@@ -832,6 +1027,10 @@ export class PlatformRebuildSession {
|
|
|
832
1027
|
component.locator.command = cursorWorkspaceOpenCommand(entry.binding, ctx.platform);
|
|
833
1028
|
historical.push(component);
|
|
834
1029
|
}
|
|
1030
|
+
for (const slot of gapSupplementFiles(entry.binding, entry.layout, expected.unmet)) {
|
|
1031
|
+
if (!historical.some((component) => 'path' in component && component.path === slot.path))
|
|
1032
|
+
historical.push(slot);
|
|
1033
|
+
}
|
|
835
1034
|
const components = [...currentComponents, ...historical.filter((component) => !currentComponents.some((current) => 'path' in current && 'path' in component && current.path === component.path
|
|
836
1035
|
|| current.kind === 'shared-config' && component.kind === 'shared-config' && artifactValueDigest(current.locator) === artifactValueDigest(component.locator)))];
|
|
837
1036
|
for (const component of components)
|
|
@@ -848,18 +1047,30 @@ export class PlatformRebuildSession {
|
|
|
848
1047
|
}
|
|
849
1048
|
const inspected = await inspectOwnedComponents({ components, executor: this.ownership });
|
|
850
1049
|
const managedCommandReview = await captureManagedCommandReviewEvidence({ binding: entry.binding,
|
|
851
|
-
renderUnits: entry.layout.renderUnits,
|
|
1050
|
+
renderUnits: entry.layout.renderUnits, inactivePermissions: units.flatMap((unit) => unit.finalized.invocationPolicy.inactivePermissions), projections });
|
|
852
1051
|
const currentMutable = async (batch) => {
|
|
853
1052
|
const observation = await adapter.inspect(batch ? { ...ctx, ...batch } : ctx, entry.binding);
|
|
854
1053
|
return { observation, references: await sharedReferences(this.context, entry.binding, observation, entry.layout),
|
|
855
|
-
paths: await Promise.all(components.map(async (component) =>
|
|
856
|
-
|
|
1054
|
+
paths: await Promise.all(components.map(async (component) => {
|
|
1055
|
+
if ('path' in component)
|
|
1056
|
+
return pathEvidence(component.path);
|
|
1057
|
+
const ownership = await inspectOwnedComponents({ components: [component], executor: this.ownership });
|
|
1058
|
+
if (component.kind === 'shared-config' && component.locator.kind === 'host-permissions') {
|
|
1059
|
+
const locator = component.locator;
|
|
1060
|
+
const plannedWrite = projections.some((projection) => projection.supplements.some((item) => item.destination === locator.settingsPath));
|
|
1061
|
+
const fingerprint = await hostPermissionFingerprint(ctx, locator, plannedWrite);
|
|
1062
|
+
const last = this.permissionWrites.get(component.locator.settingsPath);
|
|
1063
|
+
return { ownership, fingerprint: last?.current === fingerprint ? last.previous : fingerprint };
|
|
1064
|
+
}
|
|
1065
|
+
return { ownership, contentDigest: await ownedContentDigest(component, ctx) };
|
|
857
1066
|
})) };
|
|
858
1067
|
};
|
|
859
|
-
const
|
|
1068
|
+
const shadowedUser = operation(input) === 'ensure' ? await grokUserBehindProject(ctx, entry.binding, entry.observation) : undefined;
|
|
1069
|
+
const fingerprintParts = async (discovery) => ({
|
|
1070
|
+
...(shadowedUser && { grokUserContent: await grokUserContentDigest(shadowedUser) }),
|
|
860
1071
|
managedCommandReview,
|
|
861
1072
|
source: removing ? null : await pathEvidence(input.plugin.rootDir),
|
|
862
|
-
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(
|
|
1073
|
+
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),
|
|
863
1074
|
sharedReferenceView: this.context.sharedReferenceView,
|
|
864
1075
|
layout: await getDeploymentLayout(ctx, entry.binding),
|
|
865
1076
|
config: await Promise.all(units.map((unit) => resolveArtifactRenderConfig({ ...sourceIdentity(input), pluginName: input.plugin.manifest.name,
|
|
@@ -878,11 +1089,14 @@ export class PlatformRebuildSession {
|
|
|
878
1089
|
if (initialReads?.[0].status === 'rejected')
|
|
879
1090
|
throw initialReads[0].reason;
|
|
880
1091
|
const initialParts = initialReads?.[0].status === 'fulfilled' ? initialReads[0].value : await fingerprintParts();
|
|
1092
|
+
if (shadowedUser && initialParts.grokUserContent) {
|
|
1093
|
+
shadowedUsers.set(entry.binding.id, { ...shadowedUser, contentDigest: initialParts.grokUserContent });
|
|
1094
|
+
}
|
|
881
1095
|
if (!removing && ordinaryEvidence && ordinaryEvidence.discovery !== artifactValueDigest(initialParts.discovery)) {
|
|
882
1096
|
throw new Error('operationPlanStale: client discovery changed after the ordinary observation.');
|
|
883
1097
|
}
|
|
884
1098
|
const initial = artifactValueDigest(initialParts);
|
|
885
|
-
const fingerprint = async (discovery
|
|
1099
|
+
const fingerprint = async (discovery) => artifactValueDigest(await fingerprintParts(discovery));
|
|
886
1100
|
if (initialReads?.[1].status === 'rejected')
|
|
887
1101
|
throw initialReads[1].reason;
|
|
888
1102
|
let mutableBaseline = initialReads?.[1].status === 'fulfilled' ? initialReads[1].value : await currentMutable();
|
|
@@ -890,20 +1104,223 @@ export class PlatformRebuildSession {
|
|
|
890
1104
|
if (ordinaryObservation !== undefined && ordinaryObservation !== artifactValueDigest(mutableBaseline.observation)) {
|
|
891
1105
|
throw new Error('operationPlanStale: deployment evidence changed after the ordinary observation.');
|
|
892
1106
|
}
|
|
893
|
-
const preparationObservation = entry.binding.route === 'antigravity-cli'
|
|
1107
|
+
const preparationObservation = entry.binding.route === 'antigravity-cli' || antigravityProject
|
|
894
1108
|
? mutableBaseline.observation : entry.observation;
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1109
|
+
const piInventoryKey = piProjectInventoryKey(entry.binding, entry.layout.activationPath);
|
|
1110
|
+
const matchesMutable = (current) => {
|
|
1111
|
+
const currentDigest = artifactValueDigest(current);
|
|
1112
|
+
if (currentDigest === artifactValueDigest(mutableBaseline))
|
|
1113
|
+
return true;
|
|
1114
|
+
const registered = piInventoryKey && this.piProjectRegisteredRoots.get(piInventoryKey);
|
|
1115
|
+
if (!registered || operation(input) !== 'ensure' || !piProjectEmptyDeliveryObserved(entry.binding, mutableBaseline.observation)
|
|
1116
|
+
|| current.observation.registration !== 'absent' || !piProjectListContainsOnly(current.observation, registered))
|
|
903
1117
|
return false;
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1118
|
+
// The first successful register in an empty Project can expose its
|
|
1119
|
+
// section. Compare every other fact with the original empty target.
|
|
1120
|
+
const { observation: before, ...baseline } = mutableBaseline;
|
|
1121
|
+
return currentDigest === artifactValueDigest({ ...baseline,
|
|
1122
|
+
observation: { ...before, registration: 'absent',
|
|
1123
|
+
diagnostics: before.diagnostics.filter(({ code }) => code !== 'piProjectRegistrationNotVisible') } });
|
|
1124
|
+
};
|
|
1125
|
+
const matchesAfterGrokPublications = async (current) => {
|
|
1126
|
+
const { binding } = entry;
|
|
1127
|
+
const scopeRoot = binding.route === 'grok-cli' ? entry.layout.activationPath
|
|
1128
|
+
: binding.route === 'grok-directory' && binding.scope.kind === 'project' ? binding.scope.projectRoot : null;
|
|
1129
|
+
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) : [];
|
|
1130
|
+
const retirements = binding.route === 'grok-directory' && operation(input) === 'ensure'
|
|
1131
|
+
? [...this.grokProjectRetirements.values()].filter((item) => item.projectRoot === scopeRoot) : [];
|
|
1132
|
+
const baselineDigest = artifactValueDigest(mutableBaseline);
|
|
1133
|
+
if (artifactValueDigest(current) === baselineDigest)
|
|
1134
|
+
return true;
|
|
1135
|
+
if (!scopeRoot || !publications.length && !retirements.length && !this.grokPermissionWrites.size)
|
|
1136
|
+
return false;
|
|
1137
|
+
const before = mutableBaseline.observation.prerequisites.nativeSources;
|
|
1138
|
+
const after = current.observation.prerequisites.nativeSources;
|
|
1139
|
+
const priorEvidence = before?.grokScopeEvidence;
|
|
1140
|
+
const scopeEvidence = after?.grokScopeEvidence;
|
|
1141
|
+
if (before?.observation !== 'complete' || after?.observation !== 'complete' || !scopeEvidence || !priorEvidence
|
|
1142
|
+
|| scopeEvidence.scopeDigest !== priorEvidence.scopeDigest)
|
|
1143
|
+
return false;
|
|
1144
|
+
let permissionChanged = false;
|
|
1145
|
+
if (scopeEvidence.permissionConfigs.length !== priorEvidence.permissionConfigs.length)
|
|
1146
|
+
return false;
|
|
1147
|
+
for (const [index, file] of scopeEvidence.permissionConfigs.entries()) {
|
|
1148
|
+
const prior = priorEvidence.permissionConfigs[index];
|
|
1149
|
+
if (prior.path !== file.path)
|
|
1150
|
+
return false;
|
|
1151
|
+
if (prior.digest === file.digest)
|
|
1152
|
+
continue;
|
|
1153
|
+
const write = this.grokPermissionWrites.get(file.path);
|
|
1154
|
+
if (!write || write.previous !== prior.digest || write.current !== file.digest)
|
|
1155
|
+
return false;
|
|
1156
|
+
permissionChanged = true;
|
|
1157
|
+
}
|
|
1158
|
+
if (!permissionChanged && scopeEvidence.permissionInventoryDigest !== priorEvidence.permissionInventoryDigest)
|
|
1159
|
+
return false;
|
|
1160
|
+
const paths = after.sources.map((source) => path.normalize(source.path));
|
|
1161
|
+
const priorPaths = before.sources.map((source) => path.normalize(source.path));
|
|
1162
|
+
if (new Set(paths).size !== paths.length || new Set(priorPaths).size !== priorPaths.length)
|
|
1163
|
+
return false;
|
|
1164
|
+
const sources = [...after.sources];
|
|
1165
|
+
const sourceDigests = [...scopeEvidence.sourceDigests];
|
|
1166
|
+
const addedSources = new Set();
|
|
1167
|
+
const publishedRoots = new Set();
|
|
1168
|
+
const orderChecks = [priorEvidence];
|
|
1169
|
+
const instructions = [...scopeEvidence.instructions];
|
|
1170
|
+
const retiredSources = new Set();
|
|
1171
|
+
let adjusted = permissionChanged;
|
|
1172
|
+
for (const retirement of retirements) {
|
|
1173
|
+
const { name, projectPackage, projectDigest, userPackage, userDigest, userSource, userContentDigest, userPhysicalKey } = retirement;
|
|
1174
|
+
if (!priorPaths.includes(projectPackage))
|
|
1175
|
+
continue;
|
|
1176
|
+
if (name === entry.layout.nativeIdentity.packageId || priorPaths.includes(userPackage) || paths.includes(projectPackage)
|
|
1177
|
+
|| grokSourceDigest(before, projectPackage, name, 'project') !== projectDigest
|
|
1178
|
+
|| grokSourceDigest(after, userPackage, name, 'user') !== userDigest
|
|
1179
|
+
|| await pathEvidence(projectPackage) !== null)
|
|
1180
|
+
return false;
|
|
1181
|
+
await assertSafeFileMutationPath({ filePath: path.join(userPackage, '.grok-plugin', 'plugin.json'),
|
|
1182
|
+
allowedRoot: path.dirname(path.dirname(userPackage)), label: 'Grok installed package' });
|
|
1183
|
+
const [installed, source, marker] = await Promise.all([readPlatformPackageContentDigest(userPackage), readPlatformPackageContentDigest(userSource),
|
|
1184
|
+
readSkillOwnerMarker({ skillRoot: userSource, allowedRoot: path.dirname(userSource) })]);
|
|
1185
|
+
if (installed !== userContentDigest || source !== userContentDigest || marker?.physicalKey !== userPhysicalKey)
|
|
1186
|
+
return false;
|
|
1187
|
+
// The Project copy hid this exact User copy. Both may leave their
|
|
1188
|
+
// old positions, and the remaining sources and components keep theirs.
|
|
1189
|
+
retiredSources.add(projectPackage);
|
|
1190
|
+
addedSources.add(userPackage);
|
|
1191
|
+
publishedRoots.add(projectPackage);
|
|
1192
|
+
publishedRoots.add(userPackage);
|
|
1193
|
+
adjusted = true;
|
|
1194
|
+
}
|
|
1195
|
+
for (const { owner, scopeRoot: publishedRoot, installedRoot, nativeDigest, contentDigest, priorNativeDigest, orderAfter, shadowedUser } of publications) {
|
|
1196
|
+
ctx.signal?.throwIfAborted();
|
|
1197
|
+
if (owner.kind === 'owned-directory') {
|
|
1198
|
+
const root = installedRoot ?? owner.path;
|
|
1199
|
+
const index = paths.indexOf(root);
|
|
1200
|
+
if (scopeEvidence.sourceDigests[index] !== nativeDigest || after.sources[index]?.name === entry.layout.nativeIdentity.packageId)
|
|
1201
|
+
return false;
|
|
1202
|
+
const priorIndex = priorPaths.indexOf(root);
|
|
1203
|
+
const priorDigest = priorEvidence.sourceDigests[priorIndex];
|
|
1204
|
+
if (shadowedUser) {
|
|
1205
|
+
const hidden = shadowedUser.installedRoot;
|
|
1206
|
+
if (paths.includes(hidden) || await grokUserContentDigest(shadowedUser) !== shadowedUser.contentDigest)
|
|
1207
|
+
return false;
|
|
1208
|
+
if (priorIndex < 0) {
|
|
1209
|
+
if (grokSourceDigest(before, hidden, owner.identity.plugin, 'user') !== shadowedUser.nativeDigest)
|
|
1210
|
+
return false;
|
|
1211
|
+
retiredSources.add(hidden);
|
|
1212
|
+
publishedRoots.add(hidden);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
if (priorDigest !== nativeDigest) {
|
|
1216
|
+
if (priorDigest !== priorNativeDigest)
|
|
1217
|
+
return false;
|
|
1218
|
+
publishedRoots.add(root);
|
|
1219
|
+
if (orderAfter)
|
|
1220
|
+
orderChecks.push(orderAfter);
|
|
1221
|
+
// Restore the frozen source at its current position. Moving a
|
|
1222
|
+
// source or changing any other source still invalidates the plan.
|
|
1223
|
+
if (priorIndex < 0)
|
|
1224
|
+
addedSources.add(root);
|
|
1225
|
+
else {
|
|
1226
|
+
sources[index] = before.sources[priorIndex];
|
|
1227
|
+
sourceDigests[index] = priorDigest;
|
|
1228
|
+
}
|
|
1229
|
+
adjusted = true;
|
|
1230
|
+
}
|
|
1231
|
+
const marker = await readSkillOwnerMarker({ skillRoot: owner.path, allowedRoot: owner.allowedRoot,
|
|
1232
|
+
expectedIdentity: owner.identity }).catch(() => null);
|
|
1233
|
+
const observedContent = marker?.nativeProjection?.contentDigest === contentDigest
|
|
1234
|
+
? await readPlatformPackageContentDigest(owner.path).catch(() => undefined) : undefined;
|
|
1235
|
+
if (observedContent !== contentDigest)
|
|
1236
|
+
return false;
|
|
1237
|
+
if (installedRoot) {
|
|
1238
|
+
try {
|
|
1239
|
+
await assertSafeFileMutationPath({ filePath: path.join(installedRoot, '.grok-plugin', 'plugin.json'),
|
|
1240
|
+
allowedRoot: publishedRoot, label: 'Grok installed package' });
|
|
1241
|
+
if (await readPlatformPackageContentDigest(installedRoot) !== contentDigest)
|
|
1242
|
+
return false;
|
|
1243
|
+
}
|
|
1244
|
+
catch {
|
|
1245
|
+
ctx.signal?.throwIfAborted();
|
|
1246
|
+
return false;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
else {
|
|
1251
|
+
const matches = instructions.filter((row) => row.rulePath === owner.path);
|
|
1252
|
+
if (matches.length !== 1 || matches[0].digest !== nativeDigest)
|
|
1253
|
+
return false;
|
|
1254
|
+
const index = instructions.indexOf(matches[0]);
|
|
1255
|
+
const prior = priorEvidence.instructions.find((row) => row.rulePath === owner.path);
|
|
1256
|
+
if (prior?.digest !== nativeDigest) {
|
|
1257
|
+
if (prior?.digest !== priorNativeDigest)
|
|
1258
|
+
return false;
|
|
1259
|
+
instructions.splice(index, 1, ...(prior ? [prior] : []));
|
|
1260
|
+
adjusted = true;
|
|
1261
|
+
}
|
|
1262
|
+
// The written hash includes the exact owner header. Grok's size
|
|
1263
|
+
// and token count alone cannot detect a same-length external edit.
|
|
1264
|
+
try {
|
|
1265
|
+
await assertSafeFileMutationPath({ filePath: owner.path, allowedRoot: publishedRoot, label: 'Grok rule' });
|
|
1266
|
+
const bytes = await fs.readFile(owner.path);
|
|
1267
|
+
if (crypto.createHash('sha256').update(bytes).digest('hex') !== contentDigest)
|
|
1268
|
+
return false;
|
|
1269
|
+
}
|
|
1270
|
+
catch {
|
|
1271
|
+
ctx.signal?.throwIfAborted();
|
|
1272
|
+
return false;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
ctx.signal?.throwIfAborted();
|
|
1277
|
+
if (!adjusted)
|
|
1278
|
+
return artifactValueDigest(current) === baselineDigest;
|
|
1279
|
+
for (const { sourceOrderAfter } of publications) {
|
|
1280
|
+
if (!sourceOrderAfter)
|
|
1281
|
+
continue;
|
|
1282
|
+
// Sources that remained visible since the Project publication keep their receipt order.
|
|
1283
|
+
if (artifactValueDigest(sourceOrderAfter.filter((root) => paths.includes(root)))
|
|
1284
|
+
!== artifactValueDigest(paths.filter((root) => sourceOrderAfter.includes(root))))
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
// The reviewed order anchors surviving rows. Each publication's receipt
|
|
1288
|
+
// also anchors its new rows against later cross-package moves.
|
|
1289
|
+
for (const previous of orderChecks) {
|
|
1290
|
+
if (!matchesGrokComponentOrder(previous.hookOrder, scopeEvidence.hookOrder, publishedRoots)
|
|
1291
|
+
|| !scopeEvidence.resourceOrder.every((order, index) => matchesGrokComponentOrder(previous.resourceOrder[index], order, publishedRoots)))
|
|
1292
|
+
return false;
|
|
1293
|
+
}
|
|
1294
|
+
const normalizedSources = { ...after, sources: sources.filter((_, index) => !addedSources.has(paths[index])),
|
|
1295
|
+
configurationEvidence: before.configurationEvidence, grokScopeEvidence: { ...scopeEvidence, instructions, permissionConfigs: priorEvidence.permissionConfigs,
|
|
1296
|
+
permissionInventoryDigest: priorEvidence.permissionInventoryDigest, hookOrder: priorEvidence.hookOrder, resourceOrder: priorEvidence.resourceOrder,
|
|
1297
|
+
sourceDigests: sourceDigests.filter((_, index) => !addedSources.has(paths[index])) } };
|
|
1298
|
+
const observation = { ...current.observation, prerequisites: { ...current.observation.prerequisites, nativeSources: normalizedSources } };
|
|
1299
|
+
const normalizedBefore = { ...before, sources: before.sources.filter((_, index) => !retiredSources.has(priorPaths[index])),
|
|
1300
|
+
grokScopeEvidence: { ...priorEvidence, sourceDigests: priorEvidence.sourceDigests.filter((_, index) => !retiredSources.has(priorPaths[index])) } };
|
|
1301
|
+
const baselineObservation = { ...mutableBaseline.observation, prerequisites: { ...mutableBaseline.observation.prerequisites,
|
|
1302
|
+
nativeSources: normalizedBefore } };
|
|
1303
|
+
return artifactValueDigest({ ...current, observation }) === artifactValueDigest({ ...mutableBaseline, observation: baselineObservation });
|
|
1304
|
+
};
|
|
1305
|
+
const check = async (discovery, batch) => {
|
|
1306
|
+
const reads = parallelNativeReads ? await Promise.allSettled([fingerprintParts(discovery), currentMutable(batch)]) : null;
|
|
1307
|
+
if (reads?.[0].status === 'rejected')
|
|
1308
|
+
throw reads[0].reason;
|
|
1309
|
+
const parts = reads?.[0].status === 'fulfilled' ? reads[0].value : await fingerprintParts(discovery);
|
|
1310
|
+
if (artifactValueDigest(parts) !== initial) {
|
|
1311
|
+
return artifactValueDigest(parts.discovery) !== artifactValueDigest(initialParts.discovery)
|
|
1312
|
+
? 'clientDiscoveryChanged' : 'deploymentInputsChanged';
|
|
1313
|
+
}
|
|
1314
|
+
if (reads?.[1].status === 'rejected')
|
|
1315
|
+
throw reads[1].reason;
|
|
1316
|
+
const current = reads?.[1].status === 'fulfilled' ? reads[1].value : await currentMutable(batch);
|
|
1317
|
+
if (parallelNativeReads ? matchesMutable(current) : await matchesAfterGrokPublications(current))
|
|
1318
|
+
return true;
|
|
1319
|
+
if (current.references !== mutableBaseline.references)
|
|
1320
|
+
return 'deploymentReferencesChanged';
|
|
1321
|
+
if (artifactValueDigest(current.paths) !== artifactValueDigest(mutableBaseline.paths))
|
|
1322
|
+
return 'deploymentPathsChanged';
|
|
1323
|
+
return 'deploymentObservationChanged';
|
|
907
1324
|
};
|
|
908
1325
|
checks.set(entry.binding.id, (batch) => check(undefined, batch));
|
|
909
1326
|
if (resolution.bindings.length === 1 && entry.binding.route === 'pi-package') {
|
|
@@ -913,7 +1330,7 @@ export class PlatformRebuildSession {
|
|
|
913
1330
|
marketplaceRoot: entry.layout.marketplaceRoot, sourceId: entry.binding.plugin.sourceId,
|
|
914
1331
|
sourceIdentity: entry.binding.plugin.sourceIdentity,
|
|
915
1332
|
assertStable: async () => {
|
|
916
|
-
if (
|
|
1333
|
+
if (await checks.get(entry.binding.id)() !== true)
|
|
917
1334
|
throw new Error('operationPlanStale: deployment evidence changed before source registration.');
|
|
918
1335
|
},
|
|
919
1336
|
acceptMarketplaceRegistration: async () => {
|
|
@@ -968,12 +1385,21 @@ export class PlatformRebuildSession {
|
|
|
968
1385
|
} });
|
|
969
1386
|
const evidence = { fingerprint: initial, managedCommandReview, layout: entry.layout, renderUnits: entry.layout.renderUnits,
|
|
970
1387
|
ownership: await Promise.all(inspected.components.map(async ({ component, state }) => ({ component, state,
|
|
971
|
-
contentDigest: state === 'present' ? await ownedContentDigest(component) : undefined,
|
|
1388
|
+
contentDigest: state === 'present' ? await ownedContentDigest(component, ctx) : undefined,
|
|
972
1389
|
physicalKey: component.identity.physicalKey ?? entry.binding.physicalKey }))),
|
|
973
1390
|
sharedReferences: await sharedReferences(this.context, entry.binding, preparationObservation, entry.layout),
|
|
974
1391
|
nativeIdentity: preparationObservation.nativeIdentity ?? entry.layout.nativeIdentity,
|
|
975
1392
|
contentMatches: projections.some((projection) => projection.bundle !== null)
|
|
1393
|
+
&& (!antigravityProject || preparationObservation.ownership === 'aw')
|
|
976
1394
|
&& await readPlatformPackageContentDigest(entry.layout.packageRoot) === projections.find((projection) => projection.bundle !== null)?.bundle?.contentDigest };
|
|
1395
|
+
if (removing && isPermissionHost(entry.binding.platform) && (entry.binding.platform === 'opencode' || hostPolicyPath)) {
|
|
1396
|
+
const permission = historical.find((component) => component.kind === 'shared-config' && component.locator.kind === 'host-permissions');
|
|
1397
|
+
const settingsPath = permission?.kind === 'shared-config' && permission.locator.kind === 'host-permissions'
|
|
1398
|
+
? permission.locator.settingsPath : undefined;
|
|
1399
|
+
const notice = await missingPermissionOwnershipWarning(ctx, entry.binding.plugin.pluginId, entry.binding.scope.kind, settingsPath ?? hostPolicyPath, entry.binding.platform, grokProjectBlocked);
|
|
1400
|
+
if (notice)
|
|
1401
|
+
evidence.permissionOwnershipWarning = notice;
|
|
1402
|
+
}
|
|
977
1403
|
if (entry.binding.platform === 'codex') {
|
|
978
1404
|
const hostEntry = entry.binding.consumers.find((consumer) => consumer.entry?.kind === 'cli'
|
|
979
1405
|
|| removing && consumer.entry?.kind === 'directory')?.entry;
|
|
@@ -999,22 +1425,47 @@ export class PlatformRebuildSession {
|
|
|
999
1425
|
evidence.userActivationEnabled = !['remove', 'cleanup'].includes(operation(plannedUser));
|
|
1000
1426
|
}
|
|
1001
1427
|
}
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1428
|
+
const priorPackage = inspected.components.find((slot) => 'path' in slot.component
|
|
1429
|
+
&& slot.component.path === entry.layout.packageRoot && ['present', 'partial'].includes(slot.state))?.component;
|
|
1430
|
+
if (!removing && expected.unmet.length && priorPackage?.kind === 'owned-directory') {
|
|
1431
|
+
const complete = hasCompleteDeliveryDeclaration(expected);
|
|
1432
|
+
const old = await readSkillOwnerMarker({ skillRoot: priorPackage.path, allowedRoot: priorPackage.allowedRoot,
|
|
1433
|
+
expectedIdentity: priorPackage.identity }).catch(() => null);
|
|
1434
|
+
const next = new Set(projections.filter((item) => item.bundle).flatMap((item) => item.components.map(({ id }) => id)));
|
|
1435
|
+
const dropsPriorComponent = !old?.nativeProjection || old.nativeProjection.components.some(({ id }) => !next.has(id));
|
|
1436
|
+
const currentDigest = evidence.ownership.find((slot) => slot.component === priorPackage)?.contentDigest;
|
|
1437
|
+
// The marker identifies the directory. Only its recorded digest proves
|
|
1438
|
+
// that replacing or withdrawing the whole tree would discard exclusively AW bytes.
|
|
1439
|
+
const previousContentsVerified = !!old?.nativeProjection && old.nativeProjection.contentDigest === currentDigest;
|
|
1440
|
+
const hasNativeCopy = ['grok-cli', 'antigravity-cli'].includes(entry.binding.route) && preparationObservation.registration === 'present';
|
|
1441
|
+
const previousCopyUnconfirmed = hasNativeCopy && (!old?.nativeProjection
|
|
1442
|
+
|| old.nativeProjection.contentDigest !== preparationObservation.nativePackageContentDigest);
|
|
1443
|
+
evidence.retainPackage = expected.unmet.some((gap) => !isDeliveryCapabilityGap(gap) && gap.reasonCode !== COMMAND_ROUTE_UNREACHABLE) || previousCopyUnconfirmed
|
|
1444
|
+
|| !evidence.contentMatches && (!previousContentsVerified || dropsPriorComponent
|
|
1445
|
+
&& (!complete || evidence.sharedReferences !== 'none' || preparationObservation.ownership !== 'aw'));
|
|
1446
|
+
}
|
|
1004
1447
|
if (!removing) {
|
|
1005
|
-
const inputEvidence = await createPlatformInputEvidence({ plugin: input.plugin, binding: entry.binding, units: units.map((unit) => unit.evidenceInput) });
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1448
|
+
const inputEvidence = await createPlatformInputEvidence({ plugin: input.plugin, commandRoutes: input.commandRecord?.routes, binding: entry.binding, units: units.map((unit) => unit.evidenceInput) });
|
|
1449
|
+
const packageComponents = projections.find((projection) => projection.bundle)?.components;
|
|
1450
|
+
inputDigests.set(entry.binding.id, platformPackageInputDigest(inputEvidence, packageComponents));
|
|
1451
|
+
if (expected.unmet.every(isDeliveryCapabilityGap)) {
|
|
1452
|
+
const permissionNotices = platformPermissionNotices(projections.flatMap(({ diagnostics }) => diagnostics)
|
|
1453
|
+
.filter((notice) => !notice.subject?.pluginId || notice.subject.pluginId === entry.binding.plugin.pluginId));
|
|
1454
|
+
const noticeFields = permissionNotices.length ? { permissionNotices } : {};
|
|
1455
|
+
if (expected.unmet.length || expected.components.length && permissionNotices.length)
|
|
1456
|
+
gapStates.set(entry.binding.id, { ...inputEvidence,
|
|
1457
|
+
kind: 'aw-platform-empty-state', result: 'capability-gaps', gaps: expected.unmet,
|
|
1458
|
+
installedComponentIds: expected.components.map(({ id }) => id), ...noticeFields });
|
|
1459
|
+
if (expected.components.length === 0 && expected.unmet.length === 0) {
|
|
1460
|
+
emptyStates.set(entry.binding.id, { ...inputEvidence, kind: 'aw-platform-empty-state', result: 'intentional-empty', ...noticeFields });
|
|
1010
1461
|
}
|
|
1011
1462
|
else if (entry.layout.supplementRoot && input.plugin.manifest.artifacts) {
|
|
1012
1463
|
const supplement = inputEvidence.units.find((unit) => unit.output === 'supplement');
|
|
1013
1464
|
if (supplement) {
|
|
1014
1465
|
supplementInputDigests.set(entry.binding.id, supplement.inputDigest);
|
|
1015
|
-
if (
|
|
1016
|
-
emptyStates.set(entry.binding.id, { ...inputEvidence, kind: 'aw-platform-empty-state',
|
|
1017
|
-
|
|
1466
|
+
if (!expected.unmet.length && !projections.some((projection) => projection.bundle)) {
|
|
1467
|
+
emptyStates.set(entry.binding.id, { ...inputEvidence, kind: 'aw-platform-empty-state',
|
|
1468
|
+
result: 'intentional-empty-package', installedComponentIds: expected.components.map(({ id }) => id).sort(), ...noticeFields });
|
|
1018
1469
|
}
|
|
1019
1470
|
}
|
|
1020
1471
|
}
|
|
@@ -1035,10 +1486,9 @@ export class PlatformRebuildSession {
|
|
|
1035
1486
|
}
|
|
1036
1487
|
target.ownedComponents = plans.flatMap((plan) => plan.evidence.ownership.map((item) => item.component));
|
|
1037
1488
|
target.desiredOwnedComponents = target.ownedComponents;
|
|
1038
|
-
let frozenNativeTools;
|
|
1039
1489
|
const verifyChecks = async (selected, batch) => {
|
|
1040
1490
|
for (const check of selected)
|
|
1041
|
-
if (
|
|
1491
|
+
if (await check(batch) !== true)
|
|
1042
1492
|
throw new Error('operationPlanStale: deployment evidence changed.');
|
|
1043
1493
|
for (const plan of plans)
|
|
1044
1494
|
if (!await this.verifyMarketplace(plan))
|
|
@@ -1048,7 +1498,7 @@ export class PlatformRebuildSession {
|
|
|
1048
1498
|
const canVerifyAtExecution = () => {
|
|
1049
1499
|
const prepared = deployments[0];
|
|
1050
1500
|
if (!prepared || deployments.length !== 1 || plans.length !== 1 || plans[0] !== prepared.plan || blockedReceipts.length
|
|
1051
|
-
|| target.operationActions === undefined || target.operationActions.some((action) => action.kind === 'runPreApply' || action.kind === 'syncManagedCommandPackage'))
|
|
1501
|
+
|| target.operationActions === undefined || target.operationActions.some((action) => action.kind === 'runPreApply' || action.kind === 'syncManagedCommandPackage' || action.kind === 'removeManagedCommandPackage'))
|
|
1052
1502
|
return false;
|
|
1053
1503
|
const { plan, driverState } = prepared;
|
|
1054
1504
|
const hiddenEmptyPiProject = piProjectRegistrationHidden(plan.binding, driverState.before)
|
|
@@ -1057,7 +1507,7 @@ export class PlatformRebuildSession {
|
|
|
1057
1507
|
&& plan.effects.every((effect) => ['publish-package', 'register'].includes(effect.kind));
|
|
1058
1508
|
const checkedBatch = this.context.batchInstallPlatform === plan.binding.platform && plan.binding.platform !== 'codex';
|
|
1059
1509
|
return plan.operation === 'ensure' && (checkedBatch || ['copilot-marketplace', 'pi-package'].includes(plan.binding.route))
|
|
1060
|
-
&& plan.binding.platform === target.identity.platform && plan.expected.components.length > 0 &&
|
|
1510
|
+
&& plan.binding.platform === target.identity.platform && plan.expected.components.length > 0 && plan.expected.unmet.every(isDeliveryCapabilityGap)
|
|
1061
1511
|
&& driverState.before.package !== 'unknown' && (driverState.before.registration !== 'unknown' || hiddenEmptyPiProject)
|
|
1062
1512
|
&& ['absent', 'aw', 'shared'].includes(driverState.before.ownership)
|
|
1063
1513
|
&& plan.effects.every((effect) => ['publish-package', 'register', 'refresh', 'activate'].includes(effect.kind));
|
|
@@ -1084,31 +1534,7 @@ export class PlatformRebuildSession {
|
|
|
1084
1534
|
},
|
|
1085
1535
|
} : undefined;
|
|
1086
1536
|
target.platformDeployment = { deployments, plans, blockedReceipts, cleanupResults, privatePackage,
|
|
1087
|
-
writesManagedCommands: [...preparedUnits.values()].some((unit) => unit.finalized.commandCandidates.length > 0)
|
|
1088
|
-
|| [...priorProducers.values()].some((producers) => producers.length > 0),
|
|
1089
1537
|
canVerifyAtExecution,
|
|
1090
|
-
captureNativeToolChanges: async () => {
|
|
1091
|
-
const signature = artifactValueDigest(deployments.map(({ plan }) => ({ bindingId: plan.binding.id,
|
|
1092
|
-
retainPackage: plan.evidence.retainPackage, effects: plan.effects })));
|
|
1093
|
-
if (frozenNativeTools?.signature === signature)
|
|
1094
|
-
return frozenNativeTools.changes;
|
|
1095
|
-
const changes = [];
|
|
1096
|
-
for (const { plan } of deployments) {
|
|
1097
|
-
const root = plan.evidence.layout.packageRoot;
|
|
1098
|
-
const publishes = plan.effects.some((effect) => effect.kind === 'publish-package' && effect.destination === root);
|
|
1099
|
-
const removes = plan.effects.some((effect) => effect.kind === 'remove-owned' && effect.destination === root);
|
|
1100
|
-
if (plan.evidence.retainPackage || !publishes && !removes)
|
|
1101
|
-
continue;
|
|
1102
|
-
const next = publishes ? [...preparedUnits.values()].flatMap((unit) => unit.finalized.commandCandidates)
|
|
1103
|
-
.filter((candidate) => candidate.producer.kind !== 'package' && candidate.producer.placementKey === plan.binding.physicalKey) : [];
|
|
1104
|
-
changes.push(...await captureNativeToolChanges({ actions: [],
|
|
1105
|
-
producers: [...priorProducers.get(plan.binding.id) ?? [], ...next.map((candidate) => candidate.producer)],
|
|
1106
|
-
nextProducers: next, removed: removes, env: this.context.env,
|
|
1107
|
-
resourceRoots: [...priorResourceRoots.get(plan.binding.id) ?? [], ...(removes ? [root] : [])] }));
|
|
1108
|
-
}
|
|
1109
|
-
frozenNativeTools = { signature, changes };
|
|
1110
|
-
return changes;
|
|
1111
|
-
},
|
|
1112
1538
|
verify,
|
|
1113
1539
|
postcheck: async (receipts, options) => {
|
|
1114
1540
|
let incomplete = false;
|
|
@@ -1146,6 +1572,11 @@ export class PlatformRebuildSession {
|
|
|
1146
1572
|
: await readPlatformPackageContentDigest(plan.evidence.layout.packageRoot) !== bundle.contentDigest));
|
|
1147
1573
|
const delivered = new Set(after.components.filter((component) => component.presence === 'present' && !component.reasonCodes.length)
|
|
1148
1574
|
.map((component) => component.id));
|
|
1575
|
+
const roleIds = plan.expected.components.filter((component) => component.kind === 'agent' && delivered.has(component.id)
|
|
1576
|
+
&& packageIds.has(component.id) && !packageIncomplete && !plan.evidence.retainPackage).map(({ id }) => id);
|
|
1577
|
+
const roleDiagnostic = piAgentConsumerDiagnostic(plan.binding, after, roleIds);
|
|
1578
|
+
if (roleDiagnostic)
|
|
1579
|
+
receipt.diagnostics.push(roleDiagnostic);
|
|
1149
1580
|
const gaps = plan.expected.components.filter((component) => packageIncomplete && packageIds.has(component.id) || !delivered.has(component.id));
|
|
1150
1581
|
if (bundle && !packageIncomplete && !plan.evidence.retainPackage) {
|
|
1151
1582
|
for (const unitId of plan.binding.renderUnitIds) {
|
|
@@ -1164,12 +1595,19 @@ export class PlatformRebuildSession {
|
|
|
1164
1595
|
&& unit.unit.consumers.every(({ product, availability, entry }) => product === 'app'
|
|
1165
1596
|
|| product === 'cli' && availability === 'available' && entry?.kind === 'cli')
|
|
1166
1597
|
? adapter.capabilities({ ...capabilityInput, renderUnit: { ...unit.unit, consumers: cliReaders } }) : undefined;
|
|
1598
|
+
const antigravityReaders = plan.binding.platform === 'antigravity'
|
|
1599
|
+
? unit.unit.consumers.flatMap((reader) => reader.availability === 'available' && reader.product !== 'generic'
|
|
1600
|
+
? [{ id: reader.id, product: reader.product,
|
|
1601
|
+
unsupported: getAntigravityUnsupportedSkillControls(capabilityInput.profile, plan.binding.scope.kind, reader) }]
|
|
1602
|
+
: []) : [];
|
|
1167
1603
|
for (const skill of unit.finalized.skills) {
|
|
1168
1604
|
if (!packageIds.has(skill.componentId) || !delivered.has(skill.componentId))
|
|
1169
1605
|
continue;
|
|
1170
1606
|
const component = unit.prepared.expected.components.find((item) => item.id === skill.componentId);
|
|
1171
1607
|
const requested = getComponentFeatureRequirements(component, { skillText: skill.tree.files['SKILL.md'].toString('utf8') });
|
|
1172
|
-
const warning = skillInvocationWarning(component.name, requested, { pluginId: plan.binding.plugin.pluginId, target: plan.binding.platform, scope: plan.binding.scope.kind }, capabilities, codexCliCapabilities)
|
|
1608
|
+
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,
|
|
1609
|
+
observed: after.skillInvocationPolicies?.find(({ componentId, productId }) => componentId === component.id
|
|
1610
|
+
&& productId === reader.id)?.features })));
|
|
1173
1611
|
if (warning)
|
|
1174
1612
|
receipt.diagnostics.push(warning);
|
|
1175
1613
|
}
|
|
@@ -1179,14 +1617,19 @@ export class PlatformRebuildSession {
|
|
|
1179
1617
|
continue;
|
|
1180
1618
|
const inputDigest = supplementInputDigests.get(plan.binding.id);
|
|
1181
1619
|
if (inputDigest && [...supplementIds].every((id) => delivered.has(id))
|
|
1182
|
-
&&
|
|
1620
|
+
&& receipt.unmet.every(isDeliveryCapabilityGap) && !receipt.diagnostics.some((diagnostic) => diagnostic.severity === 'error')) {
|
|
1183
1621
|
try {
|
|
1184
1622
|
await writePlatformSupplementState(ctx, plan.binding, inputDigest, supplementFiles.map((file) => ({
|
|
1185
1623
|
id: file.id, fileName: path.basename(file.destination), contentDigest: file.contentDigest,
|
|
1186
1624
|
})));
|
|
1187
1625
|
const emptyPackage = emptyStates.get(plan.binding.id);
|
|
1188
|
-
if (!gaps.length && emptyPackage
|
|
1626
|
+
if (!gaps.length && emptyPackage?.result === 'intentional-empty-package'
|
|
1627
|
+
&& supplementIds.size === emptyPackage.installedComponentIds.length
|
|
1628
|
+
&& emptyPackage.installedComponentIds.every((id) => supplementIds.has(id))
|
|
1629
|
+
&& after.package === 'absent' && ['absent', 'not-applicable'].includes(after.registration)) {
|
|
1630
|
+
// The package absence and permission notices describe the same binding.
|
|
1189
1631
|
await writePlatformEmptyState({ state: emptyPackage, env: this.context.env });
|
|
1632
|
+
continue;
|
|
1190
1633
|
}
|
|
1191
1634
|
}
|
|
1192
1635
|
catch {
|
|
@@ -1196,8 +1639,19 @@ export class PlatformRebuildSession {
|
|
|
1196
1639
|
subject: { target: plan.binding.platform, pluginId: plan.binding.plugin.pluginId, scope: plan.binding.scope.kind } });
|
|
1197
1640
|
}
|
|
1198
1641
|
}
|
|
1199
|
-
if (!gaps.length)
|
|
1642
|
+
if (!gaps.length) {
|
|
1643
|
+
const gapState = gapStates.get(plan.binding.id);
|
|
1644
|
+
if (gapState && !receipt.diagnostics.some((entry) => entry.severity === 'error')) {
|
|
1645
|
+
if (gapState.result === 'capability-gaps' && !gapState.gaps.length) {
|
|
1646
|
+
// A notice alone is optional status evidence. Failure to retain it does not undo verified delivery.
|
|
1647
|
+
await writePlatformEmptyState({ state: gapState, env: this.context.env }).catch(() => ctx.signal?.throwIfAborted());
|
|
1648
|
+
}
|
|
1649
|
+
else {
|
|
1650
|
+
await writePlatformEmptyState({ state: gapState, env: this.context.env });
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1200
1653
|
continue;
|
|
1654
|
+
}
|
|
1201
1655
|
incomplete = true;
|
|
1202
1656
|
const code = plan.binding.route === 'grok-directory' && requiredActivation === 'blocked' ? 'grokProjectAuthorizationDenied'
|
|
1203
1657
|
: plan.binding.route === 'codex-marketplace' && requireIndependentActivation && after.scopeActivation === 'unknown'
|
|
@@ -1232,10 +1686,16 @@ export class PlatformRebuildSession {
|
|
|
1232
1686
|
cleanupResults.length = 0;
|
|
1233
1687
|
const receipts = [...blockedReceipts];
|
|
1234
1688
|
for (const prepared of deployments) {
|
|
1689
|
+
const batch = prepared.plan.evidence.permissionBatch;
|
|
1690
|
+
let relatedProjectBatch;
|
|
1691
|
+
if (batch && prepared.plan.binding.platform === 'opencode' && prepared.plan.binding.scope.kind === 'user') {
|
|
1692
|
+
const key = identityDigest({ owners: batch.owners, projects: batch.relatedProjects });
|
|
1693
|
+
relatedProjectBatch = this.openCodeProjectBatches.get(key) ?? { writes: new Map(), pending: new Map() };
|
|
1694
|
+
this.openCodeProjectBatches.set(key, relatedProjectBatch);
|
|
1695
|
+
}
|
|
1235
1696
|
const supplementFiles = componentSupplementFiles(prepared.plan);
|
|
1236
1697
|
const writtenFiles = new Map();
|
|
1237
|
-
const
|
|
1238
|
-
.some((resolution) => resolution.state === 'failed' || resolution.state === 'unmet'));
|
|
1698
|
+
const appliedPermissionNotices = [];
|
|
1239
1699
|
let receipt;
|
|
1240
1700
|
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
|
|
1241
1701
|
&& check.sourceId === prepared.plan.binding.plugin.sourceId && check.sourceIdentity === prepared.plan.binding.plugin.sourceIdentity) : [];
|
|
@@ -1258,7 +1718,12 @@ export class PlatformRebuildSession {
|
|
|
1258
1718
|
verifyEvidence: async (plan) => {
|
|
1259
1719
|
const verified = verifiedPlan === plan;
|
|
1260
1720
|
verifiedPlan = undefined;
|
|
1261
|
-
|
|
1721
|
+
if (verified)
|
|
1722
|
+
return true;
|
|
1723
|
+
const evidence = await checks.get(plan.binding.id)();
|
|
1724
|
+
if (evidence !== true)
|
|
1725
|
+
return evidence;
|
|
1726
|
+
return await this.verifyMarketplace(plan) || 'marketplaceChanged';
|
|
1262
1727
|
},
|
|
1263
1728
|
publishPackage: async (_binding, bundle, _destination, component) => {
|
|
1264
1729
|
if (!('path' in component) || component.path !== _destination)
|
|
@@ -1269,7 +1734,8 @@ export class PlatformRebuildSession {
|
|
|
1269
1734
|
publication = publishDirectory(bundle.stagingRoot, component, {
|
|
1270
1735
|
components: prepared.plan.projections.filter((projection) => projection.bundle !== null).flatMap((projection) => projection.components),
|
|
1271
1736
|
inputDigest: inputDigests.get(prepared.plan.binding.id), contentDigest: bundle.contentDigest,
|
|
1272
|
-
|
|
1737
|
+
...(bundle.piExtensionDigest ? { piExtensionDigest: bundle.piExtensionDigest } : {}),
|
|
1738
|
+
preparation: prepared.plan.expected.unmet.some((gap) => !isDeliveryCapabilityGap(gap)) ? 'partial' : 'complete',
|
|
1273
1739
|
physicalIdentity: (await getDeploymentLayout(ctx, prepared.plan.binding)).physicalIdentity,
|
|
1274
1740
|
}, stagedPackage);
|
|
1275
1741
|
this.published.set(prepared.plan.binding.physicalKey, publication);
|
|
@@ -1296,26 +1762,69 @@ export class PlatformRebuildSession {
|
|
|
1296
1762
|
await atomicReplaceSafeFile({ filePath: component.locator.hooksPath, allowedRoot: path.dirname(component.locator.hooksPath), label: 'Cursor workspaceOpen',
|
|
1297
1763
|
content: `${JSON.stringify({ ...value, hooks: { ...hooks, workspaceOpen: [...entries.filter((item) => cursorHookEntryCommand(item) !== locator.command), ...desired] } }, null, 2)}\n` });
|
|
1298
1764
|
}
|
|
1765
|
+
else if (component.kind === 'shared-config' && component.locator.kind === 'host-permissions') {
|
|
1766
|
+
const locator = component.locator;
|
|
1767
|
+
const changed = await updateHostPermissions(ctx, locator, await jsonObject(contribution.stagingPath), (previous, current, target = locator.settingsPath, host) => this.recordPermissionWrite(target, previous, current, locator.platform === 'grok' ? host : undefined), batch, (notices) => appliedPermissionNotices.push(...notices), undefined, relatedProjectBatch);
|
|
1768
|
+
return { mutation: changed ? 'confirmed' : 'none', changed };
|
|
1769
|
+
}
|
|
1299
1770
|
else if (component.kind === 'shared-config' && component.locator.kind === 'claude-permissions') {
|
|
1300
1771
|
const content = await jsonObject(contribution.stagingPath);
|
|
1301
1772
|
if (content.kind !== 'claude-permissions')
|
|
1302
1773
|
throw new Error('platformContributionUnsupported');
|
|
1303
|
-
await applyPlannedOperationAction({ kind: 'updateSharedConfig', pluginId: prepared.plan.binding.plugin.pluginId,
|
|
1774
|
+
const added = await applyPlannedOperationAction({ kind: 'updateSharedConfig', pluginId: prepared.plan.binding.plugin.pluginId,
|
|
1304
1775
|
platform: 'claude', scope: prepared.plan.binding.scope.kind, owner: component.identity, locator: component.locator,
|
|
1305
1776
|
contentDigest: contribution.contentDigest, mutation: { kind: 'claude-permissions', permissions: content.permissions } });
|
|
1777
|
+
for (const projection of prepared.plan.projections) {
|
|
1778
|
+
for (const notice of projection.diagnostics) {
|
|
1779
|
+
const { permissionAction, permissionResource, path } = notice.detail ?? {};
|
|
1780
|
+
if (notice.code === HOST_PERMISSION_ADDITIONAL_IMPACT && path === contribution.destination
|
|
1781
|
+
&& permissionAction && permissionResource
|
|
1782
|
+
&& added[permissionAction].some((rule) => publicHostPermissionResource(rule) === permissionResource)) {
|
|
1783
|
+
appliedPermissionNotices.push(notice);
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1306
1787
|
}
|
|
1307
1788
|
else
|
|
1308
1789
|
throw new Error('platformContributionUnsupported');
|
|
1309
1790
|
return { mutation: 'confirmed', changed: true };
|
|
1310
1791
|
},
|
|
1311
|
-
removeOwned: async (
|
|
1312
|
-
|
|
1792
|
+
removeOwned: async (binding, component) => {
|
|
1793
|
+
if (isAntigravityProjectDirectory(binding) && component.kind === 'owned-directory'
|
|
1794
|
+
&& component.path !== prepared.plan.evidence.layout.packageRoot && prepared.driverState.bundle) {
|
|
1795
|
+
const replacement = prepared.driverState.packageComponent;
|
|
1796
|
+
if (replacement?.kind !== 'owned-directory' || await requireWritable(replacement, this.ownership) !== 'present'
|
|
1797
|
+
|| await readPlatformPackageContentDigest(replacement.path) !== prepared.driverState.bundle.contentDigest) {
|
|
1798
|
+
throw Object.assign(new Error('The Antigravity replacement package could not be verified.'), {
|
|
1799
|
+
code: 'operationPlanStale', mutation: 'none',
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
const locator = component.kind === 'shared-config' && component.locator.kind === 'host-permissions' ? component.locator : undefined;
|
|
1804
|
+
const restorations = [];
|
|
1805
|
+
let permissionFailure;
|
|
1806
|
+
const executor = locator ? { ...this.ownership, removeShared: async () => {
|
|
1807
|
+
try {
|
|
1808
|
+
await updateHostPermissions(ctx, locator, undefined, (previous, current, target = locator.settingsPath, host) => this.recordPermissionWrite(target, previous, current, locator.platform === 'grok' ? host : undefined), batch, (notices) => {
|
|
1809
|
+
for (const notice of notices) {
|
|
1810
|
+
(notice.code === 'hostPermissionRestored' ? restorations : appliedPermissionNotices).push(notice);
|
|
1811
|
+
}
|
|
1812
|
+
}, undefined, relatedProjectBatch);
|
|
1813
|
+
}
|
|
1814
|
+
catch (error) {
|
|
1815
|
+
permissionFailure = error;
|
|
1816
|
+
throw error;
|
|
1817
|
+
}
|
|
1818
|
+
} } : this.ownership;
|
|
1819
|
+
const result = await cleanupOwnedComponents({ components: [component], executor });
|
|
1313
1820
|
cleanupResults.push(result);
|
|
1314
1821
|
if (result.failures.length || result.residual.length || result.quarantined.length) {
|
|
1822
|
+
if (permissionFailure)
|
|
1823
|
+
throw permissionFailure;
|
|
1315
1824
|
throw Object.assign(new Error('deploymentCleanupIncomplete'), result.removed.length || result.quarantined.length
|
|
1316
1825
|
? { mutation: 'confirmed' } : {});
|
|
1317
1826
|
}
|
|
1318
|
-
return { mutation: result.removed.length ? 'confirmed' : 'none', changed: result.removed.length > 0 };
|
|
1827
|
+
return { mutation: result.removed.length ? 'confirmed' : 'none', changed: result.removed.length > 0, diagnostics: restorations };
|
|
1319
1828
|
},
|
|
1320
1829
|
} }, prepared);
|
|
1321
1830
|
}
|
|
@@ -1327,8 +1836,10 @@ export class PlatformRebuildSession {
|
|
|
1327
1836
|
id: effect.id, status: 'unknown', mutation: 'possible', diagnostics: [diagnostic]
|
|
1328
1837
|
})),
|
|
1329
1838
|
after: await adapter.inspect(ctx, prepared.plan.binding).catch(() => prepared.driverState.before),
|
|
1330
|
-
unmet:
|
|
1839
|
+
unmet: prepared.plan.expected.unmet.map((gap) => ({ ...gap, productIds: prepared.plan.binding.consumers.map(({ id }) => id) })),
|
|
1840
|
+
reload: 'unknown', diagnostics: [diagnostic] };
|
|
1331
1841
|
}
|
|
1842
|
+
receipt.diagnostics.push(...appliedPermissionNotices);
|
|
1332
1843
|
receipts.push(receipt);
|
|
1333
1844
|
if (receipt.diagnostics.some(({ code }) => code === 'processCleanupUnconfirmed'))
|
|
1334
1845
|
return receipts;
|
|
@@ -1341,13 +1852,6 @@ export class PlatformRebuildSession {
|
|
|
1341
1852
|
: 'The shared package was kept for another scope.',
|
|
1342
1853
|
subject: { target: prepared.plan.binding.platform, pluginId: prepared.plan.binding.plugin.pluginId, scope: prepared.plan.binding.scope.kind } });
|
|
1343
1854
|
}
|
|
1344
|
-
for (const unitId of prepared.plan.binding.renderUnitIds)
|
|
1345
|
-
for (const resolution of preparedUnits.get(unitId)?.finalized.producerResolutions ?? []) {
|
|
1346
|
-
if (resolution.state !== 'failed')
|
|
1347
|
-
continue;
|
|
1348
|
-
receipt.diagnostics.push({ code: 'managedCommandProducerFailed', severity: 'error', message: resolution.error.message,
|
|
1349
|
-
subject: { target: prepared.plan.binding.platform, pluginId: prepared.plan.binding.plugin.pluginId, scope: prepared.plan.binding.scope.kind } });
|
|
1350
|
-
}
|
|
1351
1855
|
const publish = prepared.plan.effects.find((effect) => effect.kind === 'publish-package');
|
|
1352
1856
|
const publication = receipt.effects.find((result) => result.id === publish?.id && result.status === 'applied');
|
|
1353
1857
|
try {
|
|
@@ -1376,29 +1880,30 @@ export class PlatformRebuildSession {
|
|
|
1376
1880
|
if (prepared.plan.evidence.retainPackage || receipt.diagnostics.some((diagnostic) => diagnostic.code === 'operationPlanStale')
|
|
1377
1881
|
|| receipt.effects.some((effect) => ['failed', 'unknown', 'blocked', 'skipped'].includes(effect.status)))
|
|
1378
1882
|
continue;
|
|
1883
|
+
this.recordGrokWrites(prepared, receipt, publication?.mutation === 'confirmed', writtenFiles, shadowedUsers.get(prepared.plan.binding.id));
|
|
1884
|
+
const piInventoryKey = piProjectInventoryKey(prepared.plan.binding, prepared.plan.evidence.layout.activationPath);
|
|
1885
|
+
if (piInventoryKey && piProjectEmptyDeliveryObserved(prepared.plan.binding, prepared.driverState.before)
|
|
1886
|
+
&& receipt.after.registration === 'present' && receipt.after.ownership === 'aw' && receipt.after.configuration?.activation === 'enabled'
|
|
1887
|
+
&& prepared.plan.effects.some((effect) => effect.kind === 'register' && receipt.effects.some((result) => result.id === effect.id && result.status === 'applied' && result.mutation === 'confirmed'))) {
|
|
1888
|
+
const registered = this.piProjectRegisteredRoots.get(piInventoryKey) ?? new Set();
|
|
1889
|
+
registered.add(prepared.plan.evidence.layout.packageRoot);
|
|
1890
|
+
this.piProjectRegisteredRoots.set(piInventoryKey, registered);
|
|
1891
|
+
}
|
|
1379
1892
|
try {
|
|
1380
|
-
const candidates = [...preparedUnits.values()].flatMap((unit) => unit.finalized.commandCandidates)
|
|
1381
|
-
.filter((candidate) => candidate.producer.kind !== 'package' && candidate.producer.placementKey === prepared.plan.binding.physicalKey);
|
|
1382
1893
|
const root = prepared.plan.evidence.layout.packageRoot;
|
|
1383
1894
|
const mappings = prepared.plan.projections.filter((projection) => projection.bundle !== null).flatMap((projection) => projection.components);
|
|
1384
|
-
for (const candidate of candidates) {
|
|
1385
|
-
const componentId = candidate.producer.kind === 'static-skill' ? `skill:${candidate.producer.key}` : candidate.producer.key;
|
|
1386
|
-
const mapping = mappings.find((item) => item.id === componentId);
|
|
1387
|
-
if (!mapping || !mapping.relativeOutputs.some((output) => output === `skills/${mapping.nativeName}/SKILL.md`))
|
|
1388
|
-
throw new Error('commandProducerProjectionMissing');
|
|
1389
|
-
await publishManagedCommandBindings({ ...candidate, resourceRoot: path.join(root, 'skills', mapping.nativeName),
|
|
1390
|
-
env: this.context.env, bindingRecoveryEvidence });
|
|
1391
|
-
}
|
|
1392
1895
|
const bundle = prepared.plan.projections.find((projection) => projection.bundle)?.bundle;
|
|
1393
1896
|
const packageOwner = prepared.plan.evidence.ownership.find((slot) => 'path' in slot.component && slot.component.path === root)?.component;
|
|
1394
1897
|
if (bundle && packageOwner?.kind === 'owned-directory' && prepared.plan.evidence.contentMatches
|
|
1395
1898
|
&& !receipt.diagnostics.some((diagnostic) => diagnostic.severity === 'error')
|
|
1396
1899
|
&& packageDeliveryConfirmed(prepared.plan.binding, receipt.after, bundle.contentDigest, requireIndependentActivation)
|
|
1397
1900
|
&& await readPlatformPackageContentDigest(root) === bundle.contentDigest) {
|
|
1901
|
+
const marker = await readSkillOwnerMarker({ skillRoot: root, allowedRoot: packageOwner.allowedRoot, expectedIdentity: packageOwner.identity });
|
|
1398
1902
|
const projection = { components: mappings, contentDigest: bundle.contentDigest,
|
|
1399
|
-
inputDigest: inputDigests.get(prepared.plan.binding.id), preparation: prepared.plan.expected.unmet.
|
|
1903
|
+
inputDigest: inputDigests.get(prepared.plan.binding.id), preparation: prepared.plan.expected.unmet.some((gap) => !isDeliveryCapabilityGap(gap)) ? 'partial' : 'complete',
|
|
1904
|
+
...(bundle.piExtensionDigest && marker?.nativeProjection?.piExtensionDigest === bundle.piExtensionDigest
|
|
1905
|
+
? { piExtensionDigest: bundle.piExtensionDigest } : {}),
|
|
1400
1906
|
physicalIdentity: (await getDeploymentLayout(ctx, prepared.plan.binding)).physicalIdentity };
|
|
1401
|
-
const marker = await readSkillOwnerMarker({ skillRoot: root, allowedRoot: packageOwner.allowedRoot, expectedIdentity: packageOwner.identity });
|
|
1402
1907
|
if (marker && (!marker.nativeProjection || artifactValueDigest(marker.nativeProjection) !== artifactValueDigest(projection))) {
|
|
1403
1908
|
await writeSkillOwnerMarker({ skillRoot: root, allowedRoot: packageOwner.allowedRoot, identity: packageOwner.identity, nativeProjection: projection });
|
|
1404
1909
|
for (const check of this.mutableChecks.values())
|
|
@@ -1407,16 +1912,7 @@ export class PlatformRebuildSession {
|
|
|
1407
1912
|
receipt.after = await adapter.inspect(ctx, prepared.plan.binding);
|
|
1408
1913
|
}
|
|
1409
1914
|
}
|
|
1410
|
-
const
|
|
1411
|
-
for (const producer of priorProducers.get(prepared.plan.binding.id) ?? []) {
|
|
1412
|
-
if (candidates.some((candidate) => artifactValueDigest(candidate.producer) === artifactValueDigest(producer)))
|
|
1413
|
-
continue;
|
|
1414
|
-
const componentId = producer.kind === 'static-skill' ? `skill:${producer.key}` : producer.key;
|
|
1415
|
-
if (packageRemoved || publication && !prepared.plan.expected.unmet.some((gap) => gap.id === componentId)) {
|
|
1416
|
-
await revokeManagedCommandBindings(producer, this.context.env);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
const emptyState = emptyStates.get(prepared.plan.binding.id);
|
|
1915
|
+
const emptyState = gapStates.get(prepared.plan.binding.id) ?? emptyStates.get(prepared.plan.binding.id);
|
|
1420
1916
|
const removedByCommand = piProjectRemovalConfirmed(prepared.plan, receipt);
|
|
1421
1917
|
const inactiveScope = removedByCommand || receipt.after.registration === 'absent'
|
|
1422
1918
|
|| receipt.after.package === 'absent' && receipt.after.registration === 'not-applicable'
|
|
@@ -1425,20 +1921,29 @@ export class PlatformRebuildSession {
|
|
|
1425
1921
|
&& ['codex-marketplace', 'copilot-marketplace'].includes(prepared.plan.binding.route)
|
|
1426
1922
|
&& receipt.after.configuration?.activation === 'absent'
|
|
1427
1923
|
|| receipt.after.consumers.every((consumer) => ['disabled', 'not-applicable'].includes(consumer.activation));
|
|
1428
|
-
if (emptyState && !prepared.plan.expected.components.length &&
|
|
1429
|
-
&& !receipt.diagnostics.some((diagnostic) => diagnostic.severity === 'error')
|
|
1430
|
-
&& (receipt.after.registration !== 'unknown' || removedByCommand) && receipt.after.package !== 'unknown'
|
|
1431
|
-
&& !['foreign', 'unknown'].includes(receipt.after.ownership)
|
|
1432
|
-
&& inactiveScope) {
|
|
1924
|
+
if (emptyState && !prepared.plan.expected.components.length && receipt.unmet.every(isDeliveryCapabilityGap)
|
|
1925
|
+
&& !receipt.diagnostics.some((diagnostic) => diagnostic.severity === 'error')) {
|
|
1433
1926
|
const residual = await inspectOwnedComponents({ components: prepared.plan.evidence.ownership
|
|
1434
|
-
.filter((slot) => !('path' in slot.component) || slot.component.path !==
|
|
1927
|
+
.filter((slot) => !('path' in slot.component) || slot.component.path !== root)
|
|
1435
1928
|
.map((slot) => slot.component), executor: this.ownership });
|
|
1436
|
-
|
|
1929
|
+
const hiddenEmptyPi = emptyState.result === 'capability-gaps' && piProjectEmptyDeliveryObserved(prepared.plan.binding, receipt.after);
|
|
1930
|
+
const clear = (receipt.after.registration !== 'unknown' || removedByCommand || hiddenEmptyPi)
|
|
1931
|
+
&& (emptyState.result !== 'capability-gaps' || prepared.plan.binding.route !== 'pi-package' || receipt.after.configuration?.activation === 'absent')
|
|
1932
|
+
&& receipt.after.package !== 'unknown' && !['foreign', 'unknown'].includes(receipt.after.ownership)
|
|
1933
|
+
&& (inactiveScope || hiddenEmptyPi)
|
|
1934
|
+
&& (emptyState.result === 'intentional-empty' || receipt.after.package === 'absent')
|
|
1935
|
+
&& residual.components.every((slot) => slot.state === 'absent');
|
|
1936
|
+
if (clear)
|
|
1437
1937
|
await writePlatformEmptyState({ state: emptyState, env: this.context.env });
|
|
1938
|
+
else if (emptyState.result === 'capability-gaps')
|
|
1939
|
+
receipt.diagnostics.push({ code: 'previousDeploymentRetained', severity: 'error',
|
|
1940
|
+
message: 'Previous output or registration could not be confirmed absent. Check the scoped deployment before retrying.',
|
|
1941
|
+
subject: { target: prepared.plan.binding.platform, pluginId: prepared.plan.binding.plugin.pluginId, scope: prepared.plan.binding.scope.kind },
|
|
1942
|
+
detail: { reasonCode: 'previousDeploymentRetained', path: root } });
|
|
1438
1943
|
}
|
|
1439
1944
|
}
|
|
1440
1945
|
catch (error) {
|
|
1441
|
-
receipt.diagnostics.push({ code: '
|
|
1946
|
+
receipt.diagnostics.push({ code: 'platformProjectionEvidenceFailed', severity: 'error',
|
|
1442
1947
|
message: error instanceof Error ? error.message : String(error),
|
|
1443
1948
|
subject: { target: prepared.plan.binding.platform, pluginId: prepared.plan.binding.plugin.pluginId, scope: prepared.plan.binding.scope.kind } });
|
|
1444
1949
|
}
|