@@ -150,6 +150,78 @@ describe("syncMemoryWikiBridgeSources", () => {
150150 expect ( logLines ) . toHaveLength ( 2 ) ;
151151 } ) ;
152152
153+ it ( "skips generated artifacts from its own vault" , async ( ) => {
154+ const workspaceDir = await createBridgeWorkspace ( "self-import-workspace" ) ;
155+ const vaultDir = path . join ( workspaceDir , "memory" , "wiki" ) ;
156+ const { config } = await createVault ( {
157+ rootDir : vaultDir ,
158+ config : {
159+ vaultMode : "bridge" ,
160+ bridge : {
161+ enabled : true ,
162+ readMemoryArtifacts : true ,
163+ indexDailyNotes : true ,
164+ } ,
165+ } ,
166+ } ) ;
167+
168+ const dailyNotePath = path . join ( workspaceDir , "memory" , "2026-06-22.md" ) ;
169+ const generatedSourcePath = path . join (
170+ vaultDir ,
171+ "sources" ,
172+ "bridge-workspace-remote-memory-daily-old.md" ,
173+ ) ;
174+ const generatedIndexPath = path . join ( vaultDir , "index.md" ) ;
175+ await fs . mkdir ( path . dirname ( dailyNotePath ) , { recursive : true } ) ;
176+ await fs . mkdir ( path . dirname ( generatedSourcePath ) , { recursive : true } ) ;
177+ await fs . writeFile ( dailyNotePath , "# Daily Note\n" , "utf8" ) ;
178+ await fs . writeFile ( generatedSourcePath , "# Previously Imported Source\n" , "utf8" ) ;
179+ await fs . writeFile ( generatedIndexPath , "# Generated Index\n" , "utf8" ) ;
180+
181+ registerBridgeArtifacts ( [
182+ {
183+ kind : "daily-note" ,
184+ workspaceDir,
185+ relativePath : "memory/2026-06-22.md" ,
186+ absolutePath : dailyNotePath ,
187+ agentIds : [ "main" ] ,
188+ contentType : "markdown" ,
189+ } ,
190+ {
191+ kind : "daily-note" ,
192+ workspaceDir,
193+ relativePath : "memory/wiki/sources/bridge-workspace-remote-memory-daily-old.md" ,
194+ absolutePath : generatedSourcePath ,
195+ agentIds : [ "main" ] ,
196+ contentType : "markdown" ,
197+ } ,
198+ {
199+ kind : "daily-note" ,
200+ workspaceDir,
201+ relativePath : "memory/wiki/index.md" ,
202+ absolutePath : generatedIndexPath ,
203+ agentIds : [ "main" ] ,
204+ contentType : "markdown" ,
205+ } ,
206+ ] ) ;
207+
208+ const appConfig : OpenClawConfig = {
209+ agents : {
210+ list : [ { id : "main" , default : true , workspace : workspaceDir } ] ,
211+ } ,
212+ } ;
213+
214+ const result = await syncMemoryWikiBridgeSources ( { config, appConfig } ) ;
215+
216+ expect ( result . artifactCount ) . toBe ( 1 ) ;
217+ expect ( result . importedCount ) . toBe ( 1 ) ;
218+ expect ( result . pagePaths ) . toHaveLength ( 1 ) ;
219+ expect ( result . pagePaths [ 0 ] ) . not . toContain ( "memory-wiki-sources" ) ;
220+ const sourcePages = await fs . readdir ( path . join ( vaultDir , "sources" ) ) ;
221+ expect ( sourcePages . filter ( ( name ) => name . startsWith ( "bridge-" ) ) ) . toHaveLength ( 2 ) ;
222+ expect ( sourcePages . filter ( ( name ) => name . includes ( "memory-wiki-sources-" ) ) ) . toEqual ( [ ] ) ;
223+ } ) ;
224+
153225 it ( "imports bridge artifacts from legacy providers without agent ids" , async ( ) => {
154226 const workspaceDir = await createBridgeWorkspace ( "legacy-agentids-workspace" ) ;
155227 const { rootDir : vaultDir , config } = await createVault ( {
0 commit comments