(Before anyone starts hollering, I earn my bread and butter in the same language, and that'll be what makes me a millionaire in the unlikely event anything ever does. But on the other hand, somebody's gonna mention it, and I suppose it may as well be me.)
[1] https://www.stsci.edu/~idash/pub/dashevsky0607rcsgso.pdf sections 3.1, 3.5, 4.2ff.
> The flight software operates the spacecraft and the science instruments. The on-board scripts will autonomously construct and issue commands, as well as telemetry requests, in real-time to the flight software, to direct the Observatory Subsystems (e.g., Science Instruments, Attitude Control, etc.). The flight software will execute the command sent by the calling on-board script and return telemetry, which will be evaluated in real-time by that on-board script. The calling script will then send status information to a higher-level on-board script, which contains the logic to skip forward in the observing plan in response to certain events (see Section 4.1).
[0]: https://jwst.nasa.gov/content/forScientists/faqScientists.ht... [1]: https://www.researchgate.net/figure/The-crew-segment-of-the-...