Prompt file imported from PauloHYBEX/Nexus-TCMS (
.windsurf/workflows/references/gates.md). Copyright stays with the author.
Canonical gate types used across learnship workflows. Every validation checkpoint maps to one of these four types.
Gate Types
Pre-flight Gate
Purpose: Validates preconditions before starting an operation. Behavior: Blocks entry if conditions unmet. No partial work created. Recovery: Fix the missing precondition, then retry. Examples:
- plan-phase checks for REQUIREMENTS.md before planning
- execute-phase validates PLAN.md exists before execution
- discuss-phase confirms phase exists in ROADMAP.md
Revision Gate
Purpose: Evaluates output quality and routes to revision if insufficient. Behavior: Loops back to producer with specific feedback. Bounded by iteration cap. Recovery: Producer addresses feedback; checker re-evaluates. The loop also escalates early if issue count does not decrease between consecutive iterations (stall detection). After max iterations, escalates unconditionally. Examples:
- Plan-checker reviewing PLAN.md (max 3 iterations)
- Verifier checking phase deliverables against success criteria
Escalation Gate
Purpose: Surfaces unresolvable issues to the developer for a decision. Behavior: Pauses workflow, presents options, waits for human input. Recovery: Developer chooses action; workflow resumes on selected path. Examples:
- Revision loop exhausted after 3 iterations
- Ambiguous requirement needing clarification
- Security threat requiring human risk acceptance
Abort Gate
Purpose: Terminates the operation to prevent damage or waste. Behavior: Stops immediately, preserves state, reports reason. Recovery: Developer investigates root cause, fixes, restarts from checkpoint. Examples:
- Context window critically low during execution
- STATE.md in error state
- Verification finds critical missing deliverables
Gate Matrix
| Workflow | Phase | Gate Type | Artifacts Checked | Failure Behavior |
|---|---|---|---|---|
| plan-phase | Entry | Pre-flight | REQUIREMENTS.md, ROADMAP.md | Block with missing-file message |
| plan-phase | Step 6 | Revision | PLAN.md quality | Loop to planner (max 3) |
| plan-phase | Post-revision | Escalation | Unresolved issues | Surface to developer |
| execute-phase | Entry | Pre-flight | PLAN.md | Block with missing-plan message |
| execute-phase | Completion | Revision | SUMMARY.md completeness | Re-run incomplete tasks |
| verify-work | Entry | Pre-flight | SUMMARY.md | Block with missing-summary |
| verify-work | Evaluation | Escalation | Failed criteria | Surface gaps to developer |
| secure-phase | Entry | Pre-flight | SUMMARY.md | Block until phase executed |
| secure-phase | Threats | Escalation | Open threats | Present to developer for decision |
| quick | Plan check | Revision | PLAN.md quality | Loop (max 2) |
Applying Gates in Custom Workflows
When creating new workflows:
- Every workflow needs at least one pre-flight gate — check that required inputs exist before starting work
- Any AI-generated output needs a revision gate — bounded loops prevent infinite regeneration
- Decisions the AI cannot make need escalation gates — risk acceptance, ambiguous requirements, conflicting constraints
- Resource exhaustion needs abort gates — context budget, time limits, repeated failures