I'm having a bit of a mind-block retrieving the various espionage stories and mystery classics I have consumed, so I may or may not have further commentary to offer later on. But based upon your initial consideration of "spy's infiltration of a castle", and my own encounters with such, I recalled a game plot in which the similarity to that of your scenario "plays" out quite nicely as a basis (not for the spy itself, but it provides an impetus and spark to the protoganists' journey conquering the pervading evil sweeping their continent).
This is the story of the spy
Leila andher efforts to gain intelligence and succeed within the realm of
Fire Emblem.