***** NOT A TEACHER *****
I found a sentence that is similar to your second sentence:
"Whoever arrives first is to turn on the lights."
The book says that we should parse "whoever" as an indefinite relative pronoun.
It is "indefinite" because it does NOT have an expressed antecedent.
Its meaning is actually "Anyone who arrives first is to turn on the light." [My note: You could speak that way, but it is more natural to simply use "whoever."]
Source: Pence and Emery, A Grammar of Present-Day English (1963).
Student or Learner