Skip to content

Commit a4ce95e

Browse files
feat: implement interactive engine simulator with message passing support (#347)
This PR adds Anthony's interaction timelines (https://github.com/anoma/Interactive-Engine-Timeline) adapted to the specs. --------- Co-authored-by: Anthony Hart <[email protected]>
1 parent 7482343 commit a4ce95e

File tree

8 files changed

+1595
-1
lines changed

8 files changed

+1595
-1
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
icon: material/animation-play
3+
search:
4+
exclude: false
5+
tags:
6+
- tutorial
7+
- example
8+
- interactive
9+
---
10+
# Engine Timeline Visualizer
11+
12+
## Engine communication
13+
14+
This interactive tutorial helps you explore how we envision [[Anomian|engines]]
15+
communicating through message passing. The visualization tool takes a JSON
16+
configuration and renders an animated timeline of message interactions between
17+
engines.
18+
19+
<div class="interactive-timeline-wrapper">
20+
<iframe
21+
class="interactive-timeline"
22+
src="app.html"
23+
width="100%"
24+
height="500px">
25+
</iframe>
26+
</div>
27+
28+
## Getting Started
29+
30+
### how to use
31+
32+
1. **Start the visualization** by clicking dotted message lines.
33+
2. **Hover over elements** to see detailed tooltips.
34+
3. **Watch the timeline scroll** automatically as messages propagate.
35+
4. **Observe engine states** update in real-time above each engine.
36+
37+
### Visual interface overview
38+
39+
- **Engine Nodes**: Coloured boxes at top representing system components.
40+
- **Timeline**: Vertical lines showing message history and potential paths.
41+
- **Message Types**:
42+
- **Dotted Lines**: Potential messages (click to send).
43+
- **Solid Lines**: Active message animations
44+
- **Faded Lines**: Historical messages
45+
46+
## Core Concepts
47+
48+
### message lifecycle
49+
50+
1. **Initiation**: Click potential message (dotted line).
51+
2. **Transmission**: Animation shows message travelling between engines.
52+
3. **Processing**: Receiving engine evaluates message against handlers.
53+
4. **Response**: New potential messages generated based on updated state.
54+
55+
### Configuration Guide
56+
57+
??? example "JSON Schema Structure"
58+
```json
59+
{
60+
"engines": [
61+
{
62+
"name": "EngineName",
63+
"initialState": any,
64+
"messageHandlers": [
65+
{
66+
"stateEffect": "return state + 1;",
67+
"guard": "return messageType === 'messageType1';",
68+
"generateMessages": [
69+
{
70+
"to": "TargetEngineName",
71+
"type": "responseMessageType",
72+
"payload": null
73+
}
74+
]
75+
}
76+
],
77+
"initialMessages": [
78+
{
79+
"to": "TargetEngineName",
80+
"type": "initialMessageType",
81+
"payload": null
82+
}
83+
]
84+
}
85+
]
86+
}
87+
```
88+
89+
??? note "Field Reference"
90+
91+
#### Engine configuration
92+
93+
| Field | Type | Description |
94+
|-------|------|-------------|
95+
| `name` | string | Unique engine identifier |
96+
| `initialState` | any | Starting state value |
97+
| `messageHandlers` | array | Message processing rules |
98+
| `initialMessages` | array | Initial outgoing messages |
99+
100+
#### Handler configuration
101+
102+
| Field | Context Variables | Description |
103+
|-------|-------------------|-------------|
104+
| `stateEffect` | `state`, `payload` | JS code returning new state |
105+
| `guard` | `state`, `payload`, `messageType` | JS condition for handler activation |
106+
| `generateMessages` | `state`, `payload` | Messages to send if guard passes |
107+
108+
### Advanced Features
109+
110+
!!! tip "Special Message Handling"
111+
112+
- **Loopback Messages**: Use `"to": "from"` to return messages to sender
113+
- **Dynamic Payloads**: Include JS code in payload strings:
114+
```json
115+
"payload": "return {timestamp: Date.now(), value: state}"
116+
```
117+
- **State Access**: Handlers can access:
118+
- `state`: Current engine state
119+
- `payload`: Received message data
120+
- `from`: Sender engine name
121+
- `messageType`: Type of received message
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Engine Timeline Visualizer</title>
7+
<link rel="stylesheet" href="/latest/assets/css/interactive_timelines.css">
8+
</head>
9+
<body>
10+
<div id="app">
11+
<div id="engines-container"></div>
12+
<div id="timeline-container"></div>
13+
</div>
14+
<script src="/latest/assets/js/interactive_timelines.js"></script>
15+
</body>
16+
</html>

0 commit comments

Comments
 (0)