I have a Bard with a couple months of downtime. He wants to cast a second level Lock on the party's locked bag and then train into a different spell. My instincts say that a character probably needs to continue to be able to cast a spell for something like that to work, but I wanted to see what the rules say or at least point towards before I make a ruling. I read through the spells chapter in both my copy of the CRB and on Archives of Nethys but didn't find anything.
The Spell Remains
Under the Long Durations section on spells there's some relevant information including mention that unlimited duration spells are maintained even when the caster dies, which seems like a more severe circumstance than retraining the spell away.
Spells with an unlimited duration last until counteracted or Dismissed. You don’t need to keep a spell slot open for these spells.
Without some mention that spells expire when the caster retrains the ability away, this general rule would apply that the spell lasts until counteracted or Dismissed.