@@ -345,6 +345,168 @@ describe("searchMemoryWiki", () => {
345345 expect ( results . map ( ( result ) => result . path ) ) . toEqual ( [ "entities/needle-person.md" ] ) ;
346346 } ) ;
347347
348+ it ( "filters standalone structural markers from matching, snippets, and ranking" , async ( ) => {
349+ const { rootDir, config } = await createQueryVault ( {
350+ initialize : true ,
351+ } ) ;
352+ await Promise . all ( [
353+ fs . writeFile (
354+ path . join ( rootDir , "entities" , "marker-only.md" ) ,
355+ renderWikiMarkdown ( {
356+ frontmatter : {
357+ pageType : "entity" ,
358+ id : "entity.marker-only" ,
359+ title : "Marker Only" ,
360+ } ,
361+ body : [
362+ "<!-- openclaw:wiki:generated:start -->" ,
363+ "<!-- openclaw:wiki:generated:end -->" ,
364+ "<!-- openclaw:human:start -->" ,
365+ "<!-- openclaw:human:end -->" ,
366+ "<!-- openclaw:wiki:raw-source -->" ,
367+ "" ,
368+ ] . join ( "\n" ) ,
369+ } ) ,
370+ "utf8" ,
371+ ) ,
372+ fs . writeFile (
373+ path . join ( rootDir , "entities" , "evidence.md" ) ,
374+ renderWikiMarkdown ( {
375+ frontmatter : {
376+ pageType : "entity" ,
377+ id : "entity.evidence" ,
378+ title : "Evidence Page" ,
379+ claims : [
380+ {
381+ id : "claim.evidence" ,
382+ text : "Neutral release note." ,
383+ status : "supported" ,
384+ confidence : 0.8 ,
385+ evidence : [ { note : "openclaw release evidence" } ] ,
386+ } ,
387+ ] ,
388+ } ,
389+ body : [
390+ "<!-- openclaw:human:start -->" ,
391+ "# Evidence Page" ,
392+ "" ,
393+ "Readable release evidence summary." ,
394+ "<!-- openclaw:human:end -->" ,
395+ "" ,
396+ ] . join ( "\n" ) ,
397+ } ) ,
398+ "utf8" ,
399+ ) ,
400+ fs . writeFile (
401+ path . join ( rootDir , "entities" , "marker-heavy.md" ) ,
402+ renderWikiMarkdown ( {
403+ frontmatter : {
404+ pageType : "entity" ,
405+ id : "entity.marker-heavy" ,
406+ title : "Marker Heavy" ,
407+ } ,
408+ body : [
409+ "# Marker Heavy" ,
410+ "" ,
411+ "<!-- openclaw:wiki:generated:start -->" ,
412+ "openclaw body reference" ,
413+ "<!-- openclaw:wiki:generated:end -->" ,
414+ "<!-- openclaw:human:start -->" ,
415+ "<!-- openclaw:human:end -->" ,
416+ "<!-- openclaw:wiki:raw-source -->" ,
417+ "" ,
418+ ] . join ( "\n" ) ,
419+ } ) ,
420+ "utf8" ,
421+ ) ,
422+ fs . writeFile (
423+ path . join ( rootDir , "entities" , "clean.md" ) ,
424+ renderWikiMarkdown ( {
425+ frontmatter : {
426+ pageType : "entity" ,
427+ id : "entity.clean" ,
428+ title : "Clean" ,
429+ } ,
430+ body : "# Clean\n\nopenclaw openclaw body reference\n" ,
431+ } ) ,
432+ "utf8" ,
433+ ) ,
434+ ] ) ;
435+
436+ const evidenceResults = await searchMemoryWiki ( {
437+ config,
438+ query : "openclaw release" ,
439+ maxResults : 10 ,
440+ } ) ;
441+ expect ( evidenceResults . map ( ( result ) => result . path ) ) . toEqual ( [ "entities/evidence.md" ] ) ;
442+ expect ( evidenceResults [ 0 ] ?. snippet ) . toBe ( "Readable release evidence summary." ) ;
443+
444+ const openClawResults = await searchMemoryWiki ( {
445+ config,
446+ query : "openclaw" ,
447+ maxResults : 10 ,
448+ } ) ;
449+ const paths = openClawResults . map ( ( result ) => result . path ) ;
450+ expect ( paths ) . not . toContain ( "entities/marker-only.md" ) ;
451+ expect (
452+ openClawResults . find ( ( result ) => result . path === "entities/clean.md" ) ?. score ,
453+ ) . toBeGreaterThan (
454+ openClawResults . find ( ( result ) => result . path === "entities/marker-heavy.md" ) ?. score ?? 0 ,
455+ ) ;
456+ } ) ;
457+
458+ it ( "keeps managed-block content and inline marker prose searchable" , async ( ) => {
459+ const { rootDir, config } = await createQueryVault ( {
460+ initialize : true ,
461+ } ) ;
462+ await Promise . all ( [
463+ fs . writeFile (
464+ path . join ( rootDir , "entities" , "managed-content.md" ) ,
465+ renderWikiMarkdown ( {
466+ frontmatter : {
467+ pageType : "entity" ,
468+ id : "entity.managed-content" ,
469+ title : "Managed Content" ,
470+ } ,
471+ body : [
472+ "# Managed Content" ,
473+ "" ,
474+ "<!-- openclaw:wiki:generated:start -->" ,
475+ "Cobalt content remains searchable." ,
476+ "<!-- openclaw:wiki:generated:end -->" ,
477+ "" ,
478+ ] . join ( "\n" ) ,
479+ } ) ,
480+ "utf8" ,
481+ ) ,
482+ fs . writeFile (
483+ path . join ( rootDir , "entities" , "inline-marker.md" ) ,
484+ renderWikiMarkdown ( {
485+ frontmatter : {
486+ pageType : "entity" ,
487+ id : "entity.inline-marker" ,
488+ title : "Inline Marker" ,
489+ } ,
490+ body : [
491+ "# Inline Marker" ,
492+ "" ,
493+ "The literal <!-- openclaw:wiki:generated:start --> inline-needle stays searchable." ,
494+ "" ,
495+ ] . join ( "\n" ) ,
496+ } ) ,
497+ "utf8" ,
498+ ) ,
499+ ] ) ;
500+
501+ const managedResults = await searchMemoryWiki ( { config, query : "cobalt" } ) ;
502+ expect ( managedResults . map ( ( result ) => result . path ) ) . toEqual ( [ "entities/managed-content.md" ] ) ;
503+ expect ( managedResults [ 0 ] ?. snippet ) . toBe ( "Cobalt content remains searchable." ) ;
504+
505+ const inlineResults = await searchMemoryWiki ( { config, query : "inline-needle" } ) ;
506+ expect ( inlineResults . map ( ( result ) => result . path ) ) . toEqual ( [ "entities/inline-marker.md" ] ) ;
507+ expect ( inlineResults [ 0 ] ?. snippet ) . toContain ( "<!-- openclaw:wiki:generated:start -->" ) ;
508+ } ) ;
509+
348510 it ( "matches pages when all query terms appear without an exact phrase" , async ( ) => {
349511 const { rootDir, config } = await createQueryVault ( {
350512 initialize : true ,
0 commit comments