[BUG] Test suite overwrites index.json with fake session IDs, kugetsu status reports ok #148

Closed
opened 2026-04-05 11:37:37 +02:00 by shoko · 0 comments
Owner

Bug: Running the test suite (test-kugetsu-v2.sh) can overwrite ~/.kugetsu/index.json with fake placeholder session IDs from setup_mock_sessions().

Root Cause:

  • setup_mock_sessions() writes hardcoded test IDs directly to ~/.kugetsu/index.json:
    cat > ~/.kugetsu/index.json << INDEX
    {
      "base": "ses_test_base_123",
      "pm_agent": "ses_test_pm_456",
      "issues": {}
    }
    
  • Test cleanup (test_cleanup) does not restore the original index
  • kugetsu status reports ok without validating that session IDs actually exist in opencode

Impact:

  • Daemon fails to fork sessions with Error: Session not found
  • All delegated tasks fail with Failed to start task after 3 attempts
  • System appears to work but is completely broken

Fix needed:

  1. kugetsu status should validate session IDs against opencode session list and report error if they do not exist
  2. Tests should use a separate test environment (e.g., KUGETSU_DIR=/tmp/test-kugetsu) instead of overwriting ~/.kugetsu
  3. Or: test cleanup should restore the original index.json after each test

Severity: High - system appears to work but is completely broken

**Bug:** Running the test suite (`test-kugetsu-v2.sh`) can overwrite `~/.kugetsu/index.json` with fake placeholder session IDs from `setup_mock_sessions()`. **Root Cause:** - `setup_mock_sessions()` writes hardcoded test IDs directly to `~/.kugetsu/index.json`: ```bash cat > ~/.kugetsu/index.json << INDEX { "base": "ses_test_base_123", "pm_agent": "ses_test_pm_456", "issues": {} } ``` - Test cleanup (`test_cleanup`) does not restore the original index - `kugetsu status` reports `ok` without validating that session IDs actually exist in opencode **Impact:** - Daemon fails to fork sessions with `Error: Session not found` - All delegated tasks fail with `Failed to start task after 3 attempts` - System appears to work but is completely broken **Fix needed:** 1. `kugetsu status` should validate session IDs against `opencode session list` and report `error` if they do not exist 2. Tests should use a separate test environment (e.g., `KUGETSU_DIR=/tmp/test-kugetsu`) instead of overwriting `~/.kugetsu` 3. Or: test cleanup should restore the original index.json after each test **Severity:** High - system appears to work but is completely broken
shoko added the high label 2026-04-05 11:37:37 +02:00
shoko closed this issue 2026-04-05 14:25:01 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/kugetsu#148