Your HaP changes whenever a hacking action completes. In the case of something like Knowledge hacking, that's every few points of K acquired. On the other hand, for something like an Advanced Factory hack, that's only at the end of the 15:00 countdown.
The current HaP is what is used whenever an AI reaction occurs. So, during a K-raid, the difficulty gets progressively harder, but it remains constant during the course of the entire Adv Fact hack (unless the HaP changes for some other reason).
If, when the AI reacts to a hack, the current HaP is negative, it acts as a near exponential multiplier to the response. Having the HaP go negative at the end of a hack is not necessarily a bad thing. But hacking a lot while the HaP is very negative will almost certainly kill you.