2.1 Identified Syntactic Domains
CodeAI provides seven top-level declarative constructs, each targeting a distinct architectural concern:
| Configuration |
config { } |
Infrastructure settings |
14-46 |
| Entity |
entity Name { } |
PostgreSQL data models |
41-193 |
| Collection |
database mongodb { collection { } } |
MongoDB document schemas |
19-242 |
| Endpoint |
endpoint METHOD /path { } |
RESTful API definitions |
200-617 |
| Event |
event Name { } |
Event-driven messaging |
623-711 |
| Integration |
integration Name { } |
External service clients |
422-555 |
| Workflow |
workflow Name { } |
Multi-step business processes |
560-782 |
| Job |
job Name { } |
Scheduled background tasks |
197-653 |
*Line ranges from example files: blog-api.cai, ecommerce.cai, mongodb-collections.cai, scheduled-jobs.cai
2.2 Concern-to-Construct Mapping
Each syntactic domain addresses a specific change driver:
2.2.1 Infrastructure Configuration Concern
Change Driver: “How the application runtime is configured”
Variation Point: config { } block
config {
name: "blog-api"
version: "1.0.0"
database: postgres {
pool_size: 20
timeout: 30s
}
cache: redis {
ttl: 5m
prefix: "blog:"
}
auth: jwt {
issuer: env(JWT_ISSUER)
secret: env(JWT_SECRET)
expiry: 24h
}
}
IVP Assessment: ✅ Compliant - Database configuration varies independently of entity definitions - Cache settings can change without modifying endpoints - Authentication parameters isolated from business logic
2.2.2 Data Schema Concern (Relational)
Change Driver: “What data structures the application persists”
Variation Point: entity { } blocks
entity Post {
description: "A blog post with content and metadata"
id: uuid, primary, auto
// Content
title: string, required, searchable
slug: string, required, unique
content: text, required, searchable
// Relationships
author_id: ref(User), required
category_id: ref(Category), optional
// Tags (stored as JSON array)
tags: list(string), optional
// Publishing
status: enum(draft, pending_review, published, archived), default(draft)
published_at: timestamp, optional
created_at: timestamp, auto
updated_at: timestamp, auto_update
index: [author_id, status]
index: [slug]
}
IVP Assessment: ✅ Compliant - Schema evolution localized to entity definitions - Adding fields doesn’t require endpoint modifications - Index changes independent of business logic
2.2.3 Data Schema Concern (Document)
Change Driver: “How document-oriented data is structured”
Variation Point: database mongodb { collection { } } blocks
database mongodb {
collection Product {
description: "E-commerce products with variants"
_id: objectid, primary, auto
sku: string, required, unique
name: string, required
// Embedded document for attributes
attributes: embedded {
color: string, optional
size: string, optional
dimensions: embedded {
length: double, optional
width: double, optional
height: double, optional
}
}
categories: array(string), optional
indexes {
index: [sku] unique
index: [name, description] text
}
}
}
IVP Assessment: ✅ Compliant - MongoDB schemas separated from relational schemas - Embedded document structures vary independently - Geospatial and text indexes localized to collections
2.2.4 API Surface Concern
Change Driver: “What HTTP endpoints are exposed and how they behave”
Variation Point: endpoint { } blocks
// Create post (author/editor/admin)
endpoint POST /posts {
description: "Create a new post"
auth: required
roles: [author, editor, admin]
body {
title: string, required
slug: string, required
content: text, required
category_id: uuid, optional
tags: list(string), optional
status: string, optional
}
returns: Post
on_success: emit(PostCreated)
}
IVP Assessment: ✅ Compliant - Endpoint definitions independent of entity schemas - Authentication requirements vary per-endpoint - Request/response contracts localized - Role-based access control declarative and isolated
2.2.5 Event-Driven Messaging Concern
Change Driver: “What events are published and their payloads”
Variation Point: event { } blocks
event PostPublished {
description: "Post published"
payload {
post_id: uuid
title: string
slug: string
published_at: timestamp
}
publish_to: [webhook("post-updates"), kafka("posts")]
}
IVP Assessment: ✅ Compliant - Event contracts vary independently of endpoints that emit them - Payload structure changes don’t affect entity definitions - Publishing destinations (Kafka, webhooks) configurable per-event
2.2.6 External Integration Concern
Change Driver: “How external services are consumed”
Variation Point: integration { } blocks
integration PaymentGateway {
description: "Stripe payment processing"
type: rest
base_url: env(STRIPE_API_URL)
auth: bearer(env(STRIPE_SECRET_KEY))
timeout: 30s
retry: 3 times with exponential_backoff
circuit_breaker: {
threshold: 5 failures in 1m
reset_after: 30s
}
operation create_payment_intent {
method: POST
path: "/payment_intents"
body: {
amount: integer, required
currency: string, default("usd")
}
returns: {
id: string
status: string
client_secret: string
}
}
}
IVP Assessment: ✅ Compliant - Integration definitions isolated from workflows that consume them - Retry and circuit breaker policies vary independently - Switching providers (Stripe → PayPal) requires only integration block changes - Fault tolerance strategies localized
2.2.7 Business Process Concern
Change Driver: “How multi-step business workflows execute”
Variation Point: workflow { } blocks
workflow OrderProcessing {
description: "Process an order from placement to fulfillment"
trigger: OrderPlaced
steps {
// Step 1: Validate order
validate_order {
for_each: trigger.order.items
check: item.product.available_quantity >= item.quantity
on_fail: cancel_order("Insufficient inventory")
}
// Step 2: Reserve inventory (with compensation)
reserve_inventory {
for_each: trigger.order.items
action: reserve_product_inventory(item.product_id, item.quantity)
timeout: 30s
retry: 3 times with exponential_backoff
on_fail: rollback
}
// Step 3: Process payment (with compensation)
process_payment {
call: PaymentGateway.create_payment_intent {
amount: trigger.order.total * 100
}
timeout: 30s
on_fail: rollback
}
confirm_order {
action: update(trigger.order.status = "confirmed")
}
}
on_complete: emit(OrderConfirmed)
on_fail: emit(OrderFailed)
}
IVP Assessment: ✅ Compliant - Workflow orchestration logic separated from entity definitions - Saga pattern with compensation localized to workflow - Adding/removing steps doesn’t affect endpoints or integrations - Error handling and retry strategies per-step
2.2.8 Scheduled Task Concern
Change Driver: “When and how background jobs execute”
Variation Point: job { } blocks
job DailySalesReport {
description: "Generate daily sales report"
schedule: "0 6 * * *" // Every day at 6:00 AM
timezone: "America/New_York"
queue: default
timeout: 30m
retry: 3 times
steps {
fetch_sales {
query: select Order
where status = "completed"
and created_at >= yesterday_start()
as: orders
}
generate_report {
template: "daily_sales_report"
data: { orders: orders }
format: pdf
as: report_file
}
distribute {
send: email(config.reports.recipients) {
template: "daily_report_email"
attachment: report_file
}
}
}
on_complete: emit(ReportGenerated)
}
IVP Assessment: ✅ Compliant - Job scheduling (cron expressions) varies independently of business logic - Changing report frequency doesn’t affect entity schemas - Queue priorities and timeouts localized to job definitions - Retry strategies per-job