@lesliechan721/aw 0.1.0-beta.102 → 0.1.0-beta.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/src/commands/catalog-generation.d.ts +2 -5
  2. package/dist/src/commands/catalog-generation.js +2 -4
  3. package/dist/src/commands/catalog-generation.js.map +1 -1
  4. package/dist/src/commands/lifecycle-command-package.d.ts +1 -1
  5. package/dist/src/commands/lifecycle-command-package.js +40 -2
  6. package/dist/src/commands/lifecycle-command-package.js.map +1 -1
  7. package/dist/src/commands/managed-commands.d.ts +2 -1
  8. package/dist/src/commands/managed-commands.js +4 -2
  9. package/dist/src/commands/managed-commands.js.map +1 -1
  10. package/dist/src/commands/operation-plan.d.ts +2 -8
  11. package/dist/src/commands/operation-plan.js.map +1 -1
  12. package/dist/src/commands/public-config-confirmation.d.ts +16 -10
  13. package/dist/src/commands/public-config-confirmation.js +87 -52
  14. package/dist/src/commands/public-config-confirmation.js.map +1 -1
  15. package/dist/src/commands/public-lifecycle.d.ts +1 -1
  16. package/dist/src/commands/public-lifecycle.js +36 -8
  17. package/dist/src/commands/public-lifecycle.js.map +1 -1
  18. package/dist/src/commands/public-plugin-query.js +6 -4
  19. package/dist/src/commands/public-plugin-query.js.map +1 -1
  20. package/dist/src/commands/rebuild-command.d.ts +22 -6
  21. package/dist/src/commands/rebuild-command.js +273 -557
  22. package/dist/src/commands/rebuild-command.js.map +1 -1
  23. package/dist/src/commands/rebuild-integration.d.ts +12 -39
  24. package/dist/src/commands/rebuild-integration.js +67 -303
  25. package/dist/src/commands/rebuild-integration.js.map +1 -1
  26. package/dist/src/commands/rebuild-operations.d.ts +0 -4
  27. package/dist/src/commands/rebuild-operations.js +9 -8
  28. package/dist/src/commands/rebuild-operations.js.map +1 -1
  29. package/dist/src/commands/rebuild-platform-integration.d.ts +14 -6
  30. package/dist/src/commands/rebuild-platform-integration.js +310 -101
  31. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  32. package/dist/src/commands/status-v6.d.ts +3 -117
  33. package/dist/src/commands/status-v6.js +0 -2886
  34. package/dist/src/commands/status-v6.js.map +1 -1
  35. package/dist/src/commands/write-commands.js +0 -3
  36. package/dist/src/commands/write-commands.js.map +1 -1
  37. package/dist/src/index.js +44 -36
  38. package/dist/src/index.js.map +1 -1
  39. package/dist/src/intent/deployment-preferences.js +4 -3
  40. package/dist/src/intent/deployment-preferences.js.map +1 -1
  41. package/dist/src/intent/intent-store.js +3 -2
  42. package/dist/src/intent/intent-store.js.map +1 -1
  43. package/dist/src/output/command-receipt.d.ts +0 -6
  44. package/dist/src/output/command-receipt.js +0 -15
  45. package/dist/src/output/command-receipt.js.map +1 -1
  46. package/dist/src/output/receipt-projection.js +2 -1
  47. package/dist/src/output/receipt-projection.js.map +1 -1
  48. package/dist/src/platforms/capabilities.js +8 -2
  49. package/dist/src/platforms/capabilities.js.map +1 -1
  50. package/dist/src/platforms/contracts.d.ts +2 -0
  51. package/dist/src/platforms/discovery.d.ts +2 -0
  52. package/dist/src/platforms/discovery.js +95 -49
  53. package/dist/src/platforms/discovery.js.map +1 -1
  54. package/dist/src/platforms/inspection-native.d.ts +7 -1
  55. package/dist/src/platforms/inspection-native.js +6 -3
  56. package/dist/src/platforms/inspection-native.js.map +1 -1
  57. package/dist/src/platforms/inspection-query.d.ts +28 -14
  58. package/dist/src/platforms/inspection-query.js +102 -8
  59. package/dist/src/platforms/inspection-query.js.map +1 -1
  60. package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
  61. package/dist/src/platforms/lifecycle-native-services.js +7 -2
  62. package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
  63. package/dist/src/platforms/lifecycle-native.js +20 -3
  64. package/dist/src/platforms/lifecycle-native.js.map +1 -1
  65. package/dist/src/platforms/lifecycle.js +5 -0
  66. package/dist/src/platforms/lifecycle.js.map +1 -1
  67. package/dist/src/platforms/supplement-state.js +11 -2
  68. package/dist/src/platforms/supplement-state.js.map +1 -1
  69. package/dist/src/portable/commands.d.ts +1 -0
  70. package/dist/src/portable/commands.js.map +1 -1
  71. package/dist/src/portable/materializer.d.ts +2 -0
  72. package/dist/src/portable/materializer.js +4 -4
  73. package/dist/src/portable/materializer.js.map +1 -1
  74. package/dist/src/portable/recovery.d.ts +1 -0
  75. package/dist/src/portable/recovery.js +3 -2
  76. package/dist/src/portable/recovery.js.map +1 -1
  77. package/dist/src/recovery/coordinator.d.ts +6 -1
  78. package/dist/src/recovery/coordinator.js +113 -108
  79. package/dist/src/recovery/coordinator.js.map +1 -1
  80. package/dist/src/recovery/demand.d.ts +1 -2
  81. package/dist/src/recovery/demand.js +4 -11
  82. package/dist/src/recovery/demand.js.map +1 -1
  83. package/dist/src/recovery/install-concurrency.d.ts +12 -0
  84. package/dist/src/recovery/install-concurrency.js +39 -0
  85. package/dist/src/recovery/install-concurrency.js.map +1 -1
  86. package/dist/src/recovery/joint-coordinator.d.ts +3 -4
  87. package/dist/src/recovery/joint-coordinator.js +324 -188
  88. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  89. package/dist/src/recovery/joint-demand.js +4 -3
  90. package/dist/src/recovery/joint-demand.js.map +1 -1
  91. package/dist/src/recovery/joint-install-execution.js +46 -2
  92. package/dist/src/recovery/joint-install-execution.js.map +1 -1
  93. package/dist/src/recovery/joint-install-native-rebase.js +5 -2
  94. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -1
  95. package/dist/src/recovery/locked-prepared-execution.d.ts +32 -0
  96. package/dist/src/recovery/locked-prepared-execution.js +67 -0
  97. package/dist/src/recovery/locked-prepared-execution.js.map +1 -0
  98. package/dist/src/recovery/status.d.ts +20 -6
  99. package/dist/src/recovery/status.js +153 -98
  100. package/dist/src/recovery/status.js.map +1 -1
  101. package/dist/src/review/skill-materialization.d.ts +1 -0
  102. package/dist/src/review/skill-materialization.js.map +1 -1
  103. package/dist/src/tui/console-app-v4.js +4 -14
  104. package/dist/src/tui/console-app-v4.js.map +1 -1
  105. package/dist/src/tui/controller-runtime.js +201 -57
  106. package/dist/src/tui/controller-runtime.js.map +1 -1
  107. package/dist/src/tui/controller.d.ts +8 -9
  108. package/dist/src/tui/controller.js +5 -6
  109. package/dist/src/tui/controller.js.map +1 -1
  110. package/dist/src/tui/operation-review-planner.js +14 -103
  111. package/dist/src/tui/operation-review-planner.js.map +1 -1
  112. package/dist/src/types.d.ts +5 -1
  113. package/dist/src/types.js.map +1 -1
  114. package/dist/src/utils/agent-version.js +1 -0
  115. package/dist/src/utils/agent-version.js.map +1 -1
  116. package/dist/src/utils/artifact-renderer.d.ts +10 -0
  117. package/dist/src/utils/artifact-renderer.js +28 -2
  118. package/dist/src/utils/artifact-renderer.js.map +1 -1
  119. package/dist/src/utils/aw-home-mutation-lock.d.ts +8 -0
  120. package/dist/src/utils/aw-home-mutation-lock.js +44 -8
  121. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  122. package/dist/src/utils/bundle-integrity.js +126 -33
  123. package/dist/src/utils/bundle-integrity.js.map +1 -1
  124. package/dist/src/utils/catalog-generation-resolver.d.ts +4 -0
  125. package/dist/src/utils/catalog-generation-resolver.js +4 -0
  126. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  127. package/dist/src/utils/catalog-generation-service.d.ts +50 -11
  128. package/dist/src/utils/catalog-generation-service.js +276 -130
  129. package/dist/src/utils/catalog-generation-service.js.map +1 -1
  130. package/dist/src/utils/catalog-generation-state.js +6 -1
  131. package/dist/src/utils/catalog-generation-state.js.map +1 -1
  132. package/dist/src/utils/catalog-generation-store.d.ts +5 -0
  133. package/dist/src/utils/catalog-generation-store.js +36 -13
  134. package/dist/src/utils/catalog-generation-store.js.map +1 -1
  135. package/dist/src/utils/catalog-operation-context.d.ts +17 -3
  136. package/dist/src/utils/catalog-operation-context.js +220 -22
  137. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  138. package/dist/src/utils/catalog-performance.d.ts +3 -0
  139. package/dist/src/utils/catalog-performance.js +26 -0
  140. package/dist/src/utils/catalog-performance.js.map +1 -0
  141. package/dist/src/utils/catalog-snapshot.d.ts +5 -2
  142. package/dist/src/utils/catalog-snapshot.js +3 -2
  143. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  144. package/dist/src/utils/catalog-source-impact.d.ts +2 -1
  145. package/dist/src/utils/catalog-source-impact.js +2 -2
  146. package/dist/src/utils/catalog-source-impact.js.map +1 -1
  147. package/dist/src/utils/catalog-source-references.d.ts +2 -0
  148. package/dist/src/utils/catalog-source-references.js +284 -148
  149. package/dist/src/utils/catalog-source-references.js.map +1 -1
  150. package/dist/src/utils/codex-executable-discovery.js +1 -0
  151. package/dist/src/utils/codex-executable-discovery.js.map +1 -1
  152. package/dist/src/utils/codex-manager.js +1 -0
  153. package/dist/src/utils/codex-manager.js.map +1 -1
  154. package/dist/src/utils/codex-native-observation.d.ts +5 -2
  155. package/dist/src/utils/codex-native-observation.js +8 -4
  156. package/dist/src/utils/codex-native-observation.js.map +1 -1
  157. package/dist/src/utils/component-command-preparation.d.ts +1 -0
  158. package/dist/src/utils/component-command-preparation.js.map +1 -1
  159. package/dist/src/utils/git-catalog-provider.d.ts +38 -5
  160. package/dist/src/utils/git-catalog-provider.js +365 -156
  161. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  162. package/dist/src/utils/managed-command-closure.d.ts +3 -1
  163. package/dist/src/utils/managed-command-closure.js +10 -5
  164. package/dist/src/utils/managed-command-closure.js.map +1 -1
  165. package/dist/src/utils/managed-command-materialization.d.ts +2 -0
  166. package/dist/src/utils/managed-command-materialization.js +4 -3
  167. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  168. package/dist/src/utils/managed-command-preparation.js +1 -1
  169. package/dist/src/utils/managed-command-preparation.js.map +1 -1
  170. package/dist/src/utils/multi-source-catalog.d.ts +1 -1
  171. package/dist/src/utils/multi-source-catalog.js +3 -3
  172. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  173. package/dist/src/utils/native-cli.d.ts +6 -1
  174. package/dist/src/utils/native-cli.js +67 -32
  175. package/dist/src/utils/native-cli.js.map +1 -1
  176. package/dist/src/utils/platform-empty-state.d.ts +2 -0
  177. package/dist/src/utils/platform-empty-state.js +5 -5
  178. package/dist/src/utils/platform-empty-state.js.map +1 -1
  179. package/dist/src/utils/plugin-config-command-apply.d.ts +14 -4
  180. package/dist/src/utils/plugin-config-command-apply.js +49 -5
  181. package/dist/src/utils/plugin-config-command-apply.js.map +1 -1
  182. package/dist/src/utils/plugin-config-impact.d.ts +42 -0
  183. package/dist/src/utils/plugin-config-impact.js +170 -14
  184. package/dist/src/utils/plugin-config-impact.js.map +1 -1
  185. package/dist/src/utils/plugin-config-references.d.ts +3 -1
  186. package/dist/src/utils/plugin-config-references.js +3 -5
  187. package/dist/src/utils/plugin-config-references.js.map +1 -1
  188. package/dist/src/utils/plugin-config-write.d.ts +14 -5
  189. package/dist/src/utils/plugin-config-write.js +213 -117
  190. package/dist/src/utils/plugin-config-write.js.map +1 -1
  191. package/dist/src/utils/plugin-config.d.ts +2 -0
  192. package/dist/src/utils/plugin-config.js.map +1 -1
  193. package/dist/src/utils/plugin-scripts.d.ts +2 -0
  194. package/dist/src/utils/plugin-scripts.js +102 -3
  195. package/dist/src/utils/plugin-scripts.js.map +1 -1
  196. package/package.json +3 -3
  197. package/dist/src/utils/codex-reconciler.d.ts +0 -123
  198. package/dist/src/utils/codex-reconciler.js +0 -322
  199. package/dist/src/utils/codex-reconciler.js.map +0 -1
@@ -6,7 +6,7 @@ import { getStaticTOMLValue, parseTOML } from 'toml-eslint-parser';
6
6
  import { sealPermissionBatches } from './permission-batch.js';
7
7
  import { COMMAND_ROUTE_UNREACHABLE, HOST_PERMISSION_ADDITIONAL_IMPACT, publicHostPermissionResource } from '../output/component-delivery.js';
8
8
  import { createMarketplaceManifestEntry, getComponentFeatureRequirements, normalizeStaticPluginComponents } from '@lesliechan721/aw-plugin-core/manifest';
9
- import { selectNativeProduct, supportsSharedNativeProbe } from '../platforms/discovery.js';
9
+ import { selectNativeProduct } from '../platforms/discovery.js';
10
10
  import { getAgentPluginAdapter } from '../platforms/registry.js';
11
11
  import { getQualifiedPlatformProfile } from '../platforms/capabilities.js';
12
12
  import { getDeploymentLayout, getDeploymentResourceKey, getInvocationPolicyPhysicalKey, scopedPermissionPath, isAntigravityProjectDirectory, hasSharedUserPackage } from '../platforms/layout.js';
@@ -33,8 +33,8 @@ import { skillAgentBinding } from '../utils/component-agent-binding.js';
33
33
  import { finalizePlatformSkillProducers } from '../utils/component-command-preparation.js';
34
34
  import { resolveStaticPlatformResourceRoot } from '../utils/component-resources.js';
35
35
  import { cleanupOwnedComponents, createSharedOwnerToken, inspectOwnedComponents, renderOwnedTextFile, writeOwnedTextFile, writeSkillOwnerMarker } from '../utils/ownership.js';
36
- import { createPlatformInputEvidence, platformPackageInputDigest, platformPermissionNotices, readPlatformPackageContentDigest, writePlatformEmptyState } from '../utils/platform-empty-state.js';
37
- import { writePlatformSupplementState } from '../platforms/supplement-state.js';
36
+ import { createPlatformInputEvidence, platformPackageInputDigest, platformPermissionNotices, matchesPlatformEmptyState, readPlatformPackageContentDigest, writePlatformEmptyState } from '../utils/platform-empty-state.js';
37
+ import { inspectPlatformSupplementState, writePlatformSupplementState } from '../platforms/supplement-state.js';
38
38
  import { atomicReplaceSafeFile, assertSafeFileMutationPath } from '../utils/safe-fs.js';
39
39
  import { captureManagedCommandReviewEvidence } from '../utils/managed-command-review.js';
40
40
  import { readClaudeSettings } from '../adapters/helpers.js';
@@ -43,6 +43,7 @@ import { readCodexConfigFile } from '../utils/codex-config.js';
43
43
  import { parseOwnedTextHeader, readSkillOwnerMarker } from '../utils/ownership.js';
44
44
  import { applyPlannedOperationAction, isNativeActivationOnlyTarget } from './rebuild-integration.js';
45
45
  import { recoveryInterruptionCode } from '../recovery/interruption.js';
46
+ import { hasPlannedPreApply } from './rebuild-operations.js';
46
47
  /** Resources touched by the frozen adapter plans, including host-managed writes. */
47
48
  export function nativeInstallResources(plans) {
48
49
  if (!plans.length)
@@ -387,7 +388,7 @@ async function ownedSupplements(binding, root, physicalKey) {
387
388
  }
388
389
  function readContext(context, cwd, confirmedCatalogRetirement) {
389
390
  return { cwd, invocationCwd: context.invocationCwd, env: context.env, runner: context.nativeCliRunner, signal: context.signal,
390
- confirmedCatalogRetirement, codexObservationSession: confirmedCatalogRetirement ? undefined : context.codexObservationSession };
391
+ confirmedCatalogRetirement };
391
392
  }
392
393
  function operation(input) {
393
394
  return input.command === 'uninstall' ? 'remove' : input.command === 'cleanup' ? 'cleanup'
@@ -614,7 +615,8 @@ export class PlatformRebuildSession {
614
615
  return [...this.openCodeProjectBatches.values()].flatMap((batch) => pendingRelatedProjectNotices(batch, interrupted));
615
616
  }
616
617
  grokPermissionWrites = new Map();
617
- recordPermissionWrite(target, previous, current, host) {
618
+ recordPermissionWrite(platform, target, previous, current, host) {
619
+ this.context.nativeObservationBatch?.invalidatePlatform(platform, 'inspect');
618
620
  const last = this.permissionWrites.get(target);
619
621
  this.permissionWrites.set(target, { previous: last?.current === previous ? last.previous : previous, current });
620
622
  if (host && host.previous !== host.current) {
@@ -660,7 +662,8 @@ export class PlatformRebuildSession {
660
662
  marketplaceCandidatesFrozen = false;
661
663
  ownership = platformOwnership;
662
664
  marketplaces = new Map();
663
- closedObservationBatch;
665
+ rejectedTargets = new Set();
666
+ sealedEpochs = new WeakMap();
664
667
  staging;
665
668
  constructor(context, adapterFor = getAgentPluginAdapter) {
666
669
  this.context = context;
@@ -673,13 +676,11 @@ export class PlatformRebuildSession {
673
676
  }
674
677
  setOwnershipExecutor(executor) { this.ownership = executor; }
675
678
  root() { return this.staging ??= fs.mkdtemp(path.join(os.tmpdir(), 'aw-deployment-')); }
676
- ordinaryReadContext(ctx, platform) {
677
- const batch = this.context.nativeObservationBatch;
678
- // A locked re-Review starts its own observation batch. Cached targets of
679
- // the earlier Review do not close the new batch before its first build.
680
- const open = platform === 'pi'
681
- ? batch !== this.closedObservationBatch : this.targets.size === 0 && platform !== 'codex';
682
- return open && batch ? { ...ctx, ...batch } : ctx;
679
+ readWindow(input, kind, base) {
680
+ if (base.confirmedCatalogRetirement || this.rejectedTargets.has(this.key(input)))
681
+ return base;
682
+ const batch = input.observationBatch ?? this.context.nativeObservationBatch;
683
+ return batch ? batch.readContextFor(input.platform, kind, base) : base;
683
684
  }
684
685
  recordGrokWrites(prepared, receipt, packagePublished, writtenFiles, shadowedUser) {
685
686
  const { binding, operation, evidence: { layout } } = prepared.plan;
@@ -854,6 +855,7 @@ export class PlatformRebuildSession {
854
855
  this.grokProjectRetirements.clear();
855
856
  this.grokRemovals.clear();
856
857
  this.offlinePermissionRemovals.clear();
858
+ this.rejectedTargets.clear();
857
859
  this.contexts.clear();
858
860
  this.mutableChecks.clear();
859
861
  this.requestedOperations.clear();
@@ -869,7 +871,7 @@ export class PlatformRebuildSession {
869
871
  return artifactValueDigest({ plugin: sourceIdentity(input), platform: input.platform, scope: input.scope, cwd: input.scope === 'project' ? input.cwd : null,
870
872
  operation: operation(input), confirmedCatalogRetirement: this.retirementMode(input) });
871
873
  }
872
- resolve(input, placementProbeGroup) {
874
+ resolve(input) {
873
875
  const key = this.key(input);
874
876
  // Inspection of a shared package does not request activation in that scope.
875
877
  if (!input.readOnlyInspectionPlan)
@@ -880,14 +882,13 @@ export class PlatformRebuildSession {
880
882
  const adapter = this.adapterFor(input.platform);
881
883
  const mode = this.retirementMode(input);
882
884
  const readCtx = readContext(this.context, input.cwd, mode);
883
- const ctx = mode ? readCtx : input.readOnlyInspectionPlan && input.observationBatch ? { ...readCtx, ...input.observationBatch }
884
- : this.ordinaryReadContext(readCtx, input.platform);
885
+ const ctx = this.readWindow(input, 'ordinary', readCtx);
885
886
  const plugin = sourceIdentity(input);
886
887
  const recoveryCandidates = (this.context.recoveryCandidates ?? []).filter((candidate) => candidate.binding.platform === input.platform
887
888
  && candidate.binding.plugin.sourceIdentity === plugin.sourceIdentity && candidate.binding.plugin.pluginId === plugin.pluginId
888
889
  && candidate.binding.scope.kind === input.scope && (candidate.binding.scope.kind !== 'project' || candidate.binding.scope.projectRoot === input.cwd));
889
890
  const scope = input.scope === 'project' ? { kind: 'project', projectRoot: input.cwd } : { kind: 'user' };
890
- const discovery = await adapter.discover(placementProbeGroup ? { ...ctx, placementProbeGroup } : ctx);
891
+ const discovery = await adapter.discover(ctx);
891
892
  const resolution = await adapter.resolve(ctx, { plugin, scope, operation: operation(input), discovery, recoveryCandidates });
892
893
  this.exclusions.set(key, resolution.exclusions.flatMap((exclusion) => {
893
894
  if (!exclusion.productId)
@@ -912,18 +913,59 @@ export class PlatformRebuildSession {
912
913
  }
913
914
  return result;
914
915
  }
915
- /** Resolve the whole selected scope before any physical unit is rendered. */
916
- async resolveAll(inputs) {
917
- const first = inputs[0];
918
- const samePlacement = supportsSharedNativeProbe && first && inputs.length > 1
919
- && this.context.batchInstallPlatform === first.platform && this.context.nativeObservationBatch?.scriptFreePlacement === true
920
- && inputs.every((input) => input.platform === first.platform && input.scope === first.scope && input.cwd === first.cwd
921
- && operation(input) === 'ensure');
922
- const group = samePlacement ? { scope: first.scope, probes: new Map() } : undefined;
923
- await Promise.allSettled(inputs.map((input) => this.resolve(input, group)));
916
+ /** Freeze the group's ordinary host evidence before any opaque renderer starts. */
917
+ async resolveAll(inputs, captureOrdinary = false) {
918
+ await Promise.allSettled(inputs.map(async (input) => {
919
+ const resolution = await this.resolve(input);
920
+ const evidence = resolution.ordinaryEvidence;
921
+ if (!captureOrdinary || !evidence || operation(input) !== 'ensure')
922
+ return;
923
+ evidence.captured ??= (async () => {
924
+ const adapter = this.adapterFor(input.platform);
925
+ const ctx = this.readWindow(input, 'ordinary', readContext(this.context, input.cwd, this.retirementMode(input)));
926
+ const discovery = await adapter.discover(ctx);
927
+ const observations = new Map(await Promise.all(resolution.bindings.map(async (binding) => [binding.id, await adapter.inspect(ctx, binding)])));
928
+ return { discovery, observations };
929
+ })();
930
+ await evidence.captured;
931
+ }));
932
+ }
933
+ /** Import only the selected ordinary evidence, never a private reader's driver or context. */
934
+ async adoptOrdinaryFrom(reader, inputs) {
935
+ for (const input of inputs) {
936
+ const key = this.key(input);
937
+ const pending = reader.resolutions.get(reader.key(input));
938
+ if (!pending)
939
+ continue;
940
+ this.requestedOperations.set(key, input);
941
+ const prior = this.resolutions.get(key);
942
+ if (prior) {
943
+ const [first, next] = await Promise.allSettled([prior, pending]);
944
+ if (first.status !== 'fulfilled' || next.status !== 'fulfilled')
945
+ continue;
946
+ const firstCaptured = await first.value.ordinaryEvidence?.captured;
947
+ const nextCaptured = await next.value.ordinaryEvidence?.captured;
948
+ if (artifactValueDigest(first.value.bindings) !== artifactValueDigest(next.value.bindings)
949
+ || first.value.ordinaryEvidence?.discovery !== next.value.ordinaryEvidence?.discovery
950
+ || firstCaptured && nextCaptured && artifactValueDigest([...firstCaptured.observations]) !== artifactValueDigest([...nextCaptured.observations])) {
951
+ throw new Error('operationPlanStale: ordinary host evidence changed between scopes.');
952
+ }
953
+ // Keep the first sample; if it came from a shallow placement read,
954
+ // attach the now-complete evidence from the same ordinary phase.
955
+ if (!firstCaptured && nextCaptured && first.value.ordinaryEvidence) {
956
+ first.value.ordinaryEvidence.captured = Promise.resolve(nextCaptured);
957
+ }
958
+ }
959
+ else {
960
+ this.resolutions.set(key, pending);
961
+ const exclusions = reader.exclusions.get(reader.key(input));
962
+ if (exclusions)
963
+ this.exclusions.set(key, exclusions);
964
+ }
965
+ }
924
966
  }
925
967
  async freezeSharedPreApplyActions(targets) {
926
- const prepared = (await Promise.allSettled(this.targets.values())).flatMap((result) => result.status === 'fulfilled' ? [result.value] : []);
968
+ const prepared = (await Promise.allSettled([...this.targets.values()].map(({ result }) => result))).flatMap((result) => result.status === 'fulfilled' ? [result.value] : []);
927
969
  for (const target of targets) {
928
970
  if (target.identity.scope !== 'project' || !target.operationActions?.some((action) => action.kind === 'runPreApply'))
929
971
  continue;
@@ -942,7 +984,7 @@ export class PlatformRebuildSession {
942
984
  const input = { sourceId: target.identity.sourceId, sourceIdentity: target.identity.sourceIdentity,
943
985
  pluginName: target.plugin.manifest.name, manifest: target.plugin.manifest, platform: target.identity.platform,
944
986
  logicalIdentity: target.plugin.catalogLogicalIdentity, cwd: target.identity.cwd,
945
- env: this.context.env, referencePlugins: this.context.referencePlugins };
987
+ env: this.context.env, referencePlugins: this.context.referencePlugins, catalogReadScope: this.context.catalogReadScope };
946
988
  const [userConfig, projectConfig] = await Promise.all([
947
989
  resolveArtifactRenderConfig({ ...input, scope: 'user' }), resolveArtifactRenderConfig({ ...input, scope: 'project' }),
948
990
  ]);
@@ -959,6 +1001,16 @@ export class PlatformRebuildSession {
959
1001
  for (const target of targets)
960
1002
  this.marketplaceTargets.add(target);
961
1003
  targets = [...this.marketplaceTargets];
1004
+ // Other builds may have run a renderer since a sibling took its seal.
1005
+ const batch = this.context.nativeObservationBatch;
1006
+ if (batch)
1007
+ for (const target of targets) {
1008
+ const sealed = this.sealedEpochs.get(target);
1009
+ if (sealed?.batch === batch && sealed.epoch !== batch.writeEpoch) {
1010
+ await target.platformDeployment?.verify(batch);
1011
+ this.sealedEpochs.set(target, { batch, epoch: batch.writeEpoch });
1012
+ }
1013
+ }
962
1014
  await this.freezeSharedPreApplyActions(targets);
963
1015
  await sealPermissionBatches(targets, (target) => readContext(this.context, target.identity.cwd), this.adapterFor, this.offlinePermissionRemovals);
964
1016
  const retained = new Map(targets.flatMap((target) => (target.platformDeployment?.plans ?? [])
@@ -1064,6 +1116,7 @@ export class PlatformRebuildSession {
1064
1116
  await atomicReplaceSafeFile({ filePath: path.join(root, file.relativePath), allowedRoot: root,
1065
1117
  content: Buffer.from(file.contentBase64, 'base64').toString('utf8'), label: 'Native marketplace source' });
1066
1118
  }
1119
+ this.context.nativeObservationBatch?.invalidatePlatform(plan.binding.platform, 'inspect');
1067
1120
  generation.currentFingerprint = artifactValueDigest(await Promise.all(generation.evidence.files.map((file) => pathEvidence(path.join(root, file.relativePath)))));
1068
1121
  })();
1069
1122
  await generation.publication;
@@ -1073,21 +1126,37 @@ export class PlatformRebuildSession {
1073
1126
  return this.build(input);
1074
1127
  const key = this.key(input);
1075
1128
  let verifyInitial;
1076
- let target = this.targets.get(key);
1077
- if (!target) {
1078
- target = this.build(input, (check) => { verifyInitial = check; });
1079
- this.targets.set(key, target);
1129
+ let prepared = this.targets.get(key);
1130
+ if (!prepared) {
1131
+ const baselineChecks = [];
1132
+ const result = this.build(input, (check) => { verifyInitial = check; }, input.afterGroupRender ? baselineChecks : undefined);
1133
+ prepared = { result, baselineChecks };
1134
+ this.targets.set(key, prepared);
1080
1135
  }
1081
- // A writable build or cached-target verification ends ordinary sharing,
1082
- // before any renderer, plan verification or mutation can consume it.
1083
- if (this.context.nativeObservationBatch)
1084
- this.closedObservationBatch = this.context.nativeObservationBatch;
1085
- const result = await target;
1086
- if (verifyInitial)
1087
- await verifyInitial();
1136
+ const rejected = (error) => {
1137
+ this.rejectedTargets.add(key);
1138
+ throw error;
1139
+ };
1140
+ const target = await prepared.result.catch(rejected);
1141
+ const { baselineChecks } = prepared;
1142
+ const verify = async () => {
1143
+ const batch = this.rejectedTargets.has(key) ? undefined : input.observationBatch ?? this.context.nativeObservationBatch;
1144
+ const epoch = batch?.writeEpoch;
1145
+ for (const check of [...baselineChecks])
1146
+ await check(batch);
1147
+ if (verifyInitial)
1148
+ await verifyInitial();
1149
+ else
1150
+ await target.platformDeployment?.verify(batch);
1151
+ baselineChecks.length = 0;
1152
+ if (batch && epoch !== undefined)
1153
+ this.sealedEpochs.set(target, { batch, epoch });
1154
+ };
1155
+ if (input.afterGroupRender)
1156
+ input.afterGroupRender(() => verify().catch(rejected));
1088
1157
  else
1089
- await result.platformDeployment?.verify(input.observationBatch);
1090
- return result;
1158
+ await verify().catch(rejected);
1159
+ return target;
1091
1160
  }
1092
1161
  prepareRawUnit(key, requestFor) {
1093
1162
  let result = this.rawUnits.get(key);
@@ -1118,17 +1187,17 @@ export class PlatformRebuildSession {
1118
1187
  });
1119
1188
  return result.prepared;
1120
1189
  }
1121
- async build(input, receiveInitialVerifier) {
1122
- const { command: pluginCommand, scripts } = input.plugin.manifest;
1123
- const cursorPreviewBatch = input.platform === 'cursor'
1124
- && this.context.nativeObservationBatch?.initialInstallPreview === true
1125
- && pluginCommand?.mode !== 'dynamic' && !scripts?.artifacts?.render && !scripts?.preApply && !scripts?.node?.build
1126
- ? this.context.nativeObservationBatch : undefined;
1190
+ async build(input, receiveInitialVerifier, baselineChecks) {
1127
1191
  const confirmedCatalogRetirement = this.retirementMode(input);
1128
1192
  const ctx = readContext(this.context, input.cwd, confirmedCatalogRetirement);
1129
- const ordinaryCtx = confirmedCatalogRetirement ? ctx : input.readOnlyInspectionPlan && input.observationBatch ? { ...ctx, ...input.observationBatch }
1130
- : this.ordinaryReadContext(ctx, input.platform);
1131
1193
  const resolution = await this.resolve(input);
1194
+ const captured = baselineChecks ? await resolution.ordinaryEvidence?.captured : undefined;
1195
+ const ordinaryCtx = captured ? ctx : this.readWindow(input, 'ordinary', ctx);
1196
+ const lockedBatch = () => !confirmedCatalogRetirement && !this.rejectedTargets.has(this.key(input))
1197
+ && this.context.nativeObservationBatch?.phase === 'locked-execution' ? this.context.nativeObservationBatch : undefined;
1198
+ // Resolve the execution window at each read, never retain a query session
1199
+ // across an observed host mutation.
1200
+ const executionRead = () => lockedBatch()?.readContextFor(input.platform, 'execution', { ...ctx, codexManager: this.context.codexManager }) ?? ctx;
1132
1201
  if (!resolution.bindings.length)
1133
1202
  throw Object.assign(new Error(`platformUnavailable: ${resolution.exclusions.map((item) => item.reasonCode).join(', ') || input.platform}`), { deploymentExclusions: this.exclusions.get(this.key(input)) ?? [] });
1134
1203
  const adapter = this.adapterFor(input.platform);
@@ -1138,8 +1207,14 @@ export class PlatformRebuildSession {
1138
1207
  });
1139
1208
  this.contexts.add(ctx);
1140
1209
  const observed = await Promise.all(resolution.bindings.map(async (binding) => ({ binding,
1141
- observation: await adapter.inspect(ordinaryCtx, binding), layout: await getDeploymentLayout(ctx, binding) })));
1210
+ observation: captured ? structuredClone(captured.observations.get(binding.id)) : await adapter.inspect(ordinaryCtx, binding),
1211
+ layout: await getDeploymentLayout(ctx, binding) })));
1142
1212
  const { ordinaryEvidence } = resolution;
1213
+ // A group freezes local input bytes at each target's usual point. Recheck the
1214
+ // host independently after its last opaque renderer, then check the full seal.
1215
+ const groupDiscovery = baselineChecks && ordinaryEvidence && operation(input) === 'ensure'
1216
+ ? captured?.discovery ?? await adapter.discover(ordinaryCtx) : undefined;
1217
+ const combinedPostRenderSeal = !!groupDiscovery && input.combinePostRenderSeal === true && lockedBatch() !== undefined;
1143
1218
  if (ordinaryEvidence && (ordinaryCtx.nativeQuerySession || !input.readOnlyInspectionPlan)) {
1144
1219
  // Keep the first observation used for placement, including for targets
1145
1220
  // built after the observation batch has already ended.
@@ -1199,7 +1274,8 @@ export class PlatformRebuildSession {
1199
1274
  const config = await resolveArtifactRenderConfig({ ...sourceIdentity(input), logicalIdentity: input.plugin.catalogLogicalIdentity,
1200
1275
  pluginName: input.plugin.manifest.name, manifest: input.plugin.manifest, platform: input.platform,
1201
1276
  scope: unit.renderScope.kind, cwd: unit.renderScope.kind === 'project' ? unit.renderScope.projectRoot : input.cwd,
1202
- env: this.context.env, referencePlugins: this.context.referencePlugins });
1277
+ env: this.context.env, referencePlugins: this.context.referencePlugins,
1278
+ catalogReadScope: this.context.catalogReadScope });
1203
1279
  const staticResourceRoot = await resolveStaticPlatformResourceRoot(input.plugin.rootDir, input.platform);
1204
1280
  const grokRoleUnit = input.platform === 'grok' && unit.output === 'supplement'
1205
1281
  ? bindingEntry.layout.renderUnits.find((candidate) => candidate.output === 'package'
@@ -1208,7 +1284,11 @@ export class PlatformRebuildSession {
1208
1284
  renderScope: unit.renderScope.kind, kinds: unit.kinds, capabilities, config, cwd: input.cwd,
1209
1285
  hasInstructionAgentRecipients: grokRoleUnit && rawUnits.get(grokRoleUnit.id)?.prepared.expected.components.some(({ kind }) => kind === 'agent'),
1210
1286
  commandEnv: this.context.env, signal: this.context.signal, scriptTimeoutMs: this.context.scriptTimeoutMs,
1211
- preparedResults: this.context.preparedArtifactRenderResults };
1287
+ preparedResults: this.context.preparedArtifactRenderResults,
1288
+ onScriptExecuted: () => {
1289
+ (input.observationBatch ?? this.context.nativeObservationBatch)?.invalidateAll();
1290
+ this.context.catalogReadScope?.invalidateBundleReads();
1291
+ } };
1212
1292
  });
1213
1293
  rawUnits.set(unit.id, { unit: commonUnit, ...raw });
1214
1294
  }
@@ -1225,7 +1305,7 @@ export class PlatformRebuildSession {
1225
1305
  platform: input.platform, renderUnit: unit, prepared: raw.prepared, agentBinding: skillAgentBinding(raw, peers, extraAgents),
1226
1306
  skillWorkRoot: path.join(await this.root(), artifactValueDigest(unit.physicalKey).slice(7), 'skills'),
1227
1307
  cwd: input.cwd, env: this.context.env, signal: this.context.signal, scriptTimeoutMs: this.context.scriptTimeoutMs,
1228
- commandRecord: input.commandRecord });
1308
+ commandRecord: input.commandRecord, onScriptExecuted: raw.request.onScriptExecuted });
1229
1309
  return { unit, prepared: finalized.prepared, finalized, evidenceInput: { renderUnit: unit, capabilities, config } };
1230
1310
  })();
1231
1311
  this.units.set(unit.physicalKey, promise);
@@ -1324,8 +1404,8 @@ export class PlatformRebuildSession {
1324
1404
  const inspected = await inspectOwnedComponents({ components, executor: this.ownership });
1325
1405
  const managedCommandReview = await captureManagedCommandReviewEvidence({ binding: entry.binding,
1326
1406
  renderUnits: entry.layout.renderUnits, inactivePermissions: units.flatMap((unit) => unit.finalized.invocationPolicy.inactivePermissions), projections });
1327
- const currentMutable = async (batch) => {
1328
- const observation = await adapter.inspect(batch && !confirmedCatalogRetirement ? { ...ctx, ...batch } : ctx, entry.binding);
1407
+ const currentMutable = async (observationCtx = ctx, captured) => {
1408
+ const observation = captured ?? await adapter.inspect(observationCtx, entry.binding);
1329
1409
  return { observation, references: await sharedReferences(this.context, entry.binding, observation, entry.layout),
1330
1410
  paths: await Promise.all(components.map(async (component) => {
1331
1411
  if ('path' in component)
@@ -1342,17 +1422,18 @@ export class PlatformRebuildSession {
1342
1422
  })) };
1343
1423
  };
1344
1424
  const shadowedUser = operation(input) === 'ensure' ? await grokUserBehindProject(ctx, entry.binding, entry.observation) : undefined;
1345
- const fingerprintParts = async (discovery) => ({
1425
+ const fingerprintParts = async (discovery, observationCtx = ctx) => ({
1346
1426
  confirmedCatalogRetirement: this.retirementMode(input),
1347
1427
  ...(shadowedUser && { grokUserContent: await grokUserContentDigest(shadowedUser) }),
1348
1428
  managedCommandReview,
1349
1429
  source: removing ? null : await pathEvidence(input.plugin.rootDir),
1350
- 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),
1430
+ 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(observationCtx),
1351
1431
  sharedReferenceView: this.context.sharedReferenceView,
1352
1432
  layout: await getDeploymentLayout(ctx, entry.binding),
1353
1433
  config: await Promise.all(units.map((unit) => resolveArtifactRenderConfig({ ...sourceIdentity(input), pluginName: input.plugin.manifest.name,
1354
1434
  logicalIdentity: input.plugin.catalogLogicalIdentity, manifest: input.plugin.manifest, platform: input.platform,
1355
- scope: unit.unit.renderScope.kind, cwd: input.cwd, env: this.context.env, referencePlugins: this.context.referencePlugins }))),
1435
+ scope: unit.unit.renderScope.kind, cwd: input.cwd, env: this.context.env, referencePlugins: this.context.referencePlugins,
1436
+ catalogReadScope: this.context.catalogReadScope }))),
1356
1437
  staging: await Promise.all(projections.map(async (projection) => ({
1357
1438
  bundle: projection.bundle ? await pathEvidence(projection.bundle.stagingRoot) : null,
1358
1439
  supplements: await Promise.all(projection.supplements.map((contribution) => pathEvidence(contribution.stagingPath))),
@@ -1361,11 +1442,13 @@ export class PlatformRebuildSession {
1361
1442
  // Discovery and inspection are independent reads for these routes. Settle
1362
1443
  // both before comparing or throwing, while preserving immutable priority.
1363
1444
  const parallelNativeReads = ['copilot-marketplace', 'pi-package'].includes(entry.binding.route);
1364
- const initialReads = parallelNativeReads
1365
- ? await Promise.allSettled([fingerprintParts(), currentMutable()]) : null;
1445
+ const baseline = groupDiscovery ? ordinaryCtx : this.readWindow(input, 'baseline', ctx);
1446
+ const readParts = () => fingerprintParts(groupDiscovery && { value: groupDiscovery }, baseline);
1447
+ const readMutable = () => currentMutable(baseline, groupDiscovery && entry.observation);
1448
+ const initialReads = parallelNativeReads ? await Promise.allSettled([readParts(), readMutable()]) : null;
1366
1449
  if (initialReads?.[0].status === 'rejected')
1367
1450
  throw initialReads[0].reason;
1368
- const initialParts = initialReads?.[0].status === 'fulfilled' ? initialReads[0].value : await fingerprintParts();
1451
+ const initialParts = initialReads?.[0].status === 'fulfilled' ? initialReads[0].value : await readParts();
1369
1452
  if (shadowedUser && initialParts.grokUserContent) {
1370
1453
  shadowedUsers.set(entry.binding.id, { ...shadowedUser, contentDigest: initialParts.grokUserContent });
1371
1454
  }
@@ -1373,14 +1456,23 @@ export class PlatformRebuildSession {
1373
1456
  throw new Error('operationPlanStale: client discovery changed after the ordinary observation.');
1374
1457
  }
1375
1458
  const initial = artifactValueDigest(initialParts);
1376
- const fingerprint = async (discovery) => artifactValueDigest(await fingerprintParts(discovery));
1377
1459
  if (initialReads?.[1].status === 'rejected')
1378
1460
  throw initialReads[1].reason;
1379
- let mutableBaseline = initialReads?.[1].status === 'fulfilled' ? initialReads[1].value : await currentMutable();
1461
+ let mutableBaseline = initialReads?.[1].status === 'fulfilled' ? initialReads[1].value : await readMutable();
1380
1462
  const ordinaryObservation = ordinaryEvidence?.observations.get(entry.binding.id);
1381
1463
  if (ordinaryObservation !== undefined && ordinaryObservation !== artifactValueDigest(mutableBaseline.observation)) {
1382
1464
  throw new Error('operationPlanStale: deployment evidence changed after the ordinary observation.');
1383
1465
  }
1466
+ if (groupDiscovery && baselineChecks && !combinedPostRenderSeal)
1467
+ baselineChecks.push(async (batch) => {
1468
+ const fresh = batch?.readContextFor(input.platform, 'baseline', ctx) ?? ctx;
1469
+ if (artifactValueDigest(await adapter.discover(fresh)) !== ordinaryEvidence.discovery) {
1470
+ throw new Error('operationPlanStale: client discovery changed after the ordinary observation.');
1471
+ }
1472
+ if (artifactValueDigest(await adapter.inspect(fresh, entry.binding)) !== ordinaryObservation) {
1473
+ throw new Error('operationPlanStale: deployment evidence changed after the ordinary observation.');
1474
+ }
1475
+ });
1384
1476
  const preparationObservation = confirmedCatalogRetirement || entry.binding.route === 'antigravity-cli' || antigravityProject
1385
1477
  ? mutableBaseline.observation : entry.observation;
1386
1478
  const piInventoryKey = piProjectInventoryKey(entry.binding, entry.layout.activationPath);
@@ -1626,18 +1718,25 @@ export class PlatformRebuildSession {
1626
1718
  prerequisites: { ...mutableBaseline.observation.prerequisites, nativeSources: normalizedBefore } };
1627
1719
  return artifactValueDigest({ ...current, observation }) === artifactValueDigest({ ...mutableBaseline, observation: baselineObservation });
1628
1720
  };
1629
- const check = async (discovery, batch) => {
1630
- const reads = parallelNativeReads ? await Promise.allSettled([fingerprintParts(discovery), currentMutable(batch)]) : null;
1721
+ const check = async (discovery, batch, kind = 'seal') => {
1722
+ const seal = batch && !confirmedCatalogRetirement ? batch.readContextFor(input.platform, kind, ctx) : ctx;
1723
+ const reads = parallelNativeReads ? await Promise.allSettled([fingerprintParts(discovery, seal), currentMutable(seal)]) : null;
1631
1724
  if (reads?.[0].status === 'rejected')
1632
1725
  throw reads[0].reason;
1633
- const parts = reads?.[0].status === 'fulfilled' ? reads[0].value : await fingerprintParts(discovery);
1726
+ const parts = reads?.[0].status === 'fulfilled' ? reads[0].value : await fingerprintParts(discovery, seal);
1634
1727
  if (artifactValueDigest(parts) !== initial) {
1635
1728
  return artifactValueDigest(parts.discovery) !== artifactValueDigest(initialParts.discovery)
1636
1729
  ? 'clientDiscoveryChanged' : 'deploymentInputsChanged';
1637
1730
  }
1638
1731
  if (reads?.[1].status === 'rejected')
1639
1732
  throw reads[1].reason;
1640
- const current = reads?.[1].status === 'fulfilled' ? reads[1].value : await currentMutable(batch);
1733
+ const current = reads?.[1].status === 'fulfilled' ? reads[1].value : await currentMutable(seal);
1734
+ // For the collapsed group, the final seal runs both original host
1735
+ // comparisons against the same fresh post-render observation. The
1736
+ // subsequent execution/write window remains independently observed.
1737
+ if (combinedPostRenderSeal && kind === 'seal' && ordinaryObservation !== artifactValueDigest(current.observation)) {
1738
+ return 'deploymentObservationChanged';
1739
+ }
1641
1740
  if (parallelNativeReads ? matchesMutable(current) : await matchesAfterGrokPublications(current))
1642
1741
  return true;
1643
1742
  if (current.references !== mutableBaseline.references)
@@ -1646,20 +1745,19 @@ export class PlatformRebuildSession {
1646
1745
  return 'deploymentPathsChanged';
1647
1746
  return 'deploymentObservationChanged';
1648
1747
  };
1649
- checks.set(entry.binding.id, (batch) => check(undefined, batch));
1650
- if (resolution.bindings.length === 1 && (entry.binding.route === 'pi-package'
1651
- || cursorPreviewBatch && entry.binding.route === 'cursor-workspace-hook')) {
1748
+ checks.set(entry.binding.id, (batch, kind) => check(undefined, batch, kind));
1749
+ if (!this.context.nativeObservationBatch && !input.observationBatch && resolution.bindings.length === 1 && entry.binding.route === 'pi-package') {
1652
1750
  initialDiscoveryCheck = () => check({ value: initialParts.discovery });
1653
1751
  }
1654
1752
  this.mutableChecks.set(entry.binding.id, { physicalKey: entry.binding.physicalKey,
1655
1753
  marketplaceRoot: entry.layout.marketplaceRoot, sourceId: entry.binding.plugin.sourceId,
1656
1754
  sourceIdentity: entry.binding.plugin.sourceIdentity,
1657
1755
  assertStable: async () => {
1658
- if (await checks.get(entry.binding.id)() !== true)
1756
+ if (await checks.get(entry.binding.id)(lockedBatch(), 'execution') !== true)
1659
1757
  throw new Error('operationPlanStale: deployment evidence changed before source registration.');
1660
1758
  },
1661
1759
  acceptMarketplaceRegistration: async () => {
1662
- const current = await currentMutable();
1760
+ const current = await currentMutable(executionRead());
1663
1761
  if (artifactValueDigest(current) === artifactValueDigest(mutableBaseline))
1664
1762
  return;
1665
1763
  const withoutRegistration = { ...current, observation: { ...current.observation,
@@ -1674,7 +1772,7 @@ export class PlatformRebuildSession {
1674
1772
  && artifactValueDigest({ ...withoutRegistration, observation: { ...withoutRegistration.observation,
1675
1773
  configuration: { ...current.observation.configuration, marketplace: mutableBaseline.observation.configuration.marketplace },
1676
1774
  } }) === artifactValueDigest(mutableBaseline);
1677
- if ((!onlyRegistration && !onlyMarketplace) || await fingerprint() !== initial) {
1775
+ if ((!onlyRegistration && !onlyMarketplace) || artifactValueDigest(await fingerprintParts(undefined, executionRead())) !== initial) {
1678
1776
  throw new Error('operationPlanStale: deployment evidence changed during source registration.');
1679
1777
  }
1680
1778
  // This is the one shared observation changed by our confirmed source
@@ -1683,10 +1781,10 @@ export class PlatformRebuildSession {
1683
1781
  },
1684
1782
  rebase: async (writtenFiles) => {
1685
1783
  const reads = parallelNativeReads
1686
- ? await Promise.allSettled([fingerprintParts(), currentMutable()]) : null;
1784
+ ? await Promise.allSettled([fingerprintParts(undefined, executionRead()), currentMutable(executionRead())]) : null;
1687
1785
  if (reads?.[0].status === 'rejected')
1688
1786
  throw reads[0].reason;
1689
- const current = reads?.[0].status === 'fulfilled' ? reads[0].value : await fingerprintParts();
1787
+ const current = reads?.[0].status === 'fulfilled' ? reads[0].value : await fingerprintParts(undefined, executionRead());
1690
1788
  if (artifactValueDigest(current) !== initial) {
1691
1789
  const changed = Object.keys(initialParts)
1692
1790
  .filter((key) => artifactValueDigest(current[key]) !== artifactValueDigest(initialParts[key]));
@@ -1694,7 +1792,7 @@ export class PlatformRebuildSession {
1694
1792
  }
1695
1793
  if (reads?.[1].status === 'rejected')
1696
1794
  throw reads[1].reason;
1697
- const mutable = reads?.[1].status === 'fulfilled' ? reads[1].value : await currentMutable();
1795
+ const mutable = reads?.[1].status === 'fulfilled' ? reads[1].value : await currentMutable(executionRead());
1698
1796
  mutableBaseline = mutable;
1699
1797
  // The same rebase already hashes the exact paths. Match the owner's
1700
1798
  // header and the desired bytes without opening each file again.
@@ -1770,7 +1868,8 @@ export class PlatformRebuildSession {
1770
1868
  && (!complete || evidence.sharedReferences !== 'none' || preparationObservation.ownership !== 'aw'));
1771
1869
  }
1772
1870
  if (!removing) {
1773
- const inputEvidence = await createPlatformInputEvidence({ plugin: input.plugin, commandRoutes: input.commandRecord?.routes, binding: entry.binding, units: units.map((unit) => unit.evidenceInput) });
1871
+ const inputEvidence = await createPlatformInputEvidence({ plugin: input.plugin, commandRoutes: input.commandRecord?.routes, binding: entry.binding,
1872
+ units: units.map((unit) => unit.evidenceInput), catalogReadScope: this.context.catalogReadScope });
1774
1873
  const packageComponents = projections.find((projection) => projection.bundle)?.components;
1775
1874
  inputDigests.set(entry.binding.id, platformPackageInputDigest(inputEvidence, packageComponents));
1776
1875
  if (expected.unmet.every(isDeliveryCapabilityGap)) {
@@ -1811,21 +1910,93 @@ export class PlatformRebuildSession {
1811
1910
  }
1812
1911
  target.ownedComponents = plans.flatMap((plan) => plan.evidence.ownership.map((item) => item.component));
1813
1912
  target.desiredOwnedComponents = target.ownedComponents;
1814
- const verifyChecks = async (selected, batch) => {
1913
+ const verifyChecks = async (selected, batch, kind = 'seal') => {
1815
1914
  for (const check of selected)
1816
- if (await check(batch) !== true)
1915
+ if (await check(batch, kind) !== true)
1817
1916
  throw new Error('operationPlanStale: deployment evidence changed.');
1818
1917
  for (const plan of plans)
1819
1918
  if (!await this.verifyMarketplace(plan))
1820
1919
  throw new Error('operationPlanStale: marketplace evidence changed.');
1821
1920
  };
1822
- const verify = (batch) => verifyChecks(checks.values(), batch);
1921
+ const lockedNoEffects = () => this.context.nativeObservationBatch?.phase === 'locked-execution'
1922
+ && deployments.length > 0 && !blockedReceipts.length && deployments.every(({ plan }) => plan.operation === 'ensure' && !plan.effects.length);
1923
+ let executionVerification;
1924
+ let noWriteSettlement;
1925
+ const currentVerification = (proof) => !!proof && proof.batch === lockedBatch()
1926
+ && proof.epoch === proof.batch.writeEpoch && proof.session === executionRead().nativeQuerySession;
1927
+ const verify = async (batch) => {
1928
+ executionVerification = undefined;
1929
+ const locked = batch ?? lockedBatch();
1930
+ const writesOutsideDriver = hasPlannedPreApply(target) || target.operationActions?.some((action) => action.kind === 'syncManagedCommandPackage' && !action.keepRevision || action.kind === 'removeManagedCommandPackage');
1931
+ if (!batch && locked && writesOutsideDriver) {
1932
+ // Keep the independent F1 gate before every possible package write.
1933
+ locked.refreshExecutionInspection(input.platform);
1934
+ }
1935
+ const kind = !batch && locked ? 'execution' : 'seal';
1936
+ const proof = kind === 'execution' && locked ? {
1937
+ batch: locked, epoch: locked.writeEpoch, session: executionRead().nativeQuerySession,
1938
+ } : undefined;
1939
+ await verifyChecks(checks.values(), locked, kind);
1940
+ if (currentVerification(proof))
1941
+ executionVerification = proof;
1942
+ };
1943
+ const canSettleWithoutWrites = async (managedCommandsApplied = false) => {
1944
+ if (!lockedNoEffects() || !target.operationActions || target.operationActions.some((action) => !managedCommandsApplied || action.kind !== 'syncManagedCommandPackage'))
1945
+ return false;
1946
+ for (const { plan, driverState } of deployments) {
1947
+ const { binding, evidence } = plan;
1948
+ const before = driverState.before;
1949
+ if (evidence.retainPackage || evidence.permissionOwnershipWarning || driverState.retainedPaths.length
1950
+ || before.ownership === 'unknown' || before.ownership === 'foreign'
1951
+ || plan.expected.components.some((component) => !before.components.some(({ id, presence, reasonCodes }) => id === component.id && presence === 'present' && !reasonCodes.length))
1952
+ || before.diagnostics.length || plan.projections.some(({ diagnostics }) => diagnostics.length)
1953
+ || !plan.expected.unmet.every(isDeliveryCapabilityGap)
1954
+ || evidence.ownership.some(({ state }) => !['absent', 'present'].includes(state)))
1955
+ return false;
1956
+ const empty = gapStates.get(binding.id) ?? emptyStates.get(binding.id);
1957
+ if (empty && !await matchesPlatformEmptyState({ state: empty, env: this.context.env }))
1958
+ return false;
1959
+ if (!plan.expected.components.length && (!empty || before.package !== 'absent'
1960
+ || !['absent', 'not-applicable'].includes(before.registration)
1961
+ || evidence.ownership.some(({ state }) => state !== 'absent')))
1962
+ return false;
1963
+ const supplementDigest = supplementInputDigests.get(binding.id);
1964
+ if (supplementDigest) {
1965
+ const supplement = await inspectPlatformSupplementState(ctx, binding, supplementDigest);
1966
+ const files = componentSupplementFiles(plan);
1967
+ if (!supplement?.inputMatches || supplement.components.length !== files.length
1968
+ || files.some((file) => !supplement.components.some(({ id, presence, reasonCodes }) => id === file.id && presence === 'present' && !reasonCodes.length)))
1969
+ return false;
1970
+ }
1971
+ const bundle = driverState.bundle;
1972
+ if (bundle) {
1973
+ const owner = driverState.packageComponent;
1974
+ if (!evidence.contentMatches || owner?.kind !== 'owned-directory'
1975
+ || !packageDeliveryConfirmed(binding, before, bundle.contentDigest, requireIndependentActivation))
1976
+ return false;
1977
+ const marker = await readSkillOwnerMarker({ skillRoot: owner.path, allowedRoot: owner.allowedRoot, expectedIdentity: owner.identity });
1978
+ const projection = marker?.nativeProjection;
1979
+ if (!projection || projection.inputDigest !== inputDigests.get(binding.id) || projection.contentDigest !== bundle.contentDigest
1980
+ || projection.preparation !== 'complete' || projection.piExtensionDigest !== bundle.piExtensionDigest
1981
+ || artifactValueDigest(projection.components) !== artifactValueDigest(plan.projections.filter((item) => item.bundle).flatMap((item) => item.components))
1982
+ || artifactValueDigest(projection.physicalIdentity) !== artifactValueDigest((await getDeploymentLayout(ctx, binding)).physicalIdentity))
1983
+ return false;
1984
+ }
1985
+ }
1986
+ return true;
1987
+ };
1823
1988
  const canVerifyAtExecution = () => {
1824
1989
  const prepared = deployments[0];
1825
1990
  if (!prepared || deployments.length !== 1 || plans.length !== 1 || plans[0] !== prepared.plan || blockedReceipts.length
1826
1991
  || target.operationActions === undefined || target.operationActions.some((action) => action.kind === 'runPreApply' || action.kind === 'syncManagedCommandPackage' || action.kind === 'removeManagedCommandPackage'))
1827
1992
  return false;
1828
1993
  const { plan, driverState } = prepared;
1994
+ // Codex's lifecycle returns per-effect diagnostics from its own fresh
1995
+ // evidence check. With no preceding script or package action, this is
1996
+ // the first writer and the only execution preflight it needs.
1997
+ if (lockedBatch() && plan.binding.platform === 'codex' && plan.effects.length
1998
+ && (plan.operation === 'ensure' || plan.operation === 'reinstall'))
1999
+ return true;
1829
2000
  const hiddenEmptyPiProject = piProjectRegistrationHidden(plan.binding, driverState.before)
1830
2001
  && driverState.before.package === 'absent' && driverState.before.ownership === 'absent'
1831
2002
  && plan.evidence.sharedReferences === 'none' && plan.evidence.ownership.every((item) => item.state === 'absent')
@@ -1834,7 +2005,7 @@ export class PlatformRebuildSession {
1834
2005
  const isBuiltinCursorWorkspaceHook = (effect) => effect.kind === 'write-supplement'
1835
2006
  && plan.binding.route === 'cursor-workspace-hook'
1836
2007
  && driverState.contributions.some((entry) => entry.effectId === effect.id && entry.contribution.id === 'cursor-workspace-open');
1837
- return plan.operation === 'ensure' && (checkedBatch || ['copilot-marketplace', 'pi-package'].includes(plan.binding.route))
2008
+ return plan.operation === 'ensure' && (!lockedBatch() || plan.effects.length > 0) && (checkedBatch || ['copilot-marketplace', 'pi-package'].includes(plan.binding.route))
1838
2009
  && plan.binding.platform === target.identity.platform && plan.expected.components.length > 0 && plan.expected.unmet.every(isDeliveryCapabilityGap)
1839
2010
  && driverState.before.package !== 'unknown' && (driverState.before.registration !== 'unknown' || hiddenEmptyPiProject)
1840
2011
  && ['absent', 'aw', 'shared'].includes(driverState.before.ownership)
@@ -1862,8 +2033,9 @@ export class PlatformRebuildSession {
1862
2033
  stagedPackage = undefined;
1863
2034
  },
1864
2035
  } : undefined;
1865
- target.platformDeployment = { deployments, plans, blockedReceipts, cleanupResults, privatePackage,
1866
- canVerifyAtExecution,
2036
+ target.platformDeployment = { deployments, plans, blockedReceipts, cleanupResults, privatePackage, combinedPostRenderSeal,
2037
+ canVerifyAtExecution, canSettleWithoutWrites: () => canSettleWithoutWrites(),
2038
+ hasCurrentNoWriteSettlement: () => currentVerification(noWriteSettlement),
1867
2039
  verify,
1868
2040
  postcheck: async (receipts, options) => {
1869
2041
  let incomplete = false;
@@ -1873,7 +2045,7 @@ export class PlatformRebuildSession {
1873
2045
  const receipt = receipts.find((entry) => entry.bindingId === plan.binding.id);
1874
2046
  if (!receipt || options?.deliveredSkillsOnly && plan.evidence.retainPackage)
1875
2047
  continue;
1876
- const after = options?.refresh ? await adapter.inspect(ctx, plan.binding) : receipt.after;
2048
+ const after = options?.refresh ? await adapter.inspect(executionRead(), plan.binding) : receipt.after;
1877
2049
  const supplementFiles = componentSupplementFiles(plan);
1878
2050
  const supplementIds = new Set(supplementFiles.flatMap((contribution) => contribution.componentIds));
1879
2051
  if (!options?.deliveredSkillsOnly) {
@@ -1987,16 +2159,40 @@ export class PlatformRebuildSession {
1987
2159
  throw new Error('deploymentPostcheckFailed: the final observation does not confirm the requested deployment.');
1988
2160
  },
1989
2161
  execute: async (options) => {
2162
+ noWriteSettlement = undefined;
1990
2163
  let verifiedPlan;
1991
- if (options?.verifyBeforeExecution) {
2164
+ if (options && 'verifyBeforeExecution' in options) {
1992
2165
  if (!canVerifyAtExecution())
1993
2166
  throw new Error('deploymentExecutionVerificationUnsupported');
1994
2167
  // Keep failures outside the lifecycle catch so the caller retains its
1995
2168
  // preflight error classification. Only this call can consume success.
1996
- await verify();
1997
- verifiedPlan = deployments[0].plan;
2169
+ if (input.platform !== 'codex') {
2170
+ lockedBatch()?.refreshExecutionInspection(input.platform);
2171
+ await verifyChecks(checks.values(), lockedBatch(), 'execution');
2172
+ verifiedPlan = deployments[0].plan;
2173
+ }
1998
2174
  }
1999
2175
  cleanupResults.length = 0;
2176
+ // executeRebuildOperation publishes the reviewed managed command
2177
+ // package before invoking this host driver. The outer keep shortcut
2178
+ // cannot accept those actions; only this host-only settlement can.
2179
+ const managedCommandsApplied = options !== undefined && 'managedCommandsApplied' in options;
2180
+ if (await canSettleWithoutWrites(managedCommandsApplied)) {
2181
+ // Only a User command-package action may bridge these reads. It
2182
+ // changes AW_HOME, not the host. Project settlement still has to
2183
+ // confirm its own activation after a provider in User was updated.
2184
+ const commandOnly = input.scope === 'user' && managedCommandsApplied
2185
+ && target.operationActions?.some((action) => action.kind === 'syncManagedCommandPackage');
2186
+ if (!commandOnly || !currentVerification(executionVerification))
2187
+ await verify();
2188
+ if (commandOnly)
2189
+ noWriteSettlement = executionVerification;
2190
+ return deployments.map(({ plan, driverState }) => ({
2191
+ bindingId: plan.binding.id, effects: [], after: structuredClone(driverState.before),
2192
+ unmet: plan.expected.unmet.map((gap) => ({ ...gap, productIds: plan.binding.consumers.map(({ id }) => id) })),
2193
+ reload: 'none', diagnostics: [],
2194
+ }));
2195
+ }
2000
2196
  const receipts = [...blockedReceipts];
2001
2197
  for (const prepared of deployments) {
2002
2198
  const batch = prepared.plan.evidence.permissionBatch;
@@ -2012,10 +2208,13 @@ export class PlatformRebuildSession {
2012
2208
  let receipt;
2013
2209
  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
2014
2210
  && check.sourceId === prepared.plan.binding.plugin.sourceId && check.sourceIdentity === prepared.plan.binding.plugin.sourceIdentity) : [];
2015
- const nativeServices = createNativeLifecycleServices(ctx, prepared.plan.evidence, peers.length ? async () => {
2211
+ const onMutation = (scope) => {
2212
+ this.context.nativeObservationBatch?.invalidatePlatform(input.platform, scope);
2213
+ };
2214
+ const nativeServices = () => createNativeLifecycleServices(executionRead(), prepared.plan.evidence, peers.length ? async () => {
2016
2215
  for (const peer of peers)
2017
2216
  await peer.assertStable();
2018
- } : undefined);
2217
+ } : undefined, () => onMutation('inspect'));
2019
2218
  const grokDisablePackage = prepared.plan.binding.route === 'grok-cli'
2020
2219
  && ['remove', 'cleanup'].includes(prepared.plan.operation)
2021
2220
  && prepared.plan.effects.some((effect) => effect.kind === 'deactivate')
@@ -2027,12 +2226,11 @@ export class PlatformRebuildSession {
2027
2226
  const grokDisableConfigBefore = grokDisableConfigPath ? await readOptionalUtf8(grokDisableConfigPath) : undefined;
2028
2227
  let grokDisableConfigRecorded = false;
2029
2228
  try {
2030
- receipt = await adapter.lifecycle.execute({ ...ctx, nativeEffects: this.nativeEffects, inspect: (binding) => adapter.inspect(ctx, binding), services: {
2031
- ...nativeServices,
2229
+ receipt = await adapter.lifecycle.execute({ ...ctx, onMutation, nativeEffects: this.nativeEffects, inspect: (binding) => adapter.inspect(executionRead(), binding), services: {
2230
+ setActivation: (binding, identity, enabled) => nativeServices().setActivation(binding, identity, enabled),
2032
2231
  registerMarketplace: async (binding, identity) => {
2033
- const outcome = await nativeServices.registerMarketplace(binding, identity);
2232
+ const outcome = await nativeServices().registerMarketplace(binding, identity);
2034
2233
  if (outcome.mutation === 'confirmed') {
2035
- ctx.codexObservationSession?.invalidate(prepared.plan.evidence.layout.marketplaceName ?? undefined);
2036
2234
  for (const peer of peers)
2037
2235
  await peer.acceptMarketplaceRegistration();
2038
2236
  }
@@ -2043,7 +2241,8 @@ export class PlatformRebuildSession {
2043
2241
  verifiedPlan = undefined;
2044
2242
  if (verified)
2045
2243
  return true;
2046
- const evidence = await checks.get(plan.binding.id)();
2244
+ lockedBatch()?.refreshExecutionInspection(input.platform);
2245
+ const evidence = await checks.get(plan.binding.id)(lockedBatch(), 'execution');
2047
2246
  if (evidence !== true)
2048
2247
  return evidence;
2049
2248
  return await this.verifyMarketplace(plan) || 'marketplaceChanged';
@@ -2087,7 +2286,7 @@ export class PlatformRebuildSession {
2087
2286
  }
2088
2287
  else if (component.kind === 'shared-config' && component.locator.kind === 'host-permissions') {
2089
2288
  const locator = component.locator;
2090
- 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);
2289
+ const changed = await updateHostPermissions(ctx, locator, await jsonObject(contribution.stagingPath), (previous, current, target = locator.settingsPath, host) => this.recordPermissionWrite(locator.platform, target, previous, current, locator.platform === 'grok' ? host : undefined), batch, (notices) => appliedPermissionNotices.push(...notices), undefined, relatedProjectBatch);
2091
2290
  return { mutation: changed ? 'confirmed' : 'none', changed };
2092
2291
  }
2093
2292
  else if (component.kind === 'shared-config' && component.locator.kind === 'claude-permissions') {
@@ -2136,7 +2335,7 @@ export class PlatformRebuildSession {
2136
2335
  grokDisableConfigRecorded = true;
2137
2336
  }
2138
2337
  }
2139
- await updateHostPermissions(ctx, locator, undefined, (previous, current, target = locator.settingsPath, host) => this.recordPermissionWrite(target, previous, current, locator.platform === 'grok' ? host : undefined), batch, (notices) => {
2338
+ await updateHostPermissions(ctx, locator, undefined, (previous, current, target = locator.settingsPath, host) => this.recordPermissionWrite(locator.platform, target, previous, current, locator.platform === 'grok' ? host : undefined), batch, (notices) => {
2140
2339
  for (const notice of notices) {
2141
2340
  (notice.code === 'hostPermissionRestored' ? restorations : appliedPermissionNotices).push(notice);
2142
2341
  }
@@ -2160,13 +2359,14 @@ export class PlatformRebuildSession {
2160
2359
  } }, prepared);
2161
2360
  }
2162
2361
  catch (error) {
2362
+ onMutation('inspect');
2163
2363
  const diagnostic = { code: recoveryInterruptionCode(error) ?? 'platformExecutionFailed', severity: 'error',
2164
2364
  message: error instanceof Error ? error.message : String(error),
2165
2365
  subject: { target: prepared.plan.binding.platform, pluginId: prepared.plan.binding.plugin.pluginId, scope: prepared.plan.binding.scope.kind } };
2166
2366
  receipt = { bindingId: prepared.plan.binding.id, effects: prepared.plan.effects.map((effect) => ({
2167
2367
  id: effect.id, status: 'unknown', mutation: 'possible', diagnostics: [diagnostic]
2168
2368
  })),
2169
- after: await adapter.inspect(ctx, prepared.plan.binding).catch(() => prepared.driverState.before),
2369
+ after: await adapter.inspect(executionRead(), prepared.plan.binding).catch(() => prepared.driverState.before),
2170
2370
  unmet: prepared.plan.expected.unmet.map((gap) => ({ ...gap, productIds: prepared.plan.binding.consumers.map(({ id }) => id) })),
2171
2371
  reload: 'unknown', diagnostics: [diagnostic] };
2172
2372
  }
@@ -2189,6 +2389,11 @@ export class PlatformRebuildSession {
2189
2389
  try {
2190
2390
  let copilotRebase;
2191
2391
  if (receipt.effects.some((effect) => effect.mutation !== 'none')) {
2392
+ // Copilot's retained removal and marketplace-timeout recovery
2393
+ // compare two independent post-write observations.
2394
+ if (prepared.plan.binding.route === 'copilot-marketplace') {
2395
+ lockedBatch()?.refreshExecutionInspection(input.platform);
2396
+ }
2192
2397
  for (const [bindingId, check] of this.mutableChecks)
2193
2398
  if (check.physicalKey === prepared.plan.binding.physicalKey) {
2194
2399
  const { observation: fresh, verifiedSupplementIds } = await check.rebase(bindingId === receipt.bindingId ? writtenFiles : undefined);
@@ -2260,11 +2465,16 @@ export class PlatformRebuildSession {
2260
2465
  ? { piExtensionDigest: bundle.piExtensionDigest } : {}),
2261
2466
  physicalIdentity: (await getDeploymentLayout(ctx, prepared.plan.binding)).physicalIdentity };
2262
2467
  if (marker && (!marker.nativeProjection || artifactValueDigest(marker.nativeProjection) !== artifactValueDigest(projection))) {
2263
- await writeSkillOwnerMarker({ skillRoot: root, allowedRoot: packageOwner.allowedRoot, identity: packageOwner.identity, nativeProjection: projection });
2468
+ try {
2469
+ await writeSkillOwnerMarker({ skillRoot: root, allowedRoot: packageOwner.allowedRoot, identity: packageOwner.identity, nativeProjection: projection });
2470
+ }
2471
+ finally {
2472
+ onMutation('inspect');
2473
+ }
2264
2474
  for (const check of this.mutableChecks.values())
2265
2475
  if (check.physicalKey === prepared.plan.binding.physicalKey)
2266
2476
  await check.rebase();
2267
- receipt.after = await adapter.inspect(ctx, prepared.plan.binding);
2477
+ receipt.after = await adapter.inspect(executionRead(), prepared.plan.binding);
2268
2478
  }
2269
2479
  }
2270
2480
  const emptyState = gapStates.get(prepared.plan.binding.id) ?? emptyStates.get(prepared.plan.binding.id);
@@ -2308,8 +2518,7 @@ export class PlatformRebuildSession {
2308
2518
  };
2309
2519
  if (initialDiscoveryCheck) {
2310
2520
  const firstCheck = initialDiscoveryCheck;
2311
- const canReuseDiscovery = () => (cursorPreviewBatch
2312
- ? this.context.nativeObservationBatch === cursorPreviewBatch : this.targets.size === 1)
2521
+ const canReuseDiscovery = () => this.targets.size === 1
2313
2522
  && deployments.length === 1 && plans.length === 1
2314
2523
  && plans[0] === deployments[0].plan && !blockedReceipts.length && plans[0].operation === 'ensure'
2315
2524
  && plans[0].expected.components.length > 0 && !plans[0].expected.unmet.length;