Purpose: Canonical reference implementations demonstrating FlowScript → IR compilation Use: Validation targets for parser/linter + teaching materials for users Status: Complete - 4 patterns with full IR validation
This directory contains four golden examples that demonstrate FlowScript's core capabilities. Each example is:
- A validation target - Parser and linter implementations must handle these correctly
- A teaching tool - Shows best practices for different cognitive partnership scenarios
- A proof of architecture - Demonstrates that FlowScript → IR compilation preserves semantic richness for computational queries
Each example includes:
.fsfile - FlowScript source using indentation syntax.jsonfile - Compiled Intermediate Representation (IR)-README.mdfile - Comprehensive pattern guide (~150-200 lines)
Total: 13 files providing complete golden example suite for FlowScript v1.0.
| Pattern | Use Case | Lines | Complexity | Key Features | When to Use |
|---|---|---|---|---|---|
| Decision | Architecture choices | ~25-30 | Medium | ?, ` |
|
| Debug | Root cause analysis | ~30-35 | Medium | <-, !, [blocked], ++ |
Incident response, debugging |
| Research | Domain exploration | ~35-40 | High | Deep nesting, ~, multiple tensions |
Literature review, assessment |
| Design | RFC lifecycle | ~40-45 | High | =>, ✓, state evolution |
Project planning, tracking |
File: decision.fs | Guide: decision-README.md
Purpose: Architectural decision-making with explicit tradeoffs
Use when:
- Making RFC decisions with multiple valid options
- Evaluating alternatives with competing constraints
- Documenting "why we chose X over Y"
- Technology selection requiring rationale
Key features:
?question marker frames decision space||alternative marker for each option><[axis]tension marker (forced axis labeling)[decided(rationale: "...", on: "...")]state (forcing function)action:items make decisions actionable
Example query: alternatives() finds all options, why() traces rationale
File: debug.fs | Guide: debug-README.md
Purpose: Incident triage and root cause analysis with backward tracing
Use when:
- Debugging production issues
- Post-mortem documentation
- Tracing errors back to root cause
- Documenting investigative process
Key features:
<-reverse causation (effect ← cause)!urgent modifier marks critical issues[blocked(reason: "...", since: "...")]documents blockers++strong positive modifier for high-priority actions- Thought nodes capture insights during investigation
Example query: why() traces backward through causal chain, blocked() finds blockers
File: research.fs | Guide: research-README.md
Purpose: Complex domain exploration with hierarchical branching
Use when:
- Conducting literature reviews
- Assessing new technologies
- Mapping complex technical domains
- Documenting evolving understanding
Key features:
- Deep hierarchical nesting (4-5 levels) shows dependencies
- Multiple tension axes across domains
~exploratory modifier marks speculation- Branching structure (multiple paths from single node)
- Thought nodes synthesize findings
Example query: tensions() maps tradeoff landscape, what_if() explores consequences
File: design.fs | Guide: design-README.md
Purpose: Complete RFC lifecycle from decision through deployment
Use when:
- Writing RFCs with implementation tracking
- Project planning across multiple phases
- Documenting progress over time
- Tracking blockers and completions
Key features:
- Multiple alternatives (can include hybrid approaches)
[decided]state documents choice with rationale✓completion markers track finished tasks[completed(on: "...")]state with dates[blocked(reason: "...", since: "...")]documents blockers=>temporal operators (distinct from->causal)- Evolution over time with state changes
Example query: timeline() reconstructs project timeline, blocked() finds blockers, completed() shows progress
Start here: Pattern 1 (Decision)
- Simplest structure to learn
- Immediate practical value
- Introduces core concepts
Next: Pattern 2 (Debug)
- Adds reverse causation (
<-) - Shows state tracking in practice
- Demonstrates modifiers
Advanced: Pattern 3 (Research)
- Deep hierarchical structures
- Multiple competing constraints
- Exploratory thinking marker
Expert: Pattern 4 (Design)
- Combines all previous concepts
- Adds temporal dimension
- Shows complete lifecycle tracking
Use all 4 as regression test suite:
- Parser must compile all correctly
- Linter must catch violations (or expected warnings)
- Queries must return correct results
- IR JSON must validate against schema
# Parse any example
./bin/flowscript parse examples/decision.fs -o examples/decision.json
./bin/flowscript parse examples/debug.fs -o examples/debug.json
./bin/flowscript parse examples/research.fs -o examples/research.json
./bin/flowscript parse examples/design.fs -o examples/design.json# Lint examples
./bin/flowscript lint examples/decision.fs
# Expected: ✓ No issues found
./bin/flowscript lint examples/debug.fs
# Expected: ✓ No issues found
./bin/flowscript lint examples/research.fs
# Expected: ✓ No issues found (4-5 levels, no W002 warning)
./bin/flowscript lint examples/design.fs
# Expected: ✓ No issues found# Validate compiled IR
./bin/flowscript validate examples/decision.json
./bin/flowscript validate examples/debug.json
./bin/flowscript validate examples/research.json
./bin/flowscript validate examples/design.json
# All should pass ✓"Which pattern should I use?"
Do you need to make a decision?
└─ Yes, evaluating options
└─ Implementation tracking needed?
├─ Yes → Pattern 4 (Design RFC)
└─ No → Pattern 1 (Decision)
└─ No, analyzing existing system
└─ Is it broken/buggy?
├─ Yes, need root cause → Pattern 2 (Debug)
└─ No, exploring domain → Pattern 3 (Research)
Common scenarios:
- "Should we use Redis or Memcached?" → Decision pattern
- "Why is production timing out?" → Debug pattern
- "Is quantum computing a threat to our cryptography?" → Research pattern
- "Track our caching implementation from decision to deployment" → Design pattern
All examples use Python-style indentation (2 spaces per level):
->indented child = causal relationship with implicit block- No explicit
{}brackets needed - Preprocessor transforms to explicit blocks for parser
Every node includes:
source_file- Which .fs file it came fromline_number- Original source line (before preprocessing)timestamp- When it was parsed
Enables "show me the source" queries.
Hierarchical structure preserved:
- Questions have children (alternatives)
- Alternatives have children (implications)
- Thoughts have children (consequences)
- Enables tree traversal and depth queries
Five types of relationships:
alternative- from||markers under questionscauses- from->forward causationderives_from- from<-reverse causationtension- from><[axis]tradeoff markerstemporal- from=>time-based sequence
Three state types (stored in top-level states array):
decided- choices made with rationale and dateblocked- progress stopped with reason and since datecompleted- tasks finished with date
Linter enforces completeness:
- Tension markers MUST have axis labels (E001 error if missing)
- State markers MUST have required fields (E002 error if missing)
- Alternatives MUST have decision or parking (E006 error)
Can't hide behind vague articulations - structure forces clarity.
These examples are designed to enable computational queries. Future phases will implement:
Decision queries:
alternatives(question_id)- Find all options consideredwhy(decision_id)- Trace decision rationaletensions()- Map all tradeoffs
Debug queries:
why(error_id)- Backward trace to root causewhat_if(fix_id)- Forward trace impact of fixblocked()- Find current blockers
Research queries:
depth(node_id)- Measure complexitybranches(node_id)- Find alternative approachestensions()- Map competing constraints
Design queries:
timeline(root_id)- Reconstruct temporal sequencecompleted(since)- Track progressblocked(since)- Find blockers
See Phase 6 (Continuity Demo) for query implementations.
examples/
├── README.md # This file - navigation guide
├── decision.fs # Pattern 1 source (FlowScript)
├── decision.json # Pattern 1 IR (compiled)
├── decision-README.md # Pattern 1 guide (~200 lines)
├── debug.fs # Pattern 2 source
├── debug.json # Pattern 2 IR
├── debug-README.md # Pattern 2 guide (~150 lines)
├── research.fs # Pattern 3 source
├── research.json # Pattern 3 IR
├── research-README.md # Pattern 3 guide (~200 lines)
├── design.fs # Pattern 4 source
├── design.json # Pattern 4 IR
└── design-README.md # Pattern 4 guide (~200 lines)
13 files total - Complete golden example suite.
- Start with decision.fs - Simplest pattern, immediate value
- Read the pattern READMEs - Comprehensive guides with examples
- Try parsing - Use CLI to compile your own FlowScript
- Explore IR structure - See how FlowScript compiles to JSON
- Create your own - Adapt patterns to your use cases
- Study all 4 patterns - Understand full feature set
- Validate parser - All examples must parse correctly
- Test linter - Must catch violations, pass valid examples
- Implement queries - Use IR to build computational operations
- Add test coverage - Use patterns as regression tests
-
Spec folder (
/spec/) - Formal FlowScript specificationssemantics.md- Complete marker definitionsgrammar.md- EBNF grammarir.schema.json- JSON schema for IRlinter-rules.md- Complete linter rule definitionsgolden_examples_spec.md- Detailed pattern specifications
-
Toolchain (
TOOLCHAIN.md) - CLI usage guide- Parse command
- Lint command
- Validate command
Parser requirements (all must pass):
- ✅ Parse all 4 .fs files without errors
- ✅ Generate relationships arrays (NOT empty)
- ✅ Extract states into top-level states array
- ✅ Populate children arrays for hierarchical nodes
- ✅ Preserve provenance (source file, line numbers, timestamps)
- ✅ Handle all relationship types (alternative, causes, derives_from, tension, temporal)
- ✅ Extract modifiers (urgent, exploratory, locked, etc.)
Linter requirements (all must pass):
- ✅ decision.fs: 0 errors, 0 warnings
- ✅ debug.fs: 0 errors, 0 warnings
- ✅ research.fs: 0 errors, 0 warnings
- ✅ design.fs: 0 errors, 0 warnings
- ✅ Enforce E001 (tension axis required)
- ✅ Enforce E006 (alternatives need decision)
- ✅ Detect E004 (orphaned nodes) - with exemptions for actions/completions
IR validation (all must pass):
- ✅ All .json files validate against ir.schema.json
- ✅ Content-hash IDs consistent
- ✅ Provenance preserved
- ✅ Relationships bidirectional (source → target)
- ✅ States array populated with required fields
These golden examples embody FlowScript's core mission:
Not just notation - Computable substrate for memory Not just documentation - Queryable knowledge graphs Not just syntax - Forcing functions for cognitive clarity
Each pattern demonstrates:
- Structure → clarity (can't hide in vague prose)
- Compilation → computation (queries on semantic graphs)
- Forcing functions → completeness (required fields force thinking)
The goal: Enable AI partners to understand context deeply, not just read text linearly.
Last Updated: 2025-10-22 Session: 4a-continued-5g Phase: 4 (Golden Examples) COMPLETE Status: All 4 patterns validated - parser 100% functional, linter spec-aligned, 130/130 tests passing
Ready for Phase 5: Documentation updates using these canonical examples.