Files
storybook/tests/examples/relationship_merging.sb

75 lines
1.8 KiB
Plaintext
Raw Normal View History

// 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