BREAKING CHANGES: - Relationship syntax now requires blocks for all participants - Removed self/other perspective blocks from relationships - Replaced 'guard' keyword with 'if' for behavior tree decorators Language Features: - Add tree-sitter grammar with improved if/condition disambiguation - Add comprehensive tutorial and reference documentation - Add SBIR v0.2.0 binary format specification - Add resource linking system for behaviors and schedules - Add year-long schedule patterns (day, season, recurrence) - Add behavior tree enhancements (named nodes, decorators) Documentation: - Complete tutorial series (9 chapters) with baker family examples - Complete reference documentation for all language features - SBIR v0.2.0 specification with binary format details - Added locations and institutions documentation Examples: - Convert all examples to baker family scenario - Add comprehensive working examples Tooling: - Zed extension with LSP integration - Tree-sitter grammar for syntax highlighting - Build scripts and development tools Version Updates: - Main package: 0.1.0 → 0.2.0 - Tree-sitter grammar: 0.1.0 → 0.2.0 - Zed extension: 0.1.0 → 0.2.0 - Storybook editor: 0.1.0 → 0.2.0
531 lines
28 KiB
HTML
531 lines
28 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en" class="light sidebar-visible" dir="ltr">
|
|
<head>
|
|
<!-- Book generated using mdBook -->
|
|
<meta charset="UTF-8">
|
|
<title>Validation Rules - Storybook Language Guide</title>
|
|
|
|
|
|
<!-- Custom HTML head -->
|
|
|
|
<meta name="description" content="Comprehensive documentation for the Storybook narrative simulation language">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="theme-color" content="#ffffff">
|
|
|
|
<link rel="icon" href="../favicon.svg">
|
|
<link rel="shortcut icon" href="../favicon.png">
|
|
<link rel="stylesheet" href="../css/variables.css">
|
|
<link rel="stylesheet" href="../css/general.css">
|
|
<link rel="stylesheet" href="../css/chrome.css">
|
|
<link rel="stylesheet" href="../css/print.css" media="print">
|
|
|
|
<!-- Fonts -->
|
|
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
|
|
<link rel="stylesheet" href="../fonts/fonts.css">
|
|
|
|
<!-- Highlight.js Stylesheets -->
|
|
<link rel="stylesheet" href="../highlight.css">
|
|
<link rel="stylesheet" href="../tomorrow-night.css">
|
|
<link rel="stylesheet" href="../ayu-highlight.css">
|
|
|
|
<!-- Custom theme stylesheets -->
|
|
|
|
|
|
<!-- Provide site root to javascript -->
|
|
<script>
|
|
var path_to_root = "../";
|
|
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
|
|
</script>
|
|
<!-- Start loading toc.js asap -->
|
|
<script src="../toc.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="body-container">
|
|
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
|
<script>
|
|
try {
|
|
var theme = localStorage.getItem('mdbook-theme');
|
|
var sidebar = localStorage.getItem('mdbook-sidebar');
|
|
|
|
if (theme.startsWith('"') && theme.endsWith('"')) {
|
|
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
|
}
|
|
|
|
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
|
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
|
}
|
|
} catch (e) { }
|
|
</script>
|
|
|
|
<!-- Set the theme before any content is loaded, prevents flash -->
|
|
<script>
|
|
var theme;
|
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
|
const html = document.documentElement;
|
|
html.classList.remove('light')
|
|
html.classList.add(theme);
|
|
html.classList.add("js");
|
|
</script>
|
|
|
|
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
|
|
|
|
<!-- Hide / unhide sidebar before it is displayed -->
|
|
<script>
|
|
var sidebar = null;
|
|
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
|
|
if (document.body.clientWidth >= 1080) {
|
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
|
sidebar = sidebar || 'visible';
|
|
} else {
|
|
sidebar = 'hidden';
|
|
}
|
|
sidebar_toggle.checked = sidebar === 'visible';
|
|
html.classList.remove('sidebar-visible');
|
|
html.classList.add("sidebar-" + sidebar);
|
|
</script>
|
|
|
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
|
<!-- populated by js -->
|
|
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
|
|
<noscript>
|
|
<iframe class="sidebar-iframe-outer" src="../toc.html"></iframe>
|
|
</noscript>
|
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
|
<div class="sidebar-resize-indicator"></div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div id="page-wrapper" class="page-wrapper">
|
|
|
|
<div class="page">
|
|
<div id="menu-bar-hover-placeholder"></div>
|
|
<div id="menu-bar" class="menu-bar sticky">
|
|
<div class="left-buttons">
|
|
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
|
<i class="fa fa-bars"></i>
|
|
</label>
|
|
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
|
<i class="fa fa-paint-brush"></i>
|
|
</button>
|
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
|
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
|
</ul>
|
|
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
|
|
<i class="fa fa-search"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<h1 class="menu-title">Storybook Language Guide</h1>
|
|
|
|
<div class="right-buttons">
|
|
<a href="../print.html" title="Print this book" aria-label="Print this book">
|
|
<i id="print-button" class="fa fa-print"></i>
|
|
</a>
|
|
<a href="https://github.com/r3t-studios/storybook" title="Git repository" aria-label="Git repository">
|
|
<i id="git-repository-button" class="fa fa-github"></i>
|
|
</a>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="search-wrapper" class="hidden">
|
|
<form id="searchbar-outer" class="searchbar-outer">
|
|
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
|
</form>
|
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
|
<div id="searchresults-header" class="searchresults-header"></div>
|
|
<ul id="searchresults">
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
|
<script>
|
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
|
});
|
|
</script>
|
|
|
|
<div id="content" class="content">
|
|
<main>
|
|
<h1 id="validation-rules"><a class="header" href="#validation-rules">Validation Rules</a></h1>
|
|
<p>The Storybook compiler performs multi-layered validation to catch errors before runtime. This chapter documents all validation rules, organized by declaration type, along with the error messages you can expect and how to fix them.</p>
|
|
<h2 id="validation-layers"><a class="header" href="#validation-layers">Validation Layers</a></h2>
|
|
<p>Storybook validation happens in four stages:</p>
|
|
<ol>
|
|
<li><strong>Lexical</strong>: Tokenization of raw text (invalid characters, malformed literals)</li>
|
|
<li><strong>Syntactic</strong>: Grammar structure (missing braces, wrong keyword order)</li>
|
|
<li><strong>Semantic</strong>: Cross-reference resolution, type checking, field merging</li>
|
|
<li><strong>Domain</strong>: Narrative-specific constraints (bond ranges, schedule overlaps)</li>
|
|
</ol>
|
|
<p>Errors at earlier stages prevent later stages from running.</p>
|
|
<h2 id="character-validation"><a class="header" href="#character-validation">Character Validation</a></h2>
|
|
<h3 id="required-rules"><a class="header" href="#required-rules">Required Rules</a></h3>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>Unique name</td><td>Character names must be unique within their module</td><td>Error</td></tr>
|
|
<tr><td>Species exists</td><td>If <code>: Species</code> is used, the species must be defined</td><td>Error</td></tr>
|
|
<tr><td>Templates exist</td><td>All templates in <code>from</code> clause must be defined</td><td>Error</td></tr>
|
|
<tr><td>No circular inheritance</td><td>Template chains cannot form cycles</td><td>Error</td></tr>
|
|
<tr><td>Field type consistency</td><td>Field values must match expected types</td><td>Error</td></tr>
|
|
<tr><td>Behavior trees exist</td><td>All <code>uses behaviors</code> references must resolve</td><td>Error</td></tr>
|
|
<tr><td>Schedules exist</td><td>All <code>uses schedule</code> references must resolve</td><td>Error</td></tr>
|
|
<tr><td>Prose tag uniqueness</td><td>Each prose tag can appear at most once per character</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h3 id="examples"><a class="header" href="#examples">Examples</a></h3>
|
|
<p><strong>Species not found:</strong></p>
|
|
<pre><code class="language-storybook">character Martha: Hobbit { // Error: species 'Hobbit' not defined
|
|
age: 34
|
|
}
|
|
</code></pre>
|
|
<p><strong>Fix:</strong> Define the species or correct the reference:</p>
|
|
<pre><code class="language-storybook">species Hobbit {
|
|
lifespan: 130
|
|
}
|
|
|
|
character Martha: Hobbit {
|
|
age: 34
|
|
}
|
|
</code></pre>
|
|
<p><strong>Duplicate character name:</strong></p>
|
|
<pre><code class="language-storybook">character Martha { age: 34 }
|
|
character Martha { age: 36 } // Error: duplicate character name 'Martha'
|
|
</code></pre>
|
|
<h2 id="template-validation"><a class="header" href="#template-validation">Template Validation</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>Unique name</td><td>Template names must be unique within their module</td><td>Error</td></tr>
|
|
<tr><td>Includes exist</td><td>All included templates must be defined</td><td>Error</td></tr>
|
|
<tr><td>No circular includes</td><td>Include chains cannot form cycles</td><td>Error</td></tr>
|
|
<tr><td>Range validity</td><td>Range bounds must satisfy min <= max</td><td>Error</td></tr>
|
|
<tr><td>Range type match</td><td>Both bounds of a range must be the same type</td><td>Error</td></tr>
|
|
<tr><td>Strict enforcement</td><td>Characters using strict templates cannot add extra fields</td><td>Error</td></tr>
|
|
<tr><td>Resource links valid</td><td>Behavior/schedule references must resolve</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h3 id="examples-1"><a class="header" href="#examples-1">Examples</a></h3>
|
|
<p><strong>Invalid range:</strong></p>
|
|
<pre><code class="language-storybook">template BadRange {
|
|
age: 65..18 // Error: range min (65) must be <= max (18)
|
|
}
|
|
</code></pre>
|
|
<p><strong>Strict template violation:</strong></p>
|
|
<pre><code class="language-storybook">template Rigid strict {
|
|
required_stat: 10
|
|
}
|
|
|
|
character Constrained from Rigid {
|
|
required_stat: 15
|
|
extra_field: 42 // Error: field 'extra_field' not allowed by strict template 'Rigid'
|
|
}
|
|
</code></pre>
|
|
<h2 id="behavior-tree-validation"><a class="header" href="#behavior-tree-validation">Behavior Tree Validation</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>At least one node</td><td>Behavior body must contain at least one node</td><td>Error</td></tr>
|
|
<tr><td>Composite children</td><td><code>choose</code> and <code>then</code> require at least one child</td><td>Error</td></tr>
|
|
<tr><td>Decorator child</td><td>Decorators require exactly one child</td><td>Error</td></tr>
|
|
<tr><td>Subtree exists</td><td><code>include</code> must reference a defined behavior</td><td>Error</td></tr>
|
|
<tr><td>Expression validity</td><td>Condition expressions must be well-formed</td><td>Error</td></tr>
|
|
<tr><td>Duration format</td><td>Decorator durations must be valid (e.g., <code>5s</code>, <code>10m</code>)</td><td>Error</td></tr>
|
|
<tr><td>Repeat count valid</td><td><code>repeat N</code> requires N >= 0</td><td>Error</td></tr>
|
|
<tr><td>Repeat range valid</td><td><code>repeat min..max</code> requires 0 <= min <= max</td><td>Error</td></tr>
|
|
<tr><td>Retry count valid</td><td><code>retry N</code> requires N >= 1</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h3 id="examples-2"><a class="header" href="#examples-2">Examples</a></h3>
|
|
<p><strong>Empty composite:</strong></p>
|
|
<pre><code class="language-storybook">behavior Empty {
|
|
choose options {
|
|
// Error: 'choose' requires at least one child
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p><strong>Invalid subtree reference:</strong></p>
|
|
<pre><code class="language-storybook">behavior Main {
|
|
include NonExistentBehavior // Error: behavior 'NonExistentBehavior' not defined
|
|
}
|
|
</code></pre>
|
|
<h2 id="life-arc-validation"><a class="header" href="#life-arc-validation">Life Arc Validation</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>At least one state</td><td>Life arc must contain at least one state</td><td>Error</td></tr>
|
|
<tr><td>Unique state names</td><td>State names must be unique within the life arc</td><td>Error</td></tr>
|
|
<tr><td>Valid transitions</td><td>Transition targets must reference defined states</td><td>Error</td></tr>
|
|
<tr><td>Expression validity</td><td>Transition conditions must be well-formed</td><td>Error</td></tr>
|
|
<tr><td>Field targets valid</td><td>On-enter field references must resolve</td><td>Error</td></tr>
|
|
<tr><td>Reachable states</td><td>All states should be reachable from initial state</td><td>Warning</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h3 id="examples-3"><a class="header" href="#examples-3">Examples</a></h3>
|
|
<p><strong>Invalid transition target:</strong></p>
|
|
<pre><code class="language-storybook">life_arc Broken {
|
|
state active {
|
|
on timer_expired -> nonexistent // Error: state 'nonexistent' not defined
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p><strong>Unreachable state (warning):</strong></p>
|
|
<pre><code class="language-storybook">life_arc HasOrphan {
|
|
state start {
|
|
on ready -> middle
|
|
}
|
|
|
|
state middle {
|
|
on done -> end
|
|
}
|
|
|
|
state orphan {} // Warning: state 'orphan' is not reachable
|
|
|
|
state end {}
|
|
}
|
|
</code></pre>
|
|
<h2 id="schedule-validation"><a class="header" href="#schedule-validation">Schedule Validation</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>Time format</td><td>Times must be valid HH:MM or HH:MM:SS</td><td>Error</td></tr>
|
|
<tr><td>Extends exists</td><td>Base schedule must be defined</td><td>Error</td></tr>
|
|
<tr><td>No circular extends</td><td>Schedule chains cannot form cycles</td><td>Error</td></tr>
|
|
<tr><td>Named blocks unique</td><td>Block names must be unique within a schedule</td><td>Error</td></tr>
|
|
<tr><td>Action references valid</td><td>Action references must resolve to defined behaviors</td><td>Error</td></tr>
|
|
<tr><td>Constraint values valid</td><td>Temporal constraint values must reference defined enums</td><td>Error</td></tr>
|
|
<tr><td>Recurrence names unique</td><td>Recurrence names must be unique within a schedule</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h3 id="examples-4"><a class="header" href="#examples-4">Examples</a></h3>
|
|
<p><strong>Invalid time format:</strong></p>
|
|
<pre><code class="language-storybook">schedule Bad {
|
|
block work {
|
|
25:00 - 17:00 // Error: invalid hour '25'
|
|
action: work
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p><strong>Circular extends:</strong></p>
|
|
<pre><code class="language-storybook">schedule A extends B { }
|
|
schedule B extends A { } // Error: circular schedule extension detected
|
|
</code></pre>
|
|
<h2 id="relationship-validation"><a class="header" href="#relationship-validation">Relationship Validation</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>At least two participants</td><td>Relationships require >= 2 participants</td><td>Error</td></tr>
|
|
<tr><td>Participants exist</td><td>All participant names must reference defined entities</td><td>Error</td></tr>
|
|
<tr><td>Unique participants</td><td>Each participant appears at most once</td><td>Error</td></tr>
|
|
<tr><td>Field type consistency</td><td>Fields must have valid value types</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h3 id="examples-5"><a class="header" href="#examples-5">Examples</a></h3>
|
|
<p><strong>Too few participants:</strong></p>
|
|
<pre><code class="language-storybook">relationship Lonely {
|
|
Martha // Error: relationship requires at least 2 participants
|
|
bond: 0.5
|
|
}
|
|
</code></pre>
|
|
<h2 id="species-validation"><a class="header" href="#species-validation">Species Validation</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>Unique name</td><td>Species names must be unique within their module</td><td>Error</td></tr>
|
|
<tr><td>No circular includes</td><td>Include chains cannot form cycles</td><td>Error</td></tr>
|
|
<tr><td>Includes exist</td><td>All included species must be defined</td><td>Error</td></tr>
|
|
<tr><td>Field type consistency</td><td>Fields must have valid values</td><td>Error</td></tr>
|
|
<tr><td>Prose tag uniqueness</td><td>Each prose tag can appear at most once</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h2 id="enum-validation"><a class="header" href="#enum-validation">Enum Validation</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>Unique enum name</td><td>Enum names must be unique within their module</td><td>Error</td></tr>
|
|
<tr><td>Unique variants</td><td>Variant names must be unique within the enum</td><td>Error</td></tr>
|
|
<tr><td>Non-empty</td><td>Enums must have at least one variant</td><td>Error</td></tr>
|
|
<tr><td>Valid identifiers</td><td>Variants must follow identifier rules</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h3 id="examples-6"><a class="header" href="#examples-6">Examples</a></h3>
|
|
<p><strong>Duplicate variant:</strong></p>
|
|
<pre><code class="language-storybook">enum Size {
|
|
tiny,
|
|
small,
|
|
small, // Error: duplicate variant 'small' in enum 'Size'
|
|
large
|
|
}
|
|
</code></pre>
|
|
<h2 id="institution-and-location-validation"><a class="header" href="#institution-and-location-validation">Institution and Location Validation</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>Unique name</td><td>Names must be unique within their module</td><td>Error</td></tr>
|
|
<tr><td>Resource links valid</td><td>Behavior/schedule references must resolve</td><td>Error</td></tr>
|
|
<tr><td>Field type consistency</td><td>Fields must have valid values</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h2 id="expression-validation"><a class="header" href="#expression-validation">Expression Validation</a></h2>
|
|
<p>Expressions are validated wherever they appear (life arc transitions, behavior tree conditions, if decorators).</p>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>Type consistency</td><td>Both sides of comparison must have compatible types</td><td>Error</td></tr>
|
|
<tr><td>Boolean context</td><td>Logical operators require boolean operands</td><td>Error</td></tr>
|
|
<tr><td>Field existence</td><td>Referenced fields must exist on the entity</td><td>Error</td></tr>
|
|
<tr><td>Collection validity</td><td>Quantifiers require collection-typed expressions</td><td>Error</td></tr>
|
|
<tr><td>Variable scope</td><td>Quantifier variables only valid within their predicate</td><td>Error</td></tr>
|
|
<tr><td>Enum validity</td><td>Enum comparisons must reference defined values</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h3 id="examples-7"><a class="header" href="#examples-7">Examples</a></h3>
|
|
<p><strong>Type mismatch:</strong></p>
|
|
<pre><code class="language-storybook">life_arc TypeError {
|
|
state checking {
|
|
on count == "five" -> done // Error: cannot compare int with string
|
|
}
|
|
|
|
state done {}
|
|
}
|
|
</code></pre>
|
|
<h2 id="use-statement-validation"><a class="header" href="#use-statement-validation">Use Statement Validation</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>Path exists</td><td>Imported paths must reference defined modules/items</td><td>Error</td></tr>
|
|
<tr><td>No circular imports</td><td>Modules cannot form circular dependency chains</td><td>Error</td></tr>
|
|
<tr><td>Valid identifiers</td><td>All path segments must be valid identifiers</td><td>Error</td></tr>
|
|
<tr><td>Grouped import validity</td><td>All items in <code>{}</code> must exist in the target module</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h3 id="examples-8"><a class="header" href="#examples-8">Examples</a></h3>
|
|
<p><strong>Missing import:</strong></p>
|
|
<pre><code class="language-storybook">use schema::nonexistent::Thing; // Error: module 'schema::nonexistent' not found
|
|
</code></pre>
|
|
<h2 id="cross-file-validation"><a class="header" href="#cross-file-validation">Cross-File Validation</a></h2>
|
|
<p>When resolving across multiple <code>.sb</code> files, the compiler performs additional checks:</p>
|
|
<div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Description</th><th>Severity</th></tr></thead><tbody>
|
|
<tr><td>All references resolve</td><td>Cross-file references must find their targets</td><td>Error</td></tr>
|
|
<tr><td>No naming conflicts</td><td>Declarations must not collide across files in the same module</td><td>Error</td></tr>
|
|
<tr><td>Import visibility</td><td>Only public declarations can be imported</td><td>Error</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h2 id="common-error-patterns"><a class="header" href="#common-error-patterns">Common Error Patterns</a></h2>
|
|
<h3 id="missing-definitions"><a class="header" href="#missing-definitions">Missing Definitions</a></h3>
|
|
<p>The most common error is referencing something that does not exist:</p>
|
|
<pre><code class="language-storybook">character Martha: Human from Baker {
|
|
specialty: sourdough
|
|
}
|
|
</code></pre>
|
|
<p>If <code>Human</code>, <code>Baker</code>, or the <code>sourdough</code> enum variant are not defined or imported, the compiler will report an error. Fix by adding the appropriate <code>use</code> statements:</p>
|
|
<pre><code class="language-storybook">use schema::core_enums::{SkillLevel, Specialty};
|
|
use schema::templates::Baker;
|
|
use schema::beings::Human;
|
|
|
|
character Martha: Human from Baker {
|
|
specialty: sourdough
|
|
}
|
|
</code></pre>
|
|
<h3 id="circular-dependencies"><a class="header" href="#circular-dependencies">Circular Dependencies</a></h3>
|
|
<p>Circular references are rejected at every level:</p>
|
|
<ul>
|
|
<li>Templates including each other</li>
|
|
<li>Species including each other</li>
|
|
<li>Schedules extending each other</li>
|
|
<li>Modules importing each other</li>
|
|
</ul>
|
|
<p>Break cycles by restructuring into a hierarchy or extracting shared parts into a common module.</p>
|
|
<h3 id="type-mismatches"><a class="header" href="#type-mismatches">Type Mismatches</a></h3>
|
|
<p>Storybook has no implicit type coercion. Ensure values match their expected types:</p>
|
|
<pre><code class="language-storybook">// Wrong:
|
|
character Bad {
|
|
age: "twenty" // Error: expected int, got string
|
|
is_ready: 1 // Error: expected bool, got int
|
|
}
|
|
|
|
// Correct:
|
|
character Good {
|
|
age: 20
|
|
is_ready: true
|
|
}
|
|
</code></pre>
|
|
<h2 id="validation-summary"><a class="header" href="#validation-summary">Validation Summary</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Declaration</th><th>Key Constraints</th></tr></thead><tbody>
|
|
<tr><td>Character</td><td>Unique name, valid species/templates, no circular inheritance</td></tr>
|
|
<tr><td>Template</td><td>Unique name, valid includes, valid ranges, strict enforcement</td></tr>
|
|
<tr><td>Behavior</td><td>Non-empty, valid composites, valid decorators, valid subtrees</td></tr>
|
|
<tr><td>Life Arc</td><td>Non-empty, unique states, valid transitions, reachable states</td></tr>
|
|
<tr><td>Schedule</td><td>Valid times, valid extends chain, unique block names</td></tr>
|
|
<tr><td>Relationship</td><td>>= 2 participants, valid references</td></tr>
|
|
<tr><td>Species</td><td>Unique name, valid includes, no cycles</td></tr>
|
|
<tr><td>Enum</td><td>Unique name, unique variants, non-empty</td></tr>
|
|
<tr><td>Institution</td><td>Unique name, valid resource links</td></tr>
|
|
<tr><td>Location</td><td>Unique name, valid field types</td></tr>
|
|
<tr><td>Use</td><td>Valid paths, no circular imports</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h2 id="cross-references"><a class="header" href="#cross-references">Cross-References</a></h2>
|
|
<ul>
|
|
<li><a href="./10-characters.html">Characters</a> - Character-specific validation</li>
|
|
<li><a href="./11-behavior-trees.html">Behavior Trees</a> - Behavior validation</li>
|
|
<li><a href="./13-life-arcs.html">Life Arcs</a> - Life arc validation</li>
|
|
<li><a href="./14-schedules.html">Schedules</a> - Schedule validation</li>
|
|
<li><a href="./17-expressions.html">Expression Language</a> - Expression validation</li>
|
|
<li><a href="./18-value-types.html">Value Types</a> - Type system constraints</li>
|
|
</ul>
|
|
|
|
</main>
|
|
|
|
<nav class="nav-wrapper" aria-label="Page navigation">
|
|
<!-- Mobile navigation buttons -->
|
|
<a rel="prev" href="../reference/18-value-types.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="../advanced/20-patterns.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
<div style="clear: both"></div>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
|
<a rel="prev" href="../reference/18-value-types.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="../advanced/20-patterns.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
<!-- Livereload script (if served using the cli tool) -->
|
|
<script>
|
|
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
const wsAddress = wsProtocol + "//" + location.host + "/" + "__livereload";
|
|
const socket = new WebSocket(wsAddress);
|
|
socket.onmessage = function (event) {
|
|
if (event.data === "reload") {
|
|
socket.close();
|
|
location.reload();
|
|
}
|
|
};
|
|
|
|
window.onbeforeunload = function() {
|
|
socket.close();
|
|
}
|
|
</script>
|
|
|
|
|
|
|
|
<script>
|
|
window.playground_copyable = true;
|
|
</script>
|
|
|
|
|
|
<script src="../elasticlunr.min.js"></script>
|
|
<script src="../mark.min.js"></script>
|
|
<script src="../searcher.js"></script>
|
|
|
|
<script src="../clipboard.min.js"></script>
|
|
<script src="../highlight.js"></script>
|
|
<script src="../book.js"></script>
|
|
|
|
<!-- Custom JS scripts -->
|
|
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|