Eve library

Constraint Specification Tutorial

Guide

Revision 1

On this page

Learn how to define and apply constraints in Yemaya pipelines to control creative output.

Table of Contents#

  1. Understanding Constraints
  2. Constraint Types
  3. Scope Constraints
  4. Style Constraints
  5. Technical Constraints
  6. Content Constraints
  7. Budget Constraints
  8. Combining Constraints
  9. Constraint Validation
  10. Examples

Understanding Constraints#

Constraints define the boundaries within which AI agents must operate. They ensure outputs meet your specific requirements for:

  • Scope: What to include/exclude
  • Style: Visual and artistic direction
  • Technical: Performance and compatibility
  • Content: Safety and appropriateness
  • Budget: Resource and cost limits

Constraint Priority#

When constraints conflict, priority determines resolution:

typescript
const constraints = {
  priority: ['safety', 'technical', 'budget', 'style', 'scope'],
  // Safety constraints always win
};

Constraint Types#

Hard Constraints (Must)#

Violations cause immediate failure:

typescript
const hardConstraints = {
  must: {
    targetPlatform: 'nintendo-switch',
    ageRating: 'E',
    maxFileSize: '4GB',
  },
};

Soft Constraints (Should)#

Violations generate warnings but allow continuation:

typescript
const softConstraints = {
  should: {
    polyCount: { max: 50000 },
    textureSize: { max: 2048 },
    loadTime: { max: 5 }, // seconds
  },
};

Preference Constraints (Prefer)#

Used for optimization when multiple options exist:

typescript
const preferenceConstraints = {
  prefer: {
    artStyle: ['hand-painted', 'stylized', 'realistic'],
    musicGenre: ['orchestral', 'electronic'],
  },
};

Scope Constraints#

Content Scope#

typescript
const scopeConstraints: ScopeConstraints = {
  // Game scope
  game: {
    levels: { min: 10, max: 25 },
    playableCharacters: { min: 1, max: 4 },
    enemyTypes: { min: 10, max: 30 },
    bossCount: { min: 4, max: 8 },
    itemCount: { min: 50, max: 200 },
    dialogueLines: { max: 5000 },
  },

  // Film scope
  film: {
    runtime: { min: 10, max: 15 }, // minutes
    scenes: { min: 15, max: 30 },
    characters: { min: 2, max: 8 },
    locations: { min: 3, max: 10 },
    dialogueMinutes: { max: 12 },
  },
};

Feature Scope#

typescript
const featureConstraints = {
  features: {
    // Required features
    required: ['saving', 'pause-menu', 'accessibility-options'],

    // Optional features (include if time/budget allows)
    optional: ['achievements', 'leaderboards', 'cloud-save'],

    // Excluded features
    excluded: ['multiplayer', 'in-app-purchases', 'real-money-gambling'],
  },
};

Timeline Scope#

typescript
const timelineConstraints = {
  timeline: {
    totalDuration: { max: '30 days' },
    phases: {
      concept: { max: '2 days' },
      design: { max: '5 days' },
      production: { max: '15 days' },
      qa: { max: '5 days' },
      release: { max: '3 days' },
    },
  },
};

Style Constraints#

Visual Style#

typescript
const visualConstraints: VisualConstraints = {
  artStyle: {
    primary: 'pixel-art',
    influences: ['snes-era', 'modern-indie'],
    avoid: ['realistic', 'hyper-realistic'],
  },

  colorPalette: {
    type: 'limited', // 'limited' | 'full' | 'monochrome'
    maxColors: 32,
    primaryColors: ['#4a90d9', '#7bc96f', '#e6194b'],
    mood: 'vibrant',
  },

  resolution: {
    base: '320x180',
    scalingMode: 'integer',
    maxScale: 6,
  },

  animation: {
    style: 'frame-by-frame',
    fps: 12,
    smoothing: false,
  },
};

Character Design#

typescript
const characterConstraints = {
  characters: {
    style: 'chibi',
    proportions: { headRatio: 1.5 },
    outlines: true,
    outlineWidth: 2,

    // Diversity requirements
    diversity: {
      minEthnicities: 3,
      genderBalance: true,
      ageRange: [18, 65],
      bodyTypesVariety: true,
    },

    // Consistency rules
    consistency: {
      eyeStyle: 'uniform',
      handStyle: 'simplified',
      colorHarmony: 'analogous',
    },
  },
};

Audio Style#

typescript
const audioConstraints: AudioConstraints = {
  music: {
    genre: 'chiptune',
    tempo: { min: 100, max: 140 }, // BPM
    key: 'minor',
    instruments: ['square-wave', 'triangle', 'noise'],
    loopable: true,
  },

  sfx: {
    style: '8-bit',
    sampleRate: 44100,
    bitDepth: 16,
    maxDuration: 2, // seconds
  },

  voice: {
    style: 'none', // No voice acting
    fallback: 'text-only',
  },

  mixing: {
    musicVolume: 0.7,
    sfxVolume: 1.0,
    ducking: true,
  },
};

Technical Constraints#

Performance#

typescript
const performanceConstraints: PerformanceConstraints = {
  fps: {
    target: 60,
    minimum: 30,
    vsync: true,
  },

  memory: {
    maxRAM: '2GB',
    maxVRAM: '1GB',
    maxDiskCache: '500MB',
  },

  loading: {
    initialLoad: { max: 5 }, // seconds
    levelLoad: { max: 3 },
    assetStreaming: true,
  },

  battery: {
    optimizeForMobile: true,
    maxCpuUsage: 0.7,
  },
};

Platform-Specific#

typescript
const platformConstraints = {
  pc: {
    minSpec: {
      cpu: 'Intel i3-6100',
      ram: '4GB',
      gpu: 'GTX 750 Ti',
      storage: '2GB',
    },
    recommendedSpec: {
      cpu: 'Intel i5-8400',
      ram: '8GB',
      gpu: 'GTX 1060',
      storage: '4GB',
    },
  },

  switch: {
    docked: {
      resolution: '1080p',
      fps: 60,
    },
    handheld: {
      resolution: '720p',
      fps: 30,
    },
    fileSize: { max: '4GB' },
  },

  mobile: {
    minOS: { ios: 14, android: 10 },
    orientation: 'landscape',
    touchControls: true,
    hapticFeedback: true,
  },
};

Asset Specifications#

typescript
const assetConstraints: AssetConstraints = {
  textures: {
    maxResolution: 2048,
    format: 'png',
    compression: 'lossless',
    mipMaps: true,
    powerOfTwo: true,
  },

  models: {
    maxPolygons: 10000,
    format: 'gltf',
    lodLevels: 3,
    uvChannels: 2,
  },

  audio: {
    format: 'ogg',
    sampleRate: 44100,
    bitrate: 192,
    channels: 'stereo',
  },

  animation: {
    format: 'spritesheet',
    maxFrames: 60,
    compression: 'rle',
  },
};

Content Constraints#

Age Rating#

typescript
const ageConstraints: ContentConstraints = {
  ageRating: 'E', // ESRB: E, E10+, T, M, AO

  // Automatically enforced based on rating
  autoEnforced: {
    violence: 'cartoon',
    blood: false,
    gore: false,
    language: 'mild',
    suggestiveContent: false,
    gambling: false,
    drugReference: false,
  },
};

Custom Content Rules#

typescript
const contentRules = {
  violence: {
    level: 'fantasy',
    allowed: ['cartoon-combat', 'puzzle-destruction'],
    prohibited: ['realistic-injuries', 'torture', 'cruelty'],
  },

  themes: {
    allowed: ['friendship', 'adventure', 'puzzle-solving', 'exploration'],
    prohibited: ['real-world-politics', 'religious-extremism', 'hate-speech'],
    sensitive: {
      'loss-of-loved-one': 'handle-with-care',
      'mental-health': 'consult-guidelines',
    },
  },

  representation: {
    stereotypes: 'avoid',
    culturalSensitivity: 'high',
    consultationRequired: ['indigenous-cultures', 'religious-symbols'],
  },
};

Safety Filters#

typescript
const safetyConstraints = {
  aiSafety: {
    contentFilter: 'strict',
    outputReview: true,
    humanApprovalFor: ['dialogue', 'narrativeThemes'],
  },

  playerSafety: {
    photosensitivityWarning: true,
    maxFlashFrequency: 3, // Hz
    motionSicknessOptions: true,
    breakReminders: true,
  },

  dataSafety: {
    noPersonalData: true,
    noUserTracking: true,
    gdprCompliant: true,
  },
};

Budget Constraints#

Cost Limits#

typescript
const budgetConstraints: BudgetConstraints = {
  total: {
    maxUSD: 1000,
    alertAt: 800,
    hardLimit: true,
  },

  perPhase: {
    concept: { max: 50 },
    design: { max: 100 },
    assetProduction: { max: 500 },
    qa: { max: 200 },
    release: { max: 150 },
  },

  perCategory: {
    aiGeneration: { max: 400 },
    threeD: { max: 300 },
    audio: { max: 150 },
    rendering: { max: 100 },
    storage: { max: 50 },
  },
};

Resource Limits#

typescript
const resourceConstraints = {
  compute: {
    maxGpuHours: 100,
    maxCpuHours: 500,
    preferSpotInstances: true,
  },

  storage: {
    maxStorageGB: 50,
    cleanupPolicy: 'aggressive',
  },

  apiCalls: {
    maxLlmTokens: 10000000,
    maxImageGenerations: 500,
    max3dGenerations: 100,
  },
};

Combining Constraints#

Constraint Sets#

typescript
// Define reusable constraint sets
const constraintSets = {
  mobileOptimized: {
    performance: { maxVRAM: '512MB', maxRAM: '1GB' },
    assets: { maxTextureSize: 1024, maxPolygons: 5000 },
  },

  kidFriendly: {
    content: { ageRating: 'E', violence: 'none' },
    safety: { strictContentFilter: true },
  },

  lowBudget: {
    budget: { maxUSD: 200 },
    scope: { levels: { max: 5 }, features: { minimal: true } },
  },
};

// Combine multiple sets
const projectConstraints = mergeConstraints([
  constraintSets.mobileOptimized,
  constraintSets.kidFriendly,
  {
    custom: {
      /* project-specific */
    },
  },
]);

Inheritance#

typescript
const baseConstraints = {
  quality: 'high',
  platforms: ['pc', 'switch'],
};

const derivedConstraints = {
  ...baseConstraints,
  override: {
    platforms: ['pc', 'switch', 'mobile'], // Extend
  },
};

Conditional Constraints#

typescript
const conditionalConstraints = {
  when: {
    platform: 'mobile',
  },
  then: {
    performance: { maxVRAM: '512MB' },
    assets: { maxTextureSize: 1024 },
  },
  otherwise: {
    performance: { maxVRAM: '2GB' },
    assets: { maxTextureSize: 4096 },
  },
};

Constraint Validation#

Pre-Validation#

typescript
// Validate constraints before starting
const validation = await client.constraints.validate({
  constraints: myConstraints,
  projectType: 'game',
  targetPlatforms: ['switch', 'mobile'],
});

if (!validation.valid) {
  console.log('Constraint issues:');
  for (const issue of validation.issues) {
    console.log(`- ${issue.severity}: ${issue.message}`);
  }
}

Runtime Validation#

typescript
// Monitor constraint compliance during execution
subscription.on('constraintViolation', (violation) => {
  console.log(`Constraint violated: ${violation.constraint}`);
  console.log(`Severity: ${violation.severity}`);
  console.log(`Details: ${violation.details}`);

  if (violation.severity === 'hard') {
    console.log('Pipeline paused - intervention required');
  }
});

Post-Validation Report#

typescript
// Get constraint compliance report
const report = await client.constraints.getComplianceReport(projectId);

console.log('Constraint Compliance:');
console.log(`- Fully Compliant: ${report.compliant.length}`);
console.log(`- Warnings: ${report.warnings.length}`);
console.log(`- Violations: ${report.violations.length}`);

for (const warning of report.warnings) {
  console.log(`Warning: ${warning.constraint} - ${warning.message}`);
}

Examples#

Example 1: Family-Friendly Puzzle Game#

typescript
const familyPuzzleConstraints = {
  scope: {
    levels: { min: 30, max: 50 },
    puzzleTypes: { min: 5, max: 10 },
    difficulty: ['easy', 'medium', 'hard'],
  },

  style: {
    artStyle: 'cartoon',
    colorPalette: 'bright-and-cheerful',
    animation: 'smooth',
  },

  content: {
    ageRating: 'E',
    violence: 'none',
    themes: ['problem-solving', 'achievement', 'fun'],
    language: 'clean',
  },

  technical: {
    platforms: ['ios', 'android', 'web'],
    fileSize: { max: '100MB' },
    offlinePlay: true,
  },

  budget: {
    total: { max: 500 },
  },
};

Example 2: AAA-Quality Action Game#

typescript
const aaaActionConstraints = {
  scope: {
    campaign: { hours: { min: 15, max: 20 } },
    levels: { min: 15, max: 20 },
    bossEncounters: { min: 8 },
    sidequests: { min: 30 },
  },

  style: {
    artStyle: 'realistic',
    resolution: '4K',
    rayTracing: true,
    motionCapture: true,
  },

  technical: {
    platforms: ['ps5', 'xbox-series', 'pc'],
    fps: { target: 60, rayTracing: 30 },
    hdr: true,
    spatialAudio: true,
  },

  content: {
    ageRating: 'M',
    violence: 'stylized-action',
    matureThemes: true,
  },

  quality: {
    voiceActing: 'professional',
    orchestralScore: true,
    cinematicCutscenes: true,
  },
};

Example 3: Short Film with Strict Requirements#

typescript
const shortFilmConstraints = {
  scope: {
    runtime: { exact: 10 }, // minutes
    scenes: { max: 15 },
    characters: { max: 4 },
    locations: { max: 3 },
  },

  style: {
    animation: '3d-stylized',
    aspectRatio: '2.39:1',
    colorGrade: 'cinematic',
  },

  technical: {
    resolution: '4K',
    frameRate: 24,
    colorSpace: 'ACES',
    deliveryFormat: 'DCP',
  },

  audio: {
    dialogueStyle: 'professional-va',
    music: 'original-score',
    mixFormat: '5.1',
  },

  timeline: {
    total: { max: '60 days' },
    deadlines: {
      screenplay: '2024-02-01',
      storyboard: '2024-02-15',
      roughCut: '2024-03-15',
      final: '2024-04-01',
    },
  },
};

Next Steps#