cogn validate
Validate the structure and examples of a Cognitive Module.
Syntax
cogn validate <module> [--v22]
Arguments
| Argument | Description |
|---|---|
module | Module name or path |
--v22 | Enable v2.2 strict validation |
Validation Contents
Standard Validation
-
Module files exist
module.yamlorMODULE.mdexistsschema.jsonexists
-
Valid YAML
name,version,responsibilityfields existexcludeslist is non-empty
-
Valid JSON Schema
schema.jsonis valid JSONinputandoutput/datadefinitions exist
-
Example validation
- Example files conform to corresponding Schema
v2.2 Strict Validation (--v22)
Adds to standard validation:
| Check | Description |
|---|---|
tier exists | exec / decision / exploration |
meta schema | Contains confidence, risk, explain |
meta.explain.maxLength | ≤280 |
data.rationale | data must require rationale |
overflow config | When enabled, needs $defs.extensions |
prompt.md | Contains v2.2 envelope instructions |
Examples
Standard Validation
cogn validate code-reviewer
Output:
→ Validating module: code-reviewer
⚠ Warnings (1):
- Consider adding 'tier' for v2.2 (use 'cogn validate --v22' for full check)
✓ Module 'code-reviewer' is valid
v2.2 Strict Validation
cogn validate code-reviewer --v22
Success output:
→ Validating module: code-reviewer (v2.2 strict)
✓ Module 'code-reviewer' is valid v2.2 format
Failure output:
→ Validating module: code-reviewer (v2.2 strict)
⚠ Warnings (1):
- overflow.require_suggested_mapping not set
✗ Validation failed (2 errors):
- module.yaml missing 'tier'
- schema.json missing 'meta' schema (required for v2.2)
Common Errors
| Error | Solution |
|---|---|
Missing module.yaml, MODULE.md, or module.md | Create module definition file |
Invalid tier: xxx | Change to exec / decision / exploration |
schema.json missing 'meta' schema | Add meta schema definition |
meta schema must require 'confidence' | Add confidence to meta.required |
meta.explain should have maxLength <= 280 | Set explain.maxLength: 280 |
Module is v1 format | Use cogn migrate to upgrade |
Migration Recommendations
If validation fails with upgrade prompt:
# Preview migration changes
cogn migrate code-reviewer --dry-run
# Execute migration
cogn migrate code-reviewer
# Re-validate
cogn validate code-reviewer --v22
Best Practices
- Use v2.2 format for new modules
- Use
--v22for strict validation - Automatically validate all modules in CI
- Use
--dry-runto preview when migrating old modules