Validation Strategy
Understanding PackC’s approach to pack validation and quality assurance.
Overview
Section titled “Overview”PackC implements multi-level validation to catch errors early and ensure pack quality before deployment.
Validation Philosophy
Section titled “Validation Philosophy”Fail Fast
Section titled “Fail Fast”Catch errors at compile time, not runtime:
# Invalid prompt caught by packctask_type: "" # Error: task_type cannot be emptyBetter than runtime failure:
// Runtime error (bad!)conv, err := manager.NewConversation(ctx, pack, config)// Error: prompt not foundProgressive Validation
Section titled “Progressive Validation”Multiple checkpoints throughout compilation:
Parse → Validate Syntax → Validate Structure → Validate References → Final CheckEach stage catches different error types.
Warnings vs. Errors
Section titled “Warnings vs. Errors”Errors - Fatal, stop compilation:
Error: Missing required field 'task_type'Error: Invalid template syntaxWarnings - Non-fatal, allow compilation:
Warning: Missing description for prompt 'support'Warning: Tool 'search' not definedWarnings indicate potential issues that should be reviewed.
Validation Levels
Section titled “Validation Levels”Level 1: Syntax Validation
Section titled “Level 1: Syntax Validation”What: Valid YAML/JSON syntax
When: During parsing
Examples:
# Invalid YAMLprompts - support.yaml # Missing colonError:
Error parsing config: yaml: line 2: did not find expected keyLevel 2: Schema Validation
Section titled “Level 2: Schema Validation”What: Required fields present, correct types
When: After parsing
Check:
type Spec struct { TaskType string `yaml:"task_type"` // Required SystemTemplate string `yaml:"system_template"` // Required Version string `yaml:"version"` // Required}Errors:
Error: Missing required field 'task_type'Error: Field 'temperature' must be number, got stringLevel 3: Template Validation
Section titled “Level 3: Template Validation”What: Template syntax valid
When: During compilation
Check:
tmpl, err := template.New("test").Parse(userTemplate)if err != nil { return fmt.Errorf("Invalid template: %w", err)}Examples:
# Invalid Go templatesystem_template: "Error:
Error: Template parse error: unclosed actionLevel 4: Reference Validation
Section titled “Level 4: Reference Validation”What: Referenced resources exist
When: After pack assembly
Check:
- Tools referenced in prompts are defined
- Fragments referenced exist
- Media files exist on disk
Warnings:
Warning: Tool 'search_kb' referenced but not definedWarning: Image file not found: images/logo.pngLevel 5: Workflow Validation
Section titled “Level 5: Workflow Validation”What: Workflow state machine integrity
When: After reference validation
Check:
- Entry state exists in the states map
- All transition targets reference valid states
- Each state’s
prompt_taskreferences a prompt in the pack - Orchestration and persistence values are valid enums
- No unreachable states
Errors:
Error: workflow entry state "unknown" not found in statesError: state "intake" transition "Escalate" targets unknown state "missing"Warnings:
Warning: state "archived" is unreachable from entry stateWarning: state "specialist" references unknown prompt_task "missing-prompt"Level 6: Semantic Validation
Section titled “Level 6: Semantic Validation”What: Logical consistency
When: Final validation pass
Check:
- No duplicate prompt IDs
- No circular fragment references
- Reasonable parameter values
- Pack size within limits
Warnings:
Warning: temperature=2.0 exceeds recommended max of 1.0Warning: Pack size 2MB exceeds recommended 1MBValidation Rules
Section titled “Validation Rules”Required Fields
Section titled “Required Fields”Pack Level:
{ "id": "required", "version": "required", "prompts": "required"}Prompt Level:
{ "id": "required", "name": "optional but recommended", "description": "optional but recommended", "version": "required", "system_template": "required", "variables": "optional but recommended"}Type Validation
Section titled “Type Validation”String fields:
task_type: "support" # ✅ Validtask_type: 123 # ❌ Error: must be stringNumeric parameters:
temperature: 0.7 # ✅ Validtemperature: "0.7" # ❌ Error: must be numberBoolean fields:
debug: true # ✅ Validdebug: "true" # ❌ Error: must be booleanRange Validation
Section titled “Range Validation”Temperature: 0.0 to 2.0
temperature: 0.7 # ✅ Validtemperature: -1.0 # ⚠️ Warning: below 0temperature: 3.0 # ⚠️ Warning: above 2.0Max tokens: 1 to 100,000
max_tokens: 1000 # ✅ Validmax_tokens: 0 # ❌ Error: must be positivemax_tokens: 200000 # ⚠️ Warning: very largePattern Validation
Section titled “Pattern Validation”Pack ID: Alphanumeric with hyphens
id: "customer-support" # ✅ Validid: "Customer Support!" # ❌ Error: invalid charactersTask Type: Alphanumeric with hyphens/underscores
task_type: "support-agent" # ✅ Validtask_type: "support agent" # ❌ Error: no spacesTemplate Validation
Section titled “Template Validation”Go Templates:
# Validsystem_template: "User: {{user_name}}"system_template: "{{message}}"
# Invalidsystem_template: "{{.unclosed"system_template: "{{unknown_func .x}}" # Unknown functionVariable References:
# Warning if variables not documentedsystem_template: "{{undocumented_var}}" # Variable not in variables listValidation Implementation
Section titled “Validation Implementation”Validation Pipeline
Section titled “Validation Pipeline”func (p *Pack) Validate() []string { warnings := []string{} warnings = append(warnings, p.validatePackFields()...) warnings = append(warnings, p.validateTemplateEngine()...) warnings = append(warnings, p.validatePrompts()...) warnings = append(warnings, p.validateCompilation()...) return warnings}Validation Output
Section titled “Validation Output”Validation returns a list of warning strings:
warnings := pack.Validate()// Returns: []string{"missing required field: id", "prompt 'support': missing system_template"}Example output:
⚠ Pack has 2 warnings: - missing required field: id - prompt 'support': missing system_templateValidation Strategies
Section titled “Validation Strategies”Default Mode
Section titled “Default Mode”Allow warnings:
packc compileWarnings are reported but do not stop compilation. Use for development and production builds alike. Review warnings to improve pack quality.
Pre-Deployment Validation
Section titled “Pre-Deployment Validation”Validation Checklist
Section titled “Validation Checklist”Before deploying to production:
1. Schema valid
packc validate pack.json2. Size acceptable
du -h pack.json# Should be < 1MB3. JSON valid
jq empty pack.json4. Required metadata present
jq -e '.compilation.compiled_with' pack.jsonjq -e '.version' pack.json5. Load test
# Test with SDKgo run test-pack.go pack.jsonAutomated Validation
Section titled “Automated Validation”In CI/CD:
- name: Validate packs run: | packc compile --config arena.yaml --output pack.json --id app packc validate pack.json
# Additional checks ./scripts/check-pack-size.sh pack.json ./scripts/test-pack-load.sh pack.jsonValidation Reports
Section titled “Validation Reports”Summary Report
Section titled “Summary Report”packc validate pack.jsonOutput:
Validating pack: pack.json
Pack Information: ID: customer-support Version: 1.0.0 Prompts: 3
✓ Schema valid✓ All prompts valid✓ All references valid
⚠️ Warnings: 2 - Missing description for prompt 'support' - Tool 'search_kb' referenced but not defined
Summary: Pack is valid with 2 warningsDetailed Report (future)
Section titled “Detailed Report (future)”A more detailed validation report may be added in future versions.
Example of what a detailed report might look like:
Validation Report=================
Pack: customer-support v1.0.0Compiler: packc-v0.1.0Validated: 2025-01-16T10:30:00Z
Schema Validation: ✅ PASS - Pack ID present - Version valid (1.0.0) - 3 prompts found
Prompt Validation: ✅ PASS - greeting: ✅ Valid - support: ⚠️ Missing description - escalation: ✅ Valid
Reference Validation: ⚠️ WARNINGS - Tool 'search_kb': not defined - Tool 'create_ticket': not defined
Template Validation: ✅ PASS - All templates syntactically valid - 2 variables used: name, message
Fragment Validation: ✅ PASS - No fragments used
Size Analysis: - Pack size: 45 KB - Estimated load time: 5ms - Memory footprint: ~100 KB
Overall: ✅ VALID (2 warnings)Validation Best Practices
Section titled “Validation Best Practices”1. Validate Early
Section titled “1. Validate Early”# During developmentpackc compile && packc validate2. Validate Often
Section titled “2. Validate Often”# Pre-commit hookpackc validate pack.json || exit 13. Automate Validation
Section titled “3. Automate Validation”.PHONY: validatevalidate: packc validate packs/*.pack.json4. Track Warnings
Section titled “4. Track Warnings”# Log warningspackc validate pack.json 2>&1 | tee validation.log5. Fix Warnings
Section titled “5. Fix Warnings”Don’t ignore warnings - they indicate potential issues:
# Badtask_type: support# Warning: Missing description
# Goodtask_type: supportdescription: "Handles customer support inquiries"Validation Evolution
Section titled “Validation Evolution”Current (v0.1.0)
Section titled “Current (v0.1.0)”- Schema validation
- Template syntax checking
- Basic reference checking
- Size warnings
Planned (v0.2.0)
Section titled “Planned (v0.2.0)”- Semantic validation
- Custom validation rules
- Validation profiles
- Detailed reports
Future (v1.0.0)
Section titled “Future (v1.0.0)”- ML-based validation (detect poor prompts)
- Security scanning
- Performance predictions
- Quality scoring
Summary
Section titled “Summary”PackC’s validation strategy:
- Multi-level - Syntax, schema, references, semantics
- Progressive - Validation at each pipeline stage
- Informative - Clear error messages with context
- Flexible - Warnings vs. errors
- Automated - Easy to integrate in workflows
- Evolving - Continuous improvement
This ensures packs are correct, complete, and production-ready before deployment.