You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update docs to reflect kernel restart bug (#34) resolution (#41)
- Update AGENTS.md with critical materializer determinism requirements
- Add detailed section about ctx.query() being forbidden in materializers
- Document specific commits (6e0fb4f, a1bf20d) that fixed the issue
- Provide code examples showing wrong vs correct materializer patterns
- Update HANDOFF.md to remove bug from critical issues, add to recent fixes
- Update ROADMAP.md to mark kernel session reliability as completed
- Upgrade auto kernel management priority due to more solid foundation
This prevents future developers from accidentally reintroducing side effects
in materializers that would cause LiveStore hash mismatches and kernel failures.
**NEVER use `ctx.query()` in materializers** - This was the root cause of kernel restart bug #34.
118
+
119
+
LiveStore requires all materializers to be **pure functions without side effects**. Any data needed by a materializer must be passed via the event payload, not looked up during materialization.
120
+
121
+
**What caused the bug:**
122
+
```typescript
123
+
// ❌ WRONG - This causes LiveStore.UnexpectedError materializer hash mismatch
**Rule**: If you need data in a materializer, add it to the event schema and pass it when committing the event. Materializers must be deterministic and reproducible.
150
+
151
+
### Recent Critical Fixes (December 2024)
152
+
153
+
**Kernel Restart Bug (#34) - RESOLVED** ✅
154
+
155
+
The project recently resolved a major stability issue where 3rd+ kernel sessions would fail to receive work assignments due to LiveStore materializer hash mismatches. This was caused by non-deterministic materializers using `ctx.query()` calls.
156
+
157
+
**What was broken:**
158
+
- ExecutionCompleted, ExecutionCancelled, and ExecutionStarted materializers were using `ctx.query()`
159
+
- This made them non-deterministic, causing LiveStore to shut down with "UnexpectedError materializer hash mismatch"
160
+
- Kernel restarts would accumulate terminated sessions and eventually fail
161
+
162
+
**How it was fixed (commits 6e0fb4f and a1bf20d):**
163
+
1.**Added cellId to event schemas**: ExecutionCompleted, ExecutionCancelled, ExecutionStarted now include `cellId` in payload
164
+
2.**Removed all ctx.query() calls**: Materializers now receive all needed data via event payload
165
+
3.**Updated all event commits**: All places that commit these events now pass `cellId` explicitly
166
+
4.**Made materializers pure functions**: No side effects, deterministic output for same input
167
+
168
+
**Impact:** Kernel sessions are now reliable across multiple restarts, enabling future automated kernel management.
169
+
170
+
**For Future Development:**
171
+
- Always check that new materializers are pure functions
172
+
- Never use `ctx.query()` in materializers - pass data via event payload
173
+
- Reference these commits when adding new execution-related events
174
+
- Test kernel restart scenarios when modifying execution flow
175
+
115
176
### Local-First Architecture
116
177
- All data operations happen locally first
117
178
- Events synced across clients via document worker
**Do NOT use manual timestamps in code or events.** LiveStore automatically handles all timing through its event sourcing system. Focus development on features and architecture rather than timestamp management.
217
278
279
+
**⚠️ CRITICAL: Do NOT use `ctx.query()` in materializers.** This causes LiveStore materializer hash mismatches and kernel restart failures (see bug #34 - RESOLVED in commits 6e0fb4f and a1bf20d). All materializers must be pure functions with all needed data passed via event payload.
280
+
218
281
**Testing is Critical**: Many claims about functionality need verification through proper integration tests. Core features exist but integration testing is minimal.
219
282
220
283
**AI Tool Calling**: The next major enhancement is enabling AI to actively participate in notebook development through function calling - creating cells, modifying content, and executing code.
**Impact**: Enables unlimited AI tool extensibility through Python ecosystem
171
172
172
-
### Priority 4: Auto Kernel Management (High Impact)
173
+
### Priority 3: Auto Kernel Management (High Impact) 🚀 UPGRADED
173
174
**Current friction**: Manual `NOTEBOOK_ID=xyz pnpm dev:kernel` per notebook
174
175
175
176
**Goal**: One-click notebook startup with automatic kernel lifecycle
176
177
178
+
**Foundation now solid**: With kernel restart bug (#34) fixed, automated management is much more viable
179
+
177
180
**Next actions**:
178
181
- Modify `pnpm dev` to auto-spawn kernels per notebook
179
182
- Add kernel health monitoring and restart capability
180
183
- Better error messages when kernels fail or disconnect
184
+
- Leverage fixed kernel session reliability for robust auto-restart
181
185
182
186
**Files to modify**:
183
187
- Root `package.json` - Update dev script
184
188
-`packages/web-client/src/components/notebook/NotebookViewer.tsx` - Status display
185
189
- Add kernel process management utilities
186
190
187
-
**Estimated effort**: 2-3 hours
188
-
**Impact**: Removes major user friction
191
+
**Estimated effort**: 2-3 hours (reduced due to fixed foundation)
192
+
**Impact**: Removes major user friction + leverages recent reliability improvements
189
193
190
194
### Priority 5: Rich Output Verification (Medium)
191
195
**Current state**: Code exists but integration unclear
@@ -262,7 +266,11 @@ pnpm test # Full test suite (27 passing, 13 skipped)
262
266
-**Performance claims unverified**: Need integration tests to validate speed/output claims
263
267
264
268
### Known Critical Issues
265
-
-**🐛 Kernel Restart Bug**: 3rd+ kernel sessions fail to receive work assignments due to LiveStore web client shutdowns when multiple terminated sessions accumulate (see https://github.com/rgbkrk/anode/issues/34 and branch `annoying-multiples-bug`)
269
+
-**None currently identified** - Major kernel restart bug (#34) resolved by cleaning up side effects in materializers
270
+
271
+
### Recent Fixes ✅
272
+
-**Kernel restart bug (#34)** - Fixed materializer side effects that caused 3rd+ kernel sessions to fail work assignments
273
+
-**LiveStore web client shutdowns** - Resolved accumulation of terminated sessions causing kernel communication failures
266
274
267
275
### Schema & Architecture Notes
268
276
- All packages use direct TypeScript imports: `../../../shared/schema.js`
Copy file name to clipboardExpand all lines: ROADMAP.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,15 @@
2
2
3
3
**Vision**: A real-time collaborative notebook system enabling seamless AI ↔ Python ↔ User interactions through local-first architecture.
4
4
5
-
**Current Status**: Core prototype with collaborative editing, basic Python execution, and AI integration with context awareness working. AI tool calling and rich outputs in active development.
5
+
**Current Status**: Core prototype with collaborative editing, basic Python execution, and AI integration with context awareness working. Major kernel restart bug (#34) resolved by fixing materializer side effects. AI tool calling and rich outputs in active development.
6
6
7
7
## Foundation Complete ✅
8
8
9
9
### Core Architecture
10
10
-**LiveStore event-sourcing** - Real-time collaborative state management
11
11
-**Direct TypeScript schema** - No build complexity, full type safety
12
12
-**Reactive execution queue** - Kernel work detection without polling
0 commit comments