Skip to content

Refactor Ralph session tracking with KV-backed session mapping and configurable TTL#172

Merged
chriswritescode-dev merged 5 commits intomainfrom
ralph-kv-ttl-session-mapping-improvements
Mar 25, 2026
Merged

Refactor Ralph session tracking with KV-backed session mapping and configurable TTL#172
chriswritescode-dev merged 5 commits intomainfrom
ralph-kv-ttl-session-mapping-improvements

Conversation

@chriswritescode-dev
Copy link
Copy Markdown
Owner

Summary

  • Replace Ralph sessionId lookups with worktree-keyed KV session mapping
  • Add configurable KV TTL with 7-day default
  • Improve CLI status with --limit flag and null safety
  • Update agent prompts for 7-day TTL

Why

  • Eliminate expensive sessionId→worktreeName resolution by storing mapping in KV
  • Support configurable TTL for ephemeral state (default 7 days vs 24 hours)
  • Prevent KV store bloat by deleting resolved findings instead of updating

What Is Included

  • packages/memory/src/services/ralph.ts: registerSession/resolveWorktreeName/unregisterSession
  • packages/memory/src/hooks/ralph.ts: Watchdog/stall tracking uses worktreeName keys
  • packages/memory/src/index.ts: Plugin integration with new session mapping API
  • packages/memory/src/services/kv.ts: Configurable defaultTtlMs parameter
  • packages/memory/src/agents/*.ts: Updated prompt text (24h → 7 days)
  • packages/memory/src/cli/commands/status.ts: --limit flag, defensive field access
  • shared/src/schemas/memory.ts: RalphState fields made required

Type Of Change

  • Refactoring
  • New feature

Checklist

  • Code follows project style
  • Types updated
  • pnpm lint passes

@chriswritescode-dev chriswritescode-dev merged commit bcfb722 into main Mar 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant