From 437322fb80161c08e47c1fe1b8236bbfd23d070a Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 25 Jan 2026 09:08:57 +0100 Subject: [PATCH] docs: document test cleanup patterns and known issues in CLAUDE.md Added documentation about test cleanup patterns, known issues with session/case cleanup in specific test files, and manual cleanup commands for orphaned test resources. Co-Authored-By: Claude Opus 4.5 --- CLAUDE.md | 18 +++++++++++++++++- package.json | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 22706ace..f3a4c214 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -17,7 +17,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co Claudeman is a Claude Code session manager with a web interface and autonomous Ralph Loop. It spawns Claude CLI processes via PTY, streams output in real-time via SSE, and supports scheduled/timed runs. -**Version**: 0.1350 +**Version**: 0.1351 **Tech Stack**: TypeScript (ES2022/NodeNext, strict mode), Node.js, Fastify, Server-Sent Events, node-pty @@ -108,6 +108,22 @@ Unit tests (no port needed): respawn-controller, ralph-tracker, pty-interactive, **Test Safety**: `test/setup.ts` enforces max 10 concurrent screens, performs orphan cleanup, and protects its own process tree. You can safely run tests from within a Claudeman-managed session - the cleanup will not kill your own Claude instance. The respawn-controller tests use MockSession (not real screens). +**Test Cleanup Patterns**: Integration tests track resources in `createdSessions` and `createdCases` arrays, cleaned up by `afterAll`/`afterEach` hooks. However, some tests perform cleanup in the test body itself (e.g., `edge-cases.test.ts:273-302` creates 5 sessions and cleans them in a loop). If assertions fail before cleanup code runs, resources leak. + +**Known Cleanup Issues**: +- `pty-interactive.test.ts`: Uses `await session.stop()` at end of each test, not in `afterEach`. Test failures leave sessions running. +- `edge-cases.test.ts`: Multiple sessions created in test body with cleanup at end; failures leak sessions. +- Test cases (`~/claudeman-cases/`): Cases named `flow-test-*`, `ralph-track-loop-*`, `session-detail-*` may persist after test failures. + +**Manual Cleanup**: +```bash +# Remove orphaned test cases +rm -rf ~/claudeman-cases/flow-test-* ~/claudeman-cases/ralph-track-loop-* ~/claudeman-cases/session-detail-* + +# Kill orphaned test screens (only detached claudeman screens) +screen -ls | grep -E 'Detached.*claudeman' | cut -d. -f1 | xargs -I{} screen -S {} -X quit +``` + ### MCP Server ```bash diff --git a/package.json b/package.json index 096cf3c4..0bbc00dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claudeman", - "version": "0.1350", + "version": "0.1351", "description": "The missing control plane for Claude Code - run 20 autonomous agents with real-time monitoring and session persistence", "type": "module", "main": "dist/index.js",