Schema Extension Example

Understanding instruction type overrides in ITS

Overview

This example demonstrates how instruction types are resolved when using the extends mechanism in ITS. It shows how types can be overridden through the schema chain and how custom types take precedence over all extended schemas.

📁 Files in this Example

View Main Template View Company Types View Marketing Types

Override Chain

The template extends three schemas in this specific order:

"extends": [
    "https://.../its-standard-types-v1.json",  // 1. Standard library (lowest precedence)
    "./company-types.json",                     // 2. Company overrides standard
    "./marketing-types.json"                    // 3. Marketing overrides company (highest precedence)
]

Additionally, the template defines its own custom types:

"customInstructionTypes": {
    "summary": { ... }  // Overrides ALL extended definitions
}

How Types are Resolved

1. summary Type - Multiple Overrides

Standard library Basic summary with brief/standard/detailed lengths
company-types.json Corporate executive summary focusing on achievements
marketing-types.json Marketing-focused summary with campaign metrics
customInstructionTypes ROI and business impact focused summary
Final Resolution: Uses the custom definition from the template itself

2. testimonial Type - Schema Override

Standard library (not defined)
company-types.json Professional testimonials with name and role
marketing-types.json Marketing-optimized testimonials with style options
Final Resolution: Uses marketing-types.json definition (last in extends array)

3. company_intro Type - No Override

Standard library (not defined)
company-types.json Company introduction with optional values
marketing-types.json (not defined)
Final Resolution: Uses company-types.json definition (no override)

4. campaign_metrics Type - Single Definition

Standard library (not defined)
company-types.json (not defined)
marketing-types.json Campaign metrics dashboard
Final Resolution: Uses marketing-types.json definition (only definition)

Key Principles Demonstrated

1. Complete Override

When marketing-types.json defines summary, it completely replaces the definition from company-types.json. No property merging occurs - it's a full replacement.

2. Precedence Order

From highest to lowest precedence:

  1. customInstructionTypes in the template (always wins)
  2. marketing-types.json (last in extends array)
  3. company-types.json (middle of extends array)
  4. its-standard-types-v1.json (first in extends array)

3. No Partial Merging

The testimonial type in marketing-types.json doesn't inherit any properties from the company-types.json definition - it's a complete replacement with its own configuration schema.

Compiler Behavior

When compiling this template, a compiler should:

  1. Load all schemas in the specified order
  2. Build a type registry, applying overrides as schemas are loaded
  3. Apply custom types from the template (highest precedence)
  4. Report overrides to help developers understand type resolution

Example Compiler Output

INFO: Loading extended schemas...
INFO: Loaded https://.../its-standard-types-v1.json
INFO: Loaded ./company-types.json
INFO: Loaded ./marketing-types.json

INFO: Instruction type overrides detected:
- 'summary' overridden by company-types.json (from its-standard-types-v1.json)
- 'summary' overridden by marketing-types.json (from company-types.json)
- 'summary' overridden by customInstructionTypes (from marketing-types.json)
- 'testimonial' overridden by marketing-types.json (from company-types.json)

INFO: Compilation successful

Use Cases

Organization Standards

company-types.json ensures consistent corporate voice across all templates in an organization.

Department Customization

marketing-types.json adds department-specific instruction types while maintaining company standards.

Template Flexibility

Individual templates can still override any instruction type for specific use cases using customInstructionTypes.

Type Sharing

Common instruction types can be shared across multiple templates by referencing the same schema files.

Best Practices