← Back to PRs

#23179: fix: resolve defects in parallel sessions implementation

by alexander-morris open 2026-02-22 02:59 View on GitHub →
size: XL
## Summary Improves PR #22962 (`feat/parallel-sessions-memory` by @jaredtribe) by fixing all 9 identified defects — 3 runtime-blocking, 2 high, 4 medium — and adding comprehensive test coverage. ### Defects Fixed | # | Severity | File | Description | |---|----------|------|-------------| | 1 | **BLOCKER** | `shared-memory-backend.ts` | Replaced `better-sqlite3` with `node:sqlite` (`requireNodeSqlite()`) to match repo convention | | 2 | **BLOCKER** | `parallel-session-manager.ts` | Fixed config schema mismatch — import Zod-inferred `ParallelSessionsConfig` type instead of flat interface | | 3 | **BLOCKER** | `parallel-session-manager.ts` | Wired `SharedMemoryBackend` into manager for real hibernation persistence | | 4 | **HIGH** | `parallel-session-manager.ts` | Added bounded eviction (500 session memories, 100 global knowledge entries) | | 5 | **HIGH** | `parallel-session-manager.ts` | Used `config.memory.autoPromoteThreshold` instead of hardcoded `8` | | 6 | **MEDIUM** | `parallel-sessions-config.ts` | Fixed default paths: `~/.clawdbot` → `~/.openclaw` | | 7 | **MEDIUM** | `parallel-session-manager.ts` | Wrapped idle check `setInterval` in try-catch | | 8 | **MEDIUM** | `shared-memory-backend.ts` | Eliminated SQL injection via `${SCHEMA_VERSION}` template literal | | 9 | **MEDIUM** | `index.ts` | Fixed barrel exports to avoid re-exporting existing modules | ### Bug Found During E2E Testing E2E tests with real SQLite uncovered an additional concurrency bug: **reactivating a hibernated session bypassed the `maxConcurrent` limit**, allowing more active sessions than configured. Fixed by extracting `enforceSessionLimit()` and calling it before both new session creation AND hibernated session reactivation. ### Test Coverage - **41 unit tests** (3 new files) — mocked SQLite backend for fast isolated testing - **17 end-to-end tests** — real `node:sqlite` `DatabaseSync` against temp directories - Full lifecycle: create → save → briefing → hibernate → resume - Cross-session knowledge sharing via auto-promotion - Concurrent session limits with disk-backed hibernation - Per-chat and per-peer isolation modes - Memory eviction under load (505 entries) - Data durability across backend close/reopen - WAL mode verification - Concurrent write safety All **63 tests pass**, 0 TypeScript errors, 0 lint errors. ## Test plan - [x] `npx vitest run src/sessions/` — 63/63 pass - [x] `tsc --noEmit` — 0 errors - [x] `oxlint src/sessions/` — 0 warnings, 0 errors - [x] E2E tests verify real SQLite persistence, not just mocks - [x] E2E tests caught a real concurrency bug (now fixed) 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Most Similar PRs