How to approach some rule based selections

I’m looking for some advice on how best to tackle some rule based selections in a table - and perhaps some automatic selections. I’m not sure if all of this is possible… the following table works great. I’m just trying to add some extra formulas/rules so that people who use it don’t make mistakes which cause other problems for other tables in the app.

So here’s what it looks like at the moment.

Most of this discussion is around the column called “Step Type”

Essentially this table creates templates for workflows which can be easily added to tasks for a project.

Each workflow has multiple stages. Each stage has steps (which later get turned into tasks).

There are 4 possible types of steps, and each do different things later in our project management system.
The rules I’d like to add all revolve around these steps.
Type 1 : External Milestone. These should only be able to be the FIRST row of a stage. But a stage does not HAVE to have an external milestone.
Type 2 : Tasks. The meat and potatoes of the table. They can be any row of a stage, just not the last row. However, every stage MUST have at least one task.
Type 3 : KLANG Milestone. These should only be able to be the LAST row of a stage (with one exception - below)
Type 4 : Project Complete. Every workflow must have a final step which is project complete.

I’m wondering the best way to approach testing this. I’d think it involves a formula for the Step Type column where it only allows certain selections. However - what happens if someone moves a row around? I’m a little worried about this… but also probably because I’m not 100% sure of the way everything works in coda still.
On the other hand I’m thinking I could create an extra column that displays an error if things don’t look in the correct order? (And make it go red or something to draw attention to it?)

Or is there a completely different approach I should be thinking about?

Cheers! Brendan.