@@ -5,13 +5,19 @@ import type { OpenClawConfig } from "../config/types.openclaw.js";
55import { setCurrentPluginMetadataSnapshot } from "./current-plugin-metadata-snapshot.js" ;
66import { resolveInstalledPluginIndexPolicyHash } from "./installed-plugin-index-policy.js" ;
77import type { InstalledPluginIndex } from "./installed-plugin-index.js" ;
8+ import { loadManifestMetadataSnapshot } from "./manifest-contract-eligibility.js" ;
89import type { PluginManifestRecord } from "./manifest-registry.js" ;
910import { clearPluginMetadataLifecycleCaches } from "./plugin-metadata-lifecycle.js" ;
1011import type { PluginMetadataSnapshot } from "./plugin-metadata-snapshot.types.js" ;
11- import { loadPluginManifestRegistryForPluginRegistry } from "./plugin-registry-contributions.js" ;
12+ import {
13+ loadPluginManifestRegistryForPluginRegistry ,
14+ resolveManifestContractOwnerPluginId ,
15+ resolveManifestContractPluginIds ,
16+ } from "./plugin-registry-contributions.js" ;
1217import { loadPluginRegistrySnapshotWithMetadata } from "./plugin-registry-snapshot.js" ;
1318
1419afterEach ( ( ) => {
20+ vi . restoreAllMocks ( ) ;
1521 clearPluginMetadataLifecycleCaches ( ) ;
1622} ) ;
1723
@@ -40,7 +46,7 @@ function createManifest(id: string): PluginManifestRecord {
4046 channels : [ ] ,
4147 channelConfigs : { } ,
4248 cliBackends : [ ] ,
43- contracts : { } ,
49+ contracts : { webSearchProviders : [ ` ${ id } -search` ] } ,
4450 } as unknown as PluginManifestRecord ;
4551}
4652
@@ -95,6 +101,74 @@ function createSnapshot(params: {
95101}
96102
97103describe ( "loadPluginManifestRegistryForPluginRegistry current snapshot" , ( ) => {
104+ it ( "reuses an allowlisted published snapshot for configless manifest reads" , ( ) => {
105+ const config : OpenClawConfig = { plugins : { allow : [ "enabled" ] } } ;
106+ const env = {
107+ HOME : "/tmp/openclaw-test-home" ,
108+ OPENCLAW_DISABLE_BUNDLED_PLUGINS : "1" ,
109+ } ;
110+ const workspaceDir = "/workspace" ;
111+ const snapshot = createSnapshot ( { config, workspaceDir } ) ;
112+ setCurrentPluginMetadataSnapshot ( snapshot , { config, env, workspaceDir } ) ;
113+ const readDirectory = vi . spyOn ( fs , "readdirSync" ) ;
114+ const readFile = vi . spyOn ( fs , "readFileSync" ) ;
115+
116+ expect ( loadManifestMetadataSnapshot ( { env } ) ) . toBe ( snapshot ) ;
117+ expect ( readDirectory ) . not . toHaveBeenCalled ( ) ;
118+ expect ( readFile ) . not . toHaveBeenCalled ( ) ;
119+ } ) ;
120+
121+ it ( "projects supplied contract manifests without dropping disabled owners" , ( ) => {
122+ const config : OpenClawConfig = { plugins : { allow : [ "enabled" ] } } ;
123+ const env = {
124+ HOME : "/tmp/openclaw-test-home" ,
125+ OPENCLAW_DISABLE_BUNDLED_PLUGINS : "1" ,
126+ } ;
127+ const workspaceDir = "/workspace" ;
128+ const snapshot = createSnapshot ( { config, workspaceDir } ) ;
129+ setCurrentPluginMetadataSnapshot ( snapshot , { config, env, workspaceDir } ) ;
130+ const readDirectory = vi . spyOn ( fs , "readdirSync" ) ;
131+ const readFile = vi . spyOn ( fs , "readFileSync" ) ;
132+
133+ expect (
134+ resolveManifestContractPluginIds ( {
135+ contract : "webSearchProviders" ,
136+ config,
137+ env,
138+ workspaceDir,
139+ } ) ,
140+ ) . toEqual ( [ "disabled" , "enabled" ] ) ;
141+ expect (
142+ resolveManifestContractOwnerPluginId ( {
143+ contract : "webSearchProviders" ,
144+ value : " DISABLED-SEARCH " ,
145+ config,
146+ env,
147+ workspaceDir,
148+ } ) ,
149+ ) . toBe ( "disabled" ) ;
150+ expect (
151+ resolveManifestContractPluginIds ( {
152+ contract : "webSearchProviders" ,
153+ config : { plugins : { allow : [ "incompatible-policy" ] } } ,
154+ env,
155+ manifestRecords : snapshot . plugins ,
156+ onlyPluginIds : [ "disabled" ] ,
157+ } ) ,
158+ ) . toEqual ( [ "disabled" ] ) ;
159+ expect (
160+ resolveManifestContractOwnerPluginId ( {
161+ contract : "webSearchProviders" ,
162+ value : "disabled-search" ,
163+ config : { plugins : { allow : [ "incompatible-policy" ] } } ,
164+ env,
165+ manifestRecords : snapshot . plugins ,
166+ } ) ,
167+ ) . toBe ( "disabled" ) ;
168+ expect ( readDirectory ) . not . toHaveBeenCalled ( ) ;
169+ expect ( readFile ) . not . toHaveBeenCalled ( ) ;
170+ } ) ;
171+
98172 it ( "reuses compatible current manifest metadata" , ( ) => {
99173 const config : OpenClawConfig = { } ;
100174 const env = {
0 commit comments