AgentSkillsCN

Phase Gate Validator

阶段门验证器

SKILL.md

Phase Gate Validator

Goal: Validate that phase exit criteria are met before advancing to next phase

Description

Meta-skill that validates phase transitions in the SDLC workflow. Checks automated exit criteria (tests passing, coverage adequate, quality gate passed) and human approval gates. Determines if phase is ready to advance based on config/phase-gates.json.

Usage

  • "Validate planning phase complete"
  • "Check if implementation phase ready to advance"
  • "Verify exit criteria for review phase"

When to Use

  • After completing each SDLC phase
  • Before transitioning to next phase
  • To verify all automated checks passed

Pipeline Contract (sdlc-tdd-full.lobster)

Inputs:

  • phase (string): Current phase name (planning, implementation, review, deployment)
  • context (JSON): All artifacts and results from current phase
  • config (string): Path to phase-gates.json (default: config/phase-gates.json)

Output: JSON with structure:

json
{
  "status": "PASS",
  "phase": "implementation",
  "exit_criteria": [
    {
      "id": "acceptance_tests_generated",
      "description": "Acceptance tests exist for all stories",
      "passed": true,
      "automated": true,
      "blocking": false
    },
    {
      "id": "acceptance_tests_passing",
      "description": "All acceptance tests pass",
      "passed": true,
      "automated": true,
      "blocking": true
    },
    {
      "id": "quality_gate_passed",
      "description": "Automated quality checks pass",
      "passed": true,
      "automated": true,
      "blocking": true
    }
  ],
  "ready_to_advance": true,
  "next_phase": "review",
  "human_approval_required": true,
  "failed_criteria": []
}

Implementation

Execute in order. Do not run Lobster or any pipeline.

Step 1: Load Phase Configuration

  • Read config/phase-gates.json
  • Parse phases object
  • Extract exit_criteria for current phase (e.g., phases.implementation.exit_criteria)

Step 2: Extract Context Data

Parse context JSON for phase-specific data:

Planning Phase:

  • stories: Array of user stories
  • invest_validation: Object with INVEST criteria
  • affected_components: Array of file paths

Implementation Phase:

  • test_results: Object with acceptance and unit test results
  • coverage: Object with coverage percentages
  • quality_gate: Object with status and checks
  • security_scan: Object with vulnerabilities

Review Phase:

  • code_review: Object with approval_status
  • critical_issues: Number of critical issues
  • warnings: Number of warnings

Deployment Phase:

  • deployment: Object with staging/production status
  • smoke_tests: Object with test results

Step 3: Check Each Exit Criterion

For each criterion in exit_criteria array:

Automated Criteria (automated: true): Evaluate check expression against context data.

Examples:

  • stories_count >= 1: Check context.stories.length >= 1
  • test_results.acceptance_tests.failures == 0: Check context.test_results.acceptance.failed == 0
  • quality_gate.status == 'PASS': Check context.quality_gate.status == "PASS"
  • code_review.critical_issues == 0: Check context.code_review.critical_issues == 0

Set passed: true if check succeeds, passed: false if fails.

Manual Criteria (automated: false): Cannot validate programmatically. Set passed: "requires_human". Report as "requires human approval/verification".

Blocking Criteria (blocking: true): Must pass to advance. If any blocking criterion fails, ready_to_advance = false.

Output for each criterion:

json
{
  "id": "quality_gate_passed",
  "description": "Automated quality checks pass",
  "passed": true,
  "automated": true,
  "blocking": true,
  "reason": null
}

If failed:

json
{
  "id": "code_coverage_adequate",
  "description": "Test coverage ≥ 70%",
  "passed": false,
  "automated": true,
  "blocking": true,
  "reason": "Coverage is 65%, below threshold 70%"
}

Step 4: Determine Ready to Advance

Logic:

  • If ALL automated blocking criteria pass: ready_to_advance = true
  • If ANY automated blocking criterion fails: ready_to_advance = false
  • Human approval gates do not affect ready_to_advance (reported separately)

Collect failed_criteria array:

json
{
  "failed_criteria": [
    "code_coverage_adequate: Coverage is 65%, below threshold 70%",
    "acceptance_tests_passing: 2 tests failing"
  ]
}

Step 5: Check Human Approval Requirement

From phase-gates.json human_handoff:

  • If human_handoff.required = true: Set human_approval_required = true
  • Include human_handoff.prompt and context_to_show in output

Step 6: Determine Next Phase

From phase-gates.json:

  • Read phases.<current_phase>.next_phase
  • Example: phases.implementation.next_phase = "review"

Step 7: Output Results

Generate JSON with:

  • status: "PASS" if ready_to_advance, "FAIL" if not
  • phase: Current phase name
  • exit_criteria: Array of criteria with pass/fail status
  • ready_to_advance: Boolean (all automated blocking criteria passed)
  • next_phase: Next phase name
  • human_approval_required: Boolean
  • failed_criteria: Array of failure reasons (empty if PASS)

Output Format

Markdown summary + JSON block for pipeline consumption:

markdown
# Phase Gate Validation: Implementation

## Exit Criteria Status

### Automated Checks
✅ **acceptance_tests_generated**: Acceptance tests exist for all stories
✅ **acceptance_tests_passing**: All acceptance tests pass (3/3)
✅ **unit_tests_passing**: All unit tests pass (12/12)
✅ **code_coverage_adequate**: Test coverage 82% ≥ 70%
✅ **quality_gate_passed**: Quality gate PASS (coverage, complexity, linting)

### Manual Checks
⏳ **human_approval**: Requires human approval before deployment

## Summary
**Status**: ✅ PASS (all automated criteria met)

**Ready to Advance**: Yes
**Next Phase**: review
**Human Approval Required**: Yes

**Blocking Failures**: None

## Human Handoff
**Prompt**: "Review code and approve for deployment"
**Context**:
- Test Results: 15/15 tests passing
- Coverage: 82%
- Quality Report: PASS
- Security Report: PASS

```json
{
  "status": "PASS",
  "phase": "implementation",
  "exit_criteria": [
    {"id": "acceptance_tests_generated", "passed": true, "automated": true, "blocking": false},
    {"id": "acceptance_tests_passing", "passed": true, "automated": true, "blocking": true},
    {"id": "unit_tests_passing", "passed": true, "automated": true, "blocking": true},
    {"id": "code_coverage_adequate", "passed": true, "automated": true, "blocking": true},
    {"id": "quality_gate_passed", "passed": true, "automated": true, "blocking": true}
  ],
  "ready_to_advance": true,
  "next_phase": "review",
  "human_approval_required": true,
  "failed_criteria": []
}
code

## Example: Failed Phase Gate

```markdown
# Phase Gate Validation: Implementation

## Exit Criteria Status

### Automated Checks
✅ **acceptance_tests_generated**: Acceptance tests exist for all stories
❌ **acceptance_tests_passing**: 2 tests failing (1/3 passing)
❌ **code_coverage_adequate**: Coverage 65% < 70% threshold
✅ **quality_gate_passed**: Quality gate PASS

## Summary
**Status**: ❌ FAIL (blocking criteria not met)

**Ready to Advance**: No
**Blocking Failures**:
- acceptance_tests_passing: 2 acceptance tests failing
- code_coverage_adequate: Coverage is 65%, below threshold 70%

## Recommendations
1. Fix failing acceptance tests in features/profile_api.feature
2. Add unit tests to increase coverage from 65% to ≥70%
3. Re-run phase gate validation after fixes

```json
{
  "status": "FAIL",
  "phase": "implementation",
  "exit_criteria": [
    {"id": "acceptance_tests_generated", "passed": true, "automated": true},
    {"id": "acceptance_tests_passing", "passed": false, "automated": true, "blocking": true, "reason": "2 tests failing"},
    {"id": "code_coverage_adequate", "passed": false, "automated": true, "blocking": true, "reason": "Coverage 65% < 70%"}
  ],
  "ready_to_advance": false,
  "next_phase": "review",
  "human_approval_required": true,
  "failed_criteria": [
    "acceptance_tests_passing: 2 tests failing",
    "code_coverage_adequate: Coverage 65% < 70%"
  ]
}
code

## Notes
- Automated criteria are evaluated programmatically from context
- Manual criteria (human approval) reported as "requires_human"
- Blocking failures prevent advancing to next phase
- Non-blocking failures warn but don't prevent advance
- Re-run validator after fixing failures
- Human approval gates are separate from automated checks