This preserves your goal of having the system rightfully not need another source of truth outside the markdown files, but also lets the markdown file carry the identifier across renames without adding a YAML block.
And it lets you find the note in the "open note" dialog box by typing the code, so no other kind of search interface is needed. Or even to find the note with any other filesystem utility if you have your reference code.
Were you inspired by the Zettelkasten Method for your plugin?