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