feat: implement storybook DSL with template composition and validation
Add complete domain-specific language for authoring narrative content for agent simulations. Features: - Complete parser using LALRPOP + logos lexer - Template composition (includes + multiple inheritance) - Strict mode validation for templates - Reserved keyword protection - Semantic validators (trait ranges, schedule overlaps, life arcs, behaviors) - Name resolution and cross-reference tracking - CLI tool (validate, inspect, query commands) - Query API with filtering - 260 comprehensive tests (unit, integration, property-based) Implementation phases: - Phase 1 (Parser): Complete - Phase 2 (Resolution + Validation): Complete - Phase 3 (Public API + CLI): Complete BREAKING CHANGE: Initial implementation
This commit is contained in:
74
tests/examples/relationship_merging.sb
Normal file
74
tests/examples/relationship_merging.sb
Normal file
@@ -0,0 +1,74 @@
|
||||
// Demonstration of relationship merging
|
||||
// The same relationship can be declared multiple times from different perspectives
|
||||
// The resolver will merge them into a single relationship
|
||||
|
||||
// First, define characters
|
||||
character Alice {
|
||||
age: 30
|
||||
name: "Alice"
|
||||
}
|
||||
|
||||
character Bob {
|
||||
age: 32
|
||||
name: "Bob"
|
||||
}
|
||||
|
||||
// Declare the relationship from Alice's perspective
|
||||
// In a multi-file system, this might be in alice.sb
|
||||
relationship Friendship_AliceBob {
|
||||
Alice self {
|
||||
// Alice's feelings about the friendship
|
||||
trust: 0.9
|
||||
enjoyment: 0.95
|
||||
} other {
|
||||
// How Alice perceives Bob
|
||||
reliability: 0.85
|
||||
humor: 0.9
|
||||
}
|
||||
Bob
|
||||
}
|
||||
|
||||
// Same relationship from Bob's perspective
|
||||
// In a multi-file system, this might be in bob.sb
|
||||
relationship Friendship_AliceBob {
|
||||
Bob self {
|
||||
// Bob's feelings about the friendship
|
||||
trust: 0.85
|
||||
enjoyment: 0.9
|
||||
} other {
|
||||
// How Bob perceives Alice
|
||||
reliability: 0.95
|
||||
humor: 0.8
|
||||
}
|
||||
Alice
|
||||
}
|
||||
|
||||
// The resolver will:
|
||||
// 1. Recognize these as the same relationship (same participants + name)
|
||||
// 2. Merge the self/other blocks appropriately
|
||||
// 3. Validate that shared fields (if any) have the same values
|
||||
|
||||
// Example with shared fields
|
||||
relationship Professional_AliceBob {
|
||||
Alice self {
|
||||
respect: 0.9
|
||||
}
|
||||
Bob
|
||||
|
||||
// Shared field - must have same value in all declarations
|
||||
workplace: "TechCorp"
|
||||
}
|
||||
|
||||
// Same relationship, same shared field value
|
||||
relationship Professional_AliceBob {
|
||||
Bob self {
|
||||
respect: 0.85
|
||||
}
|
||||
Alice
|
||||
|
||||
// This MUST match the value in the other declaration
|
||||
workplace: "TechCorp"
|
||||
}
|
||||
|
||||
// Note: If the shared field values differed, the resolver would
|
||||
// report a validation error about conflicting values
|
||||
Reference in New Issue
Block a user