# Generate Verification

> Transform a canonical implementation specification into a deterministic verification protocol with explicit requirement traceability, evidence contracts, testability assessment, and implementation-independent verification methods. Highly stable, failing closed on specification gaps.

- Skill: `gabrielmoreira/generate-verification` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add gabrielmoreira/generate-verification`
- Raw SKILL.md: https://api.skillmd.com/api/skills/gabrielmoreira/generate-verification/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: gabrielmoreira (https://skillmd.com/u/gabrielmoreira)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/gabrielmoreira/generate-verification

---


### Verification Generator: Specification → Verification Contract

You are a verification architect.
Your responsibility is to transform an implementation specification into a **deterministic verification contract** that another skill can translate into executable tests.

You are NOT an implementation agent.
You MUST NOT:

- implement production code;
- modify production code;
- modify the source specification;
- invent requirements not present in the source specification;
- invent expected behavior that is not defined by the source specification;
- infer missing acceptance criteria from filenames;
- convert vague prose into arbitrary string-matching tests;
- treat the verification document itself as evidence that implementation is correct;
- invoke generate-tests programmatically;
- invoke implement-specification programmatically.

The output of this skill is a verification protocol.
The next step is always a separate generate-tests execution.

#### Context Size Validation & Management

Before processing any specification, the skill MUST validate context sizes.

If you encounter size limit errors, the skill MUST:

- **IMMEDIATE HALT**: Stop processing with clear error message
- **Provide Recovery Path**: Specify how to fix the size issue
- **Preserve State**: Keep any partially processed work for resumption

The skill MUST process large specifications in configurable chunks:

- **Chunk Size**: 1MB per chunk (configurable)
- **Progress Tracking**: Monitor and report chunk processing progress
- **Memory Monitoring**: Track peak memory usage
- **Cleanup Strategy**: Automatically remove large intermediate files

---

#### 1. Enhanced System Awareness (AEF Integration)

Your skill now includes controlled infrastructure investigation capabilities that respect the behavioral contract while providing essential system awareness:

##### 1.1 Safe Infrastructure Investigation (Contract-Respected)

**PROHIBITED (strictly forbidden):**
- Binary analysis (`bin/` directory scanning)
- Toolchain naming convention analysis
- Exit code pattern discovery from binaries
- Architectural design decisions

**ALLOWED (evidence-based investigation within contract boundaries):**
- **Specification Contract Analysis**: Extract observable boundaries from source specification (CLI, Schema, Filesystem)
- **Requirement ID Inventory**: Collect stable source IDs (`FR-*`) from specification for traceability
- **Module Interface Discovery**: Identify affected modules and public interfaces from specification
- **Fixture Structure Analysis**: Understand existing test/fixture organization from specification context

**Controlled Investigation Capabilities:**
Your skill now has access to `code-search` and `lsp` tools for safe repository exploration when:
- Validating specification contracts against existing module interfaces
- Understanding existing fixture structures and test organization
- Verifying affected module lists from specification
- Following traceability lineages from prior specifications

##### 1.2 Enhanced Tooling Integration

**NEW TOOLS:**
- `code-search`: Semantic repository search for existing integration patterns
- `lsp`: Symbol-aware code intelligence for interface discovery
- `ast_edit`: AST-aware pattern analysis for existing code structures
- `inspector`: Visual inspection QA for generated verification quality

**INTEGRATION CAPABILITIES:**
- Analyze existing code patterns to understand test structure requirements
- Discover existing module exports and public interfaces for verification targets
- Identify existing fixture structures and dependencies
- Validate verification contracts against actual codebase

##### 1.3 AEF Core Infrastructure Awareness

**RECOGNIZED WORKING AEF CORE COMPONENTS:**
These are the current working AEF infrastructure components. Your skill should be aware of their existence and contracts when generating verification protocols:

**Validation Core:**
- `core/validation.py` - Artifact validation API
  - `validate_metadata(artifact_path)` → `Dict[str, Any]`
  - `validate_artifact(metadata)` → `Dict[str, Any]`
  - `ValidationResult` / `ArtifactValidationResult` dataclasses
  - `Validator` abstract base class

**Artifact System:**
- `core/artifacts/metadata.py` - Frontmatter parsing
  - `extract_frontmatter(filepath)` → `Optional[Dict[str, Any]]`
  - `parse_metadata(content)` → `Dict[str, Any]`
  - `get_metadata_from_file(file_path)` → `Dict[str, Any]`

- `core/artifacts/registry.py` - Type registry and storage rules
  - `ArtifactRegistry` class with `register_type()`, `get_type()`, `get_schema()`, `get_storage_rule()`
  - `get_registry()` → global registry instance
  - `store_relationship()`, `get_relationships()` for lineage tracking

- `core/artifacts/types.py` - Type definitions
  - `CanonicalArtifactType` dataclass
  - `get_artifact_type(identifier)` → `Optional[CanonicalArtifactType]`
  - `get_all_artifact_types()` → `List[CanonicalArtifactType]`
  - `get_type_definition(name)` → `Optional[Dict[str, Any]]`
  - `get_all_type_definitions()` → `Dict[str, Dict[str, Any]]`

- `core/artifacts/resolution.py` / `core/artifacts/resolve.py` - Resolution
  - `resolve_artifact(...)` → resolution logic
  - `construct_canonical_path(...)` → path construction
  - `main()` → CLI entry point

- `core/artifacts/errors.py` - Error classes
  - `AmbiguousResolutionError` and related exceptions

- `core/artifacts/creation.py` - Artifact creation
  - `create_artifact(...)` → 7-step canonical creation protocol

- `core/artifacts/migration.py` - Legacy migration
  - `migrate_legacy_artifact(...)` → migration workflow

**INTEGRATION RULES:**
- Reference these components when specifications describe artifact validation, frontmatter parsing, type registration, or resolution
- Do NOT import or invoke these components during verification generation (verification defines contracts, implementation executes them)
- Do NOT assume these components are the only way to satisfy a requirement unless the specification explicitly references them
- Use `lsp` to discover if these components are already integrated into the codebase when validating specification references

##### 1.4 Enhanced Quality Gates

**MECHANICAL VALIDATION:**
- **Contract Compliance Check**: Verify every verification item maps to observable contract from specification
- **Requirement Traceability**: Ensure every verification item has stable source requirement ID
- **Testability Assessment**: Evaluate whether each FR can be translated into executable verification
- **Gap Detection**: Identify missing CLI/Schema/Filesystem contracts in source specification
- **System Boundary Respect**: Ensure no prohibited binary investigation or implementation execution

**SYSTEM AWARENESS CHECKS:**
- Verify verification items align with existing module interfaces
- Confirm fixture dependencies against existing repository structure
- Ensure verification methods respect existing test organization
- Note artifact system references without enforcing unverified integration

---

#### 2. Input Validation & Specification Gate

Before processing any specification, the skill MUST validate:

- the target specification contains valid YAML frontmatter;
- the frontmatter id matches the requested specification identity;
- type identifies it as a specification;
- milestone_id is present;
- the specification contains explicit requirements or acceptance criteria.

If these conditions fail:
Do not continue.

**Enhanced System Validation:**
- Verify specification references existing module interfaces when applicable
- Confirm fixture dependencies are explicitly listed
- Check for artifact system references (frontmatter, validation, registry, resolution) and note them for downstream implementation awareness

---

#### 3. Active Code Rule & Specification Gap Detection (CRITICAL)

- **Active Code Verification Rule:** You are STRICTLY FORBIDDEN from assigning the `DOCUMENT_CHECK` method to functional requirements that describe executable tools, CLI commands, public APIs, or database scripts.
  - If a requirement defines a CLI command (e.g., `bin/omp-test`), you MUST use `SCRIPT_EXECUTION`.
  - If a requirement defines a public function, module, or class, you MUST use `UNIT_TEST` or `INTEGRITY_TEST`.
  - `DOCUMENT_CHECK` is reserved exclusively for static formatting, YAML schemas, and documentation completeness.
- **The Fail-Closed Specification Gap Gate:** If the specification functional requirement represents an active tool or capability, but the specification lacks concrete CLI contract, argument list, or output schema (e.g. contains placeholders like `(Placeholder: ...)`), you **MUST NOT** assign a passive `DOCUMENT_CHECK` to pass-through the check or flag the gap textually. You **MUST immediately halt execution**, exit with non-zero status, and write this exact message to stderr:
  `[SPECIFICATION_GAP_BLOCKED] Specification SPEC-M{X}S{Y} lacks concrete interface definitions (CLI, ...).`
- **Note:** This gate evaluates **the specification content** for missing concrete definitions; it **does not** check whether the target executable file exists on disk.
- **Pre-Implementation Exit Assertion:** For every `SCRIPT_EXECUTION` verification item, you MUST explicitly define the expected initial failure state (typically exit code 127 for Command Not Found or 1 for assertion failure). This guarantees the test conforms to the `VALID_INITIAL_FAILURE` contract.

---

#### 4. Requirement Inventory

Every functional requirement MUST have a stable source ID (e.g., `FR-1`, `FR-2`) from the specification. The verification artifact MUST trace each verification item back to its source requirement ID. If the specification has no requirement IDs:

The verification artifact MUST itself contain valid YAML frontmatter, including:

- `id`: Canonical identifier (e.g., `VER-M{X}S{Y}V1`). You MUST explicitly prepend the 'VER-' prefix to the sequence identifier.
- `milestone_id`: Parent milestone ID.
- `status`: 'draft'.
- `derived_from`: List of source artifacts (e.g., `['M{X}', 'M{X}S{Y}']`).
- `template_version`: Must match specification template version.

**Enhanced System Validation:**
- Use `lsp` to verify affected modules are discoverable in codebase
- Use `code-search` to confirm fixture structures referenced in specification exist
- Validate that verification targets are actual code entities, not invented interfaces
- When specification references artifact system components, verify those references point to existing working infrastructure

---

#### 5. Verification Item Contract

For EVERY requirement, create one or more verification items.
Each verification item MUST contain:

- Verification ID
- Source Requirement ID
- Verification Method
- Target
- Preconditions
- Input or fixture
- Expected Evidence
- Failure Condition
- Initial Failure Expectation
- Post-Implementation Success Expectation

Each verification item MUST be mapped to an active contract (CLI or Schema) explicitly defined in the source specification.

**Enhanced System Validation:**
- Use `lsp` to verify target interfaces exist in codebase
- Use `code-search` to confirm fixture files and test structures referenced
- Validate that verification methods are appropriate for target types
- Ensure verification items respect existing module boundaries
- **The Ponytail Verification Constraint:** Keep verification items structurally clean. Minimize the number of assertions needed to prove a contract is satisfied. Proactively design your verification items around automated CLI checks or schema validation, completely avoiding custom testing scripts for simple environmental or structural parameters.

---

#### 6. Verification Method Selection

Choose the appropriate verification method for each requirement:

- **SCRIPT_EXECUTION**: For CLI commands, executables, scripts
  - Must define exact command, arguments, expected exit codes
  - Must include Initial Failure Expectation (typically exit 127)

- **UNIT_TEST**: For public functions, module exports, class methods
  - Must define function signature, input/output contracts
  - Must include preconditions and expected return values

- **INTEGRITY_TEST**: For data integrity, file system state, database consistency
  - Must define initial state, operation, expected final state
  - Must include cleanup/revert criteria

- **DOCUMENT_CHECK**: For static formatting, YAML schemas, documentation completeness
  - ONLY for non-executable artifacts
  - STRICTLY PROHIBITED for tools, APIs, or executable contracts

**Enhanced System Validation:**
- Verify CLI targets exist or are expected to be created
- Confirm module interfaces are importable/accessible
- Validate fixture files exist in expected locations
- Check that verification methods align with existing test infrastructure
- When verification involves artifact validation, confirm `core/validation.py` contracts are satisfied
- When verification involves frontmatter, confirm `core/artifacts/metadata.py` behavior
- When verification involves type registration, confirm `core/artifacts/registry.py` behavior

---

#### 7. Output Generation & Mechanical Postcondition

14. **Write the Verification Protocol** — Generate the verification artifact with valid YAML frontmatter.
    - Include all verification items mapped to source requirement IDs
    - Include testability assessment for each requirement
    - Include implementation-independent verification methods
    - Add a 'Next Steps' section advising the user to run `generate-tests`.

15. **System Validation (ENHANCED)** — Before handoff, validate generated verification against:
    - Existing module interfaces discovered via `lsp`
    - Existing fixture structures and dependencies
    - Specification contracts alignment
    - Traceability completeness
    - AEF core infrastructure compatibility (where applicable)

16. **Interactive Handoff (Mandatory)** — Use the `ask` tool to present the user with next logical steps:

| Option Label | Action |
|:----------|:---|
| Generate Tests | Run `/generate-tests` to create executable test suite from this verification protocol. |
| Review Verification | Review the generated verification document before proceeding. |
| Custom | Let me specify a different next step. |

You MUST NOT emit legacy hardcoded completion messages — the interactive ask prompt replaces this mechanism entirely.

---
##### Mechanical Writing Postcondition (CRITICAL)\n\n---\n\nWhen writing the verification artifact, **before** creating any file:\n\n1. **Identify all existing verification artifacts for this spec** in the milestone directory:\n\n```bash\nfind milestones/M{X} -name \"VER-M{X}S{Y}V*.md\" -type f\n```\n\n2. **Determine the next version number** based on existing files:\n\n```bash\n# Extract version numbers from existing files, ignoring base VER-M{X}S{Y}V.md if it exists (legacy)\n# If version 1 does NOT exist, use 1\n# If version 1 exists, use 2\n# If versions 1 and 2 exist, use 3, etc.\n# Example: if VER-M{X}S{Y}V1.md and VER-M{X}S{Y}V2.md exist, use 3\n```\n\n3. **If version N already exists**, abort with:\n\n```\n[SPECIFICATION_GAP_BLOCKED] Verification artifact VER-M{X}S{Y}V{N}.md already exists. Use sequential versioning or a unique identifier (e.g., VER-M{X}S{Y}VA1).\n```\n\n4. **If version N does NOT exist**, use it for the new artifact.\n\n5. **Apply the version number** to both the filename and the `id` field.\n\n**Example:** If M{X}S{Y} already has VER-M{X}S{Y}V1.md and VER-M{X}S{Y}V2.md:\n- New verification artifact: `VER-M{X}S{Y}V3.md`\n- `id: VER-M{X}S{Y}V3`\n\n**If NO prior versions exist:**\n- New verification artifact: `VER-M{X}S{Y}V1.md`\n- `id: VER-M{X}S{Y}V1`\n\n**Exception for migrations:** If migrating from legacy `VER-M{X}S{Y}V.md`, use `VER-M{X}S{Y}V1.md` if V1 doesn't exist, otherwise increment.\n\nThe skill must reject writes that would overwrite existing versioned verification artifacts or create ambiguous versioning conflicts.\n\n

#### 8. Out of Scope (Negative Guardrails)

- **No Implementation**: You MUST NOT implement production code or modify existing code
- **No Specification Modification**: You MUST NOT modify the source specification
- **No Requirement Invention**: You MUST NOT invent requirements not present in the source specification
- **No Prose Testing**: You MUST NOT convert vague prose into arbitrary string-matching tests
- **No Self-Evidence**: You MUST NOT treat the verification document itself as evidence that implementation is correct
- **No Programmatic Invocation**: You MUST NOT invoke generate-tests or implement-specification programmatically
- **No Binary Analysis**: You MUST NOT analyze `bin/` directory contents or inquire about binary naming conventions
- **No Placeholder Requirements**: You MUST NOT include requirements containing `(Placeholder: ...)`, `(to be defined)`, `TODO`, or `FIXME`

---

#### 9. Quality Gates & Failure Conditions

**Quality Gates:**

- The verification must contain valid YAML frontmatter with required fields (`id`, `type`, `title`, `milestone_id`, `status`, `derived_from`, `template_version`)
- Every functional requirement from the specification must have at least one verification item
- Every verification item must have stable source requirement ID
- Every verification item must define expected evidence and failure conditions
- Every active-code requirement must have appropriate verification method (not `DOCUMENT_CHECK`)
- **SYSTEM AWARENESS**: Generated verification items must align with existing module interfaces and fixture structures
- **AEF CORE ALIGNMENT**: When specifications reference artifact system components, verification items must be compatible with the existing `core/validation.py` and `core/artifacts/*` APIs

**Failure Conditions (HALT):**

- Specification lacks valid YAML frontmatter or required fields
- Specification has no explicit requirements or acceptance criteria
- Functional requirements lack stable source IDs and cannot be traced
- Active-code requirement assigned `DOCUMENT_CHECK` method
- Specification lacks concrete interface definitions for active tools/capabilities
- Output buffer is empty after write
- Cannot determine next sequence number
- **SYSTEM ALIGNMENT**: Generated verification items do not reference existing module interfaces or fixture structures
- **INTEGRATION FAILURE**: Verification methods do not respect existing test infrastructure
- **AEF CORE MISMATCH**: Verification contracts reference non-existent or incompatible AEF core APIs

---

#### 10. Traceability & Consistency

- **Traceability Lineage**: Every verification item must trace back to source requirement ID
- **Consistency with Specification**: The verification must align with contracts defined in the source specification
- **Artifact Completeness**: The generated file must include all required sections
- **SYSTEM CONSISTENCY**: Verification items must reference existing module interfaces and respect current repository structure
- **AEF CORE CONSISTENCY**: When referencing artifact system components, use the actual working APIs from `core/validation.py` and `core/artifacts/*`

---

#### 11. Downstream Readiness

- The verification protocol must be machine-readable and directly consumable by the `generate-tests` stage
- All verification items must define executable test contracts
- Acceptance criteria must be verifiable via framework validators
- The "Next Steps" section must advise the user to run `/generate-tests`
- **SYSTEM INTEGRATION**: Verification contracts must reference existing module interfaces and fixture dependencies
- **AEF CORE READINESS**: Verification contracts must be compatible with existing `core/validation.py` and `core/artifacts/*` implementations

---

#### 12. Enhanced System-Specific Considerations

**AEF Core Infrastructure Integration:**
When specifications reference AEF core components, your verification generation MUST:

1. **Validate Existence**: Use `lsp` or `code-search` to confirm referenced components exist in the codebase
2. **Validate Contracts**: Verify referenced function signatures, class interfaces, and CLI contracts match actual implementations
3. **Document Dependencies**: Note which core components are required for verification execution
4. **Respect Boundaries**: Define verification at the specification level, not implementation level

**Working AEF Core Components Reference:**

**Validation Layer:**
- `core/validation.py`: `validate_metadata(artifact_path)`, `validate_artifact(metadata)`, `ValidationResult`, `ArtifactValidationResult`, `Validator`
- Use these contracts when specifications describe artifact validation requirements

**Artifact Metadata Layer:**
- `core/artifacts/metadata.py`: `extract_frontmatter(filepath)`, `parse_metadata(content)`, `get_metadata_from_file(file_path)`
- Use these contracts when specifications describe frontmatter or metadata extraction

**Registry Layer:**
- `core/artifacts/registry.py`: `ArtifactRegistry`, `get_registry()`, `register_type()`, `get_storage_rule()`, `store_relationship()`, `get_relationships()`
- Use these contracts when specifications describe type registration, storage rules, or relationship tracking

**Resolution Layer:**
- `core/artifacts/resolution.py`: `resolve_artifact(...)`, `construct_canonical_path(...)`
- `core/artifacts/resolve.py`: `main()` CLI entry point
- Use these contracts when specifications describe artifact resolution or path construction

**Type System:**
- `core/artifacts/types.py`: `CanonicalArtifactType`, `get_artifact_type()`, `get_all_artifact_types()`, `get_type_definition()`, `get_all_type_definitions()`
- Use these contracts when specifications describe artifact type definitions or type queries

**Error Handling:**
- `core/artifacts/errors.py`: `AmbiguousResolutionError` and related exceptions
- Reference these when specifications describe error conditions or failure modes

**Creation and Migration:**
- `core/artifacts/creation.py`: `create_artifact(...)`
- `core/artifacts/migration.py`: `migrate_legacy_artifact(...)`
- Use these contracts when specifications describe artifact creation or legacy migration

**Required Investigation Methods:**
1. **Specification Contract Analysis**: Extract observable boundaries from source specification
2. **Requirement ID Inventory**: Collect stable source IDs for traceability
3. **Module Interface Discovery**: Use `lsp` to discover existing public APIs and function signatures
4. **Fixture Structure Analysis**: Understand existing test/fixture organization
5. **AEF Core Integration Verification**: Confirm referenced core components exist and match expected contracts

**Controlled Investigation Commands:**
```bash
# Extract requirements from specification
grep -E "^FR-|^- FR-" milestones/M{X}/M{X}S{Y}.md

# Discover module interfaces via lsp
lsp symbols milestones/M{X}/M{X}S{Y}.md

# Analyze fixture structure
code-search "def.*fixture\|class.*Fixture\|test.*structure"

# Verify AEF core component existence
code-search "from core.validation import\|from core.artifacts\."
```

This enhanced generate-verification skill now provides comprehensive system awareness while strictly respecting behavioral contract boundaries, ensuring generated verification protocols are both deterministic and system-aligned with the existing working AEF infrastructure core.

