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
- schema-extension-example.json - The main template demonstrating overrides
- company-types.json - Company-specific instruction types
- marketing-types.json - Marketing-specific instruction 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:
customInstructionTypes
in the template (always wins)
marketing-types.json
(last in extends array)
company-types.json
(middle of extends array)
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:
- Load all schemas in the specified order
- Build a type registry, applying overrides as schemas are loaded
- Apply custom types from the template (highest precedence)
- 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
- Order matters - Place more specific schemas later in the extends array
- Document overrides - Use descriptive names and comments to clarify override intentions
- Version compatibility - Ensure all extended schemas match the template's base version
- Test thoroughly - Verify that the correct instruction types are being used