---
# Stage identity per spec Section 6.1
stage: 2
stage_id: "02"
title: "Collect Principles"
workflow: constitution
estimated_tokens: 2000

# Context specification
context:
  static:
    persona: "technical governance architect structuring principles"
    purpose: "Structure the collected principles for constitution generation"
  dynamic:
    - key: principles
      source: cli_arg
    - key: defaults
      source: cli_arg

# Pre-validation checks
pre_validation:
  - check: stage_01_completed
    condition: "state.constitution.current_stage == '01-initialization'"
    message: "Stage 01 (Initialization) must be completed first"
    recovery: "civyk-hatch constitution --stage=1"
  - check: principles_provided
    condition: "principles is not empty OR defaults flag is set"
    message: "Principles must be provided via --defaults or --principles flag"
    recovery: "civyk-hatch constitution --stage=1"

# Execution flow with step types
execution_flow:
  - step: 1
    type: action
    name: validate_input
    instruction: "Verify principles were provided via CLI flags"
    output_variable: input_valid
  - step: 2
    type: action
    name: review_principles
    instruction: "Review and validate the principles for completeness and clarity"
    output_variable: principles_reviewed
  - step: 3
    type: action
    name: check_coverage
    instruction: "Check if key areas are covered: code quality, testing, documentation, security, architecture"
    output_variable: coverage_check
  - step: 4
    type: action
    name: identify_gaps
    instruction: "Identify gaps and suggest additional principles if critical areas missing"
    output_variable: gaps_identified

# Guardrails
guardrails:
  enforcement: active
  allowed_tools:
    - civyk-repoix
    - Read
    - Grep
    - Glob
  forbidden_actions:
    - "Proceed without principles being provided"
    - "Modify any files"
  read_only: true

# Post-validation checks
post_validation:
  - check: principles_validated
    description: "Principles were reviewed and validated"
    severity: error
  - check: coverage_checked
    description: "Coverage of key areas was checked"
    severity: warning

# Next stage
next:
  stage: 3
  stage_id: "03"
  command: "civyk-hatch constitution --stage=3"
  is_terminal: false
version: 1.0.0
---
{{include:verification-rules.md}}

# Stage 2: Collect Principles

## Purpose

Structure the collected principles for constitution generation.

---

## Pre-Check: Verify Principles Provided

**IF** `{principles}` is empty or shows only "$NONE":

```text
[!] ERROR: No principles provided

Stage 2 requires either --defaults or --principles flag.
Re-run with:
  civyk-hatch constitution --defaults
  OR
  civyk-hatch constitution --principles="Your principles here"
```

**STOP** - Do not proceed until principles are provided via CLI flags.

---

## Collected Principles

The following principles have been collected:

{principles}

Source: User input

---

## Task

Review and validate the principles above:

1. **Check completeness** - Are all key areas covered?
   - Code quality and standards
   - Testing requirements
   - Documentation standards
   - Security practices
   - Architecture constraints

2. **Check clarity** - Is each principle:
   - Specific and measurable?
   - Using normative language (MUST, SHOULD, MAY)?
   - Actionable in code reviews?

3. **Identify gaps** - Suggest additional principles if critical areas are missing

---

## Output

Confirm principles are ready for constitution generation:

```text
[ok] Principles validated: [N] principles
  - Quality coverage: [Complete/Needs additions]
  - Ready for constitution generation
```

---

## NEXT

Run the next stage to generate the constitution:

```bash
civyk-hatch constitution --stage=3
```
