I have a market with safe rate r and risky asset S $$ \frac{dS_t}{S_t}=(r+Y_t)dt+\sigma dW_t \quad \quad (1)$$ $$ dY_t = - \lambda Y_t +dB_t \quad \quad (2)$$ where W, B are Brownian Motions with correlation $\rho$.
I am deriving the HJB equation for the utility maximization problem $$\max_{X} E[logX_T] \quad \quad (3)$$
The V function depends on t, X and Y. HJB is going to be the drift of the dV function derived using Ito formula. Hence the initial dV function will be of the following form $$dV(t,X_t,Y_t)=V_t dt + V_x dX_t + V_ydY_t + \frac{1}{2} \big{(} V_{xx} d \langle X \rangle_t + 2 V_{xy} d \langle X,Y \rangle_t + V_{yy} d \langle Y \rangle_t \big{)} \quad \quad (4)$$
so I supposed to get the below HJB equation $$\sup_{\pi} \big{(} V_t + V_x (r+y \pi)x - \lambda y V_y + \frac{1}{2} (V_{xx}\sigma^2 \pi^2 x^2 + 2V_{xy} \sigma \rho \pi x + V_{yy} ) \big{)} =0 \quad \quad (5)$$ using the follwing dynamics $$dX_t=X_t(r+ \pi y )dt + \pi \sigma X_t dW_t \quad \quad (6)$$ $$$$
Now, I don't quite follow how the $dX_t$ is created and how the $\pi$ comes into play here. My guess is that it represents portfolio weight and $dX_t$ represents the change in the capital.
In the theory (study notes) I have a general formula for one variable and it looks like $$dV(X_t^{\Pi},t)=V_t + X_t^{\Pi} (r + \Pi' \mu)V_x + \frac{\Pi_t' \Sigma \Pi_t}{2} (X_t^{\Pi})^2 V_{xx})dt + V_x X_t^{\Pi} \Pi_t' \sigma dW_t \quad \quad (7)$$
The use of the $\pi, \Pi$ components confuses me. Could anybody clarify of the logic behind the use of $\pi$ and $dX_t$ derivation please?