How engineers detect that the state function did not collapse due to the environment while a calculation is performed?
You can detect and correct errors during the calculation by using some Quantum Error Correction code. The idea behind these error correction codes is:
- You entangle the qubit you want to "protect" against errors with $n$ other qubits.
- You perform the operation that may introduce an error.
- You measure a general property of the system.
I recommend you to read Quantum Error Correction for Beginners (Devitt, Nemoto & Munro, 2013) if you want more details on quantum error correction (and detection!).
But you are right, a dumb measurement will break the state function and thus break an ongoing calculation.
How to detect that a calculation is finished?
From the comments you wrote, your question is based on Quantum theory, the Church-Turing principle and the universal quantum computer (page 7). In this paper, David Deutsch tries to formalise the Quantum Turing Machine (QTM).
In the model of the QTM, a user does not have any mean to know if the computation is over or not but the machine does (because there is no more instruction, because the quantum state ended up in a trap state, etc.). In order to let the user know that he can retrieve the result of its calculations, the machine just flips a (classical) bit to 1. This bit and the quantum bits used for the computation are obviously not entangled (classical bits cannot be entangled) and so measuring the bit will not change the quantum system.
In real-world models/implementations, this may be done by other means. For example with IBM's quantum chips, you know that your computation is finished when the results become available and IBM knows that the computation is over because they executed on the quantum chip all the quantum gates you asked them to execute.
How is it even possible to check whether the experimenter produced a certain quantum state?
You can perform 2 different checks:
Quantifying the reliability of the initial state: if the experimenter tell you that the initial state is $\left|\phi\right>$ you can run multiple experiments consisting in only a measurement of the initial state and count how many experiments gave wrong outcomes.
This check consists in measurements and so may break the initial state, so you cannot check just before your experiment that the initial state is good. You can only obtain numbers like "the initial state will be good in 90% of the experiments".
Checking just before your calculations that the initial state is good. As said in the previous point, this may break the initial state and I don't know any algorithm capable of doing that for an arbitrary initial state.
The 2 points above are not making any assumptions on the initial state. If you are using the quantum circuit model then you expect $\left|0\right>^n$ as initial state and this initial state can be checked and corrected before your calculations:
- Perform a destructive measurement on the qubits. Depending on the outcome of the measurement, each qubit is either in the state $\left|0\right>$ or $\left|1\right>$.
- For all the qubits measured in the state $\left|1\right>$, apply an $X$ gate to flip the qubit state to $\left|0\right>$.
I think this is how IBM reset its qubits to the $\left|0\right>$ state (but I don't have any links ensuring it).