The point of this task is to find whether the "rollback" step can be avoided during parsing. This logic exists to handle the case when a <ref> tag is processed as if it's on the top level of the document, but later we discover that it was inside of a disguised <references> block written as {{#tag|references. The rollback adds significant complexity to Cite and it would be worthwhile to rewrite this in a simpler way if possible.
Since we already use the same formatter for footnote marks in the article body and in the footnote block, it's a good target for giving authority over numbering. Upstream callers are released of responsibility.
Abandoned patch moving numbering from ReferenceStack to FootnoteMarkFormatter: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cite/+/553478