Skip to content

Latest commit

 

History

History
349 lines (245 loc) · 9.19 KB

File metadata and controls

349 lines (245 loc) · 9.19 KB

Validation Enforcement - OCL Constraint Protection

Overview

This document explains how strict validation enforcement protects your transformation pipeline from processing invalid models. This is critical for thesis defense demonstrations where examiners may test model integrity.


🔒 Strict Validation Mode (Default)

By default, the pipeline operates in strict validation mode:

./run_complete_pipeline.sh

What Happens:

  1. Valid Model → Validation PASSES → Transformation PROCEEDS
  2. Invalid Model → Validation FAILS → Pipeline STOPS (exit code 1)

Why This Matters:

  • 🎓 Thesis Defense: Demonstrates that OCL constraints actually work
  • 🛡️ Quality Assurance: Prevents invalid models from producing incorrect code
  • 📊 Model Integrity: Ensures all 50+ OCL constraints are satisfied

📋 OCL Constraints Enforced

The pipeline validates 50+ OCL constraints across multiple categories:

1. Structural Integrity (15 rules)

  • ✓ Valid names and IDs
  • ✓ Unique identifiers
  • ✓ Proper parent-child relationships

2. Data Validation (12 rules)

  • ✓ Color values in range [0.0, 1.0]
  • ✓ Positive dimensions (width, height)
  • ✓ Valid font properties

3. Layout Consistency (10 rules)

  • ✓ Valid layout modes
  • ✓ Non-negative spacing/padding
  • ✓ Consistent sizing constraints

4. Business Logic (8 rules)

  • ✓ No circular component references
  • ✓ Valid component property types
  • ✓ Consistent auto-resize settings

5. Interaction Validation (5 rules)

  • ✓ Valid navigation targets
  • ✓ Positive transition durations

🎬 Validation Failure Example

When validation fails, the pipeline stops immediately:

[STEP 2] Validating Figma Instance Model
────────────────────────────────────────────────────────────────────
✗ Figma model validation FAILED
  One or more OCL constraints were violated

════════════════════════════════════════════════════════════════
                   VALIDATION FAILED - STOPPING PIPELINE
════════════════════════════════════════════════════════════════

The Figma instance model contains constraint violations.
Transformation cannot proceed until these issues are fixed.

Why this matters:
  • OCL constraints ensure model integrity and correctness
  • Invalid models can produce incorrect transformations
  • Quality assurance requires valid input models

What to do:
  1. Review the validation errors above
  2. Fix the constraint violations in your Figma design
  3. Re-fetch the Figma model: cd python_code && python3 main.py && cd ..
  4. Re-run the pipeline: ./run_complete_pipeline.sh

For debugging only (not recommended):
  To bypass validation: STRICT_VALIDATION=false ./run_complete_pipeline.sh

════════════════════════════════════════════════════════════════

Result: Pipeline exits with code 1. No transformation occurs.


🎓 For Thesis Defense Demonstration

Scenario: Examiner Asks to Test Invalid Data

Examiner: "What happens if I provide invalid data?"

Your Response: "Let me demonstrate the validation enforcement..."

Steps to Demonstrate:

  1. Show Current Valid State

    ./validate_models.sh figma
    # Output: ✓ Figma model validation PASSED
  2. Run Test Script

    ./test_validation_enforcement.sh

    This script:

    • ✅ Tests valid model (passes)
    • ❌ Creates invalid model (fails validation)
    • 🛑 Shows pipeline stops on invalid model
  3. Explain the Protection

    • "The pipeline has 50+ OCL constraints"
    • "Invalid models are automatically rejected"
    • "This ensures transformation quality"
    • "Strict validation mode is enabled by default"
  4. Show Example Violations

    # Example: Color value out of range
    # OCL constraint: r >= 0.0 and r <= 1.0
    # Invalid: r = 2.5
    # Result: REJECTED
    
    # Example: Negative dimensions
    # OCL constraint: width > 0.0
    # Invalid: width = -100
    # Result: REJECTED

⚙️ Configuration Options

Default (Recommended for Thesis Defense)

./run_complete_pipeline.sh
# STRICT_VALIDATION=true (default)
# Pipeline STOPS on validation errors

Skip Validation Entirely (Not Recommended)

VALIDATE_FIGMA=false ./run_complete_pipeline.sh
# Skips validation step completely

Bypass Strict Mode (For Debugging Only)

STRICT_VALIDATION=false ./run_complete_pipeline.sh
# Pipeline continues despite validation errors
# ⚠️ NOT recommended for production/thesis defense

📊 Validation Statistics

Constraint Coverage:

Category Count Examples
Structural 15 Unique IDs, valid names
Data Validation 12 Color ranges, font sizes
Layout 10 Non-negative spacing
Business Logic 8 No circular refs
Interactions 5 Valid transitions
Total 50+ Comprehensive coverage

Validation Performance:

  • ⚡ Fast: ~2-5 seconds for typical models
  • 🔍 Comprehensive: Checks all constraints
  • 📝 Clear: Reports specific violations

🧪 Testing Validation Enforcement

Quick Test:

# Test that validation works
./test_validation_enforcement.sh

Manual Test:

# 1. Validate current (valid) model
./validate_models.sh figma
# Expected: ✓ PASSED

# 2. Try to run pipeline with invalid model
# (Manually edit figma_instance.xmi to introduce error)
./run_complete_pipeline.sh
# Expected: Pipeline STOPS at validation step

🎯 Key Points for Examiners

Question: "Does your OCL validation actually prevent bad data?"

Answer: ✅ Yes, absolutely.

Proof:

  1. Pipeline has strict validation mode (default ON)
  2. Invalid models cannot proceed to transformation
  3. 50+ OCL constraints are enforced
  4. Test script demonstrates rejection of invalid models

Question: "What if someone bypasses validation?"

Answer:

  • Validation is enabled by default
  • Bypassing requires explicit flag (STRICT_VALIDATION=false)
  • This is clearly marked as debugging-only
  • Production/thesis defense uses strict mode
  • Pipeline shows "Strict Validation: ENABLED" in output

📖 Example Violations and Messages

Violation 1: Invalid Color Value

OCL Constraint:

context Color
inv validRGBAValues:
    self.r >= 0.0 and self.r <= 1.0 and
    self.g >= 0.0 and self.g <= 1.0 and
    self.b >= 0.0 and self.b <= 1.0 and
    self.a >= 0.0 and self.a <= 1.0

Violation: r="2.5" (outside range [0, 1])

Result: ❌ REJECTED - "Color values must be between 0.0 and 1.0"

Violation 2: Negative Dimensions

OCL Constraint:

context Dimensions
inv positiveDimensions: self.width > 0.0 and self.height > 0.0

Violation: width="-100.0"

Result: ❌ REJECTED - "Dimensions must have positive width and height"

Violation 3: Empty Node Name

OCL Constraint:

context Children
inv validName: self.name <> null and self.name.size() > 0

Violation: name=""

Result: ❌ REJECTED - "All nodes must have valid non-empty names"


✅ Summary

Feature Status Benefit
Strict Validation ✅ Enabled by default Protects quality
50+ OCL Constraints ✅ Fully enforced Comprehensive checks
Pipeline Stops on Error ✅ Yes (strict mode) Prevents bad output
Clear Error Messages ✅ Detailed violations Easy debugging
Test Script ✅ Included Demo-ready
Thesis Defense Ready ✅ Yes Professional

🚀 Quick Commands

# Run pipeline (strict validation enforced)
./run_complete_pipeline.sh

# Test validation enforcement
./test_validation_enforcement.sh

# Validate model only
./validate_models.sh figma

# Check constraint count
grep -c '^inv' Metamodel/figma_meta_model.ocl

# View all constraints
cat Metamodel/figma_meta_model.ocl

📞 Thesis Defense Script

When demonstrating validation:

  1. Show the setting:

    Pipeline Configuration:
      Strict Validation: ENABLED (Pipeline stops on validation errors)
    
  2. Explain the protection: "The pipeline enforces 50+ OCL constraints to ensure model quality."

  3. Run the test:

    ./test_validation_enforcement.sh
  4. Explain the results:

    • Valid models pass ✅
    • Invalid models are rejected ❌
    • Pipeline stops immediately on errors 🛑
  5. Emphasize quality assurance: "This validation layer ensures that only valid, well-formed models proceed to transformation, guaranteeing output quality."


Last Updated: November 2025 Status: ✅ Production Ready for Thesis Defense