I have this thought about having a tiny, low power processor as a "base" for state and it's powered by a battery source that will make it last a while and also when you charge it, no interruption, TL;DR it won't die.
But then, it can add on more code without stopping the base code. Is that possible/what would you use(language) it sounds low level.
Conceptually it sounds impossible, how can you interface with an unknown endpoint(counts).
You should have spare memory space to accept updates, there are solutions for in-place updates but that will make things more complex so let's skip that.
Once the new piece of code is in place you replace or insert an assembly jump instruction to your new code and you're good to go.
This can replace the whole code, but if done smartly can replace parts of it. Think for example of using a dynamic jump table into functions.