% Required:
% \usetikzlibrary{positioning,shadows}

\begin{tikzpicture}[
box/.style={
    draw,
    fill=white,
    drop shadow={shadow xshift=0.08cm, shadow yshift=-0.08cm},
    text width=2.75cm,
    minimum height=2.25cm,
    inner sep=0.12cm,
    font=\small,
    align=center
},
widebox/.style={
    draw,
    fill=white,
    drop shadow={shadow xshift=0.08cm, shadow yshift=-0.08cm},
    text width=3.2cm,
    minimum height=2.25cm,
    inner sep=0.12cm,
    font=\small,
    align=center
},
rolloutbox/.style={widebox, fill=violet!10},
learnbox/.style={widebox, fill=red!8},
arrow/.style={
    ->,
    thick
},
dashedarrow/.style={
    ->,
    thick,
    dashed
}
]

\node[box] (spec) {
\textbf{\textit{Environment Specification}}\\[0.08cm]
State schema\\
Tools and APIs\\
Transition rules
};

\node[box, right=0.55cm of spec] (synthesis) {
\textbf{\textit{Programmatic Synthesis}}\\[0.08cm]
Executable code\\
Database states\\
Tool interfaces
};

\node[box, right=0.55cm of synthesis] (scenario) {
\textbf{\textit{Scenario Generation}}\\[0.08cm]
Initial states\\
User tasks\\
Difficulty control
};

\node[rolloutbox, right=0.55cm of scenario] (rollout) {
\textbf{\textit{Agent--Environment Interaction}}\\[0.08cm]
$u_1 \rightarrow o_1 \rightarrow \cdots$\\
$\rightarrow u_T \rightarrow o_T$
};

\node[box, right=0.55cm of rollout] (verify) {
\textbf{\textit{Verification}}\\[0.08cm]
State checking\\
Execution success\\
Task completion
};

\node[learnbox, below=1.05cm of rollout,minimum height=1.8cm] (learning) {
\textbf{\textit{Agent Learning}}\\[0.08cm]
Trajectory collection\\
SFT or RL update
};

\draw[arrow] (spec) -- (synthesis);
\draw[arrow] (synthesis) -- (scenario);
\draw[arrow] (scenario) -- (rollout);
\draw[arrow] (rollout) -- (verify);
\draw[arrow] (verify.south) |- (learning.east);

\draw[dashedarrow]
    (learning.west)
    -| (scenario.south);

% \node[font=\small, align=center, below=0.42cm of learning] {
% Verified outcomes support training, while failures guide scenario generation.
% };

\end{tikzpicture}
