@@ -736,3 +736,64 @@ def test_permalink_compatibility_candidates_are_not_filename_aliases(test_projec
736736 )
737737 source = next (file .content for file in render_bundle (snapshot ) if file .path == "source.md" )
738738 assert b"[p/foo](/p/foo) and [foo](/foo.md)" in source
739+
740+
741+ def test_escaping_wikilink_stays_literal_instead_of_normalizing_to_a_real_note ():
742+ body = "[[../../a.md]] and [[../a.md]]"
743+ assert convert_wikilinks (body , "folder/source.md" , {"a.md" : "a.md" }, "p" ) == (
744+ "[[../../a.md]] and [../a.md](/a.md)"
745+ )
746+
747+
748+ def test_ambiguous_slash_title_still_allows_exact_filename_inference (test_project ):
749+ from basic_memory .models import Entity
750+ from basic_memory .services .bulk_link_resolver import ProjectEntityIdentityIndex
751+
752+ owner = Entity (title = "p/foo" , file_path = "p/foo.md" )
753+ index = ProjectEntityIdentityIndex .from_entities (
754+ test_project , [owner , Entity (title = "p/foo" , file_path = "other.md" )]
755+ )
756+ assert (
757+ index .resolve_strict (
758+ "p/foo" , include_project_permalinks = True , workspace_permalink = None
759+ ).entity
760+ is owner
761+ )
762+ snapshot = ExportSnapshot (
763+ "p" ,
764+ (
765+ ExportFile ("p/foo.md" , b"---\n title: p/foo\n ---\n " ),
766+ ExportFile ("other.md" , b"---\n title: p/foo\n ---\n " ),
767+ ExportFile ("source.md" , b"[[p/foo]]" ),
768+ ),
769+ )
770+ source = next (file .content for file in render_bundle (snapshot ) if file .path == "source.md" )
771+ assert b"[p/foo](/p/foo.md)" in source
772+
773+
774+ def test_yaml_sets_are_deterministic_across_processes ():
775+ import os
776+ import subprocess
777+ import sys
778+
779+ source = b"---\n type: note\n custom: !!set {alpha: null, beta: null, gamma: null}\n ---\n "
780+ expected = next (
781+ file .content .decode ()
782+ for file in render_bundle (ExportSnapshot ("p" , (ExportFile ("a.md" , source ),)))
783+ if file .path == "a.md"
784+ )
785+ script = (
786+ "from basic_memory.okf.render import ExportFile, ExportSnapshot, render_bundle\n "
787+ f"source = { source !r} \n "
788+ "print(next(f.content.decode() for f in render_bundle(ExportSnapshot('p', "
789+ "(ExportFile('a.md', source),))) if f.path == 'a.md'))\n "
790+ )
791+ outputs = [
792+ subprocess .check_output (
793+ [sys .executable , "-c" , script ], env = {** os .environ , "PYTHONHASHSEED" : seed }, text = True
794+ )
795+ for seed in ("1" , "2" )
796+ ]
797+ assert outputs [0 ] == outputs [1 ] == expected + "\n "
798+ assert parse_document (outputs [0 ]).metadata ["custom" ] == {"alpha" , "beta" , "gamma" }
799+ assert outputs [0 ].index ("type: note" ) < outputs [0 ].index ("custom:" )
0 commit comments