Skip to content

v5.1.1

Choose a tag to compare

@andrehrferreira andrehrferreira released this 24 Mar 09:55
· 162 commits to main since this release

Fixed — MCP Server Memory Leak & Orphan Processes

  • Orphan process prevention: Added SIGTERM, SIGHUP signal handlers and stdin close detection to rulebook-server.js. Previously only SIGINT was handled — when Claude Code exited, the MCP server kept running as an orphan, leaking memory indefinitely.
  • stdin polling safety net: Added 30s polling fallback for Windows environments where stdin close/end events may not fire reliably.
  • HNSW index memory cap: Added maxNodes option (default 50,000) to the in-memory HNSW vector index with FIFO eviction. Previously the index grew unboundedly as the BackgroundIndexer processed files, contributing to multi-GB memory usage over time.
  • PID file instance guard: Added mcp-server.pid lock file in .rulebook/ to prevent multiple MCP server instances for the same project. Detects and takes over stale PID files from dead processes.
  • autoCapture import caching: Cached the dynamic import('../memory/memory-hooks.js') after first call instead of re-importing on every tool invocation.
  • Flaky migrator test fix: Changed tests/migrator.test.ts to use unique OS temp directories instead of a fixed tmp-test-migrator/ path in the project root, eliminating EPERM errors from parallel test worker file contention.

Added — Incremental Implementation & Knowledge Base Integration

  • New Tier 1 Rule: incremental-implementation — Implement step by step, test each step, restart from scratch if stuck after 3 failed attempts. Enforces the principle: "The line between persistence and stubbornness is thin."
  • Knowledge Base as mandatory workflow — All agents now check .rulebook/knowledge/ before implementing and record patterns/anti-patterns after completing. Knowledge base is no longer optional side feature — it's integrated into every agent's workflow.
  • Agent MANDATORY_FOOTER updated — Every generated agent now includes:
    • Incremental implementation directive (decompose → implement one step → verify → repeat)
    • 3-attempt restart rule (stop, record anti-pattern, restart from scratch)
    • Knowledge base check-before / record-after directive
  • Agent template updates:
    • implementer: Workflow starts with KB check, implements incrementally, records learnings
    • tester: Includes cascade-fail restart rule and KB pitfall check
    • code-reviewer: Checklist validates against known patterns and anti-patterns
    • test-engineer: Checklist includes KB testing pitfalls
    • project-manager: Tracks KB health and reminds agents to record learnings
  • sql.js fallback fix: saveToDisk() now called after createSchema() to ensure .db file exists on disk for sql.js backend
  • 41 new memory store tests: Comprehensive CRUD, FTS5 search, sessions, persistence, code nodes, code edges, and sql.js fallback validation

Changed

  • Tier 1 rules list expanded from 5 to 6 (added incremental-implementation)
  • CLI rules add help text updated with complete list of all 10 available rules
  • rulebook init and rulebook update both auto-install the new rule