refactor(01-01): wire ConcurrencyManager into AutoModeService

- AutoModeService now delegates to ConcurrencyManager for all running feature tracking
- Constructor accepts optional ConcurrencyManager for dependency injection
- Remove local RunningFeature interface (imported from ConcurrencyManager)
- Migrate all this.runningFeatures usages to concurrencyManager methods
- Update tests to use concurrencyManager.acquire() instead of direct Map access
- ConcurrencyManager accepts getCurrentBranch function for testability

BREAKING: AutoModeService no longer exposes runningFeatures Map directly.
Tests must use concurrencyManager.acquire() to add running features.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Shirone
2026-01-27 14:44:03 +01:00
parent b2b2d65587
commit 55dcdaa476
4 changed files with 135 additions and 190 deletions

View File

@@ -1,22 +1,19 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { ConcurrencyManager, type RunningFeature } from '@/services/concurrency-manager.js';
// Mock git-utils to control getCurrentBranch behavior
vi.mock('@automaker/git-utils', () => ({
getCurrentBranch: vi.fn(),
}));
import { getCurrentBranch } from '@automaker/git-utils';
const mockGetCurrentBranch = vi.mocked(getCurrentBranch);
import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest';
import {
ConcurrencyManager,
type RunningFeature,
type GetCurrentBranchFn,
} from '@/services/concurrency-manager.js';
describe('ConcurrencyManager', () => {
let manager: ConcurrencyManager;
let mockGetCurrentBranch: Mock<GetCurrentBranchFn>;
beforeEach(() => {
vi.clearAllMocks();
manager = new ConcurrencyManager();
// Default: primary branch is 'main'
mockGetCurrentBranch.mockResolvedValue('main');
mockGetCurrentBranch = vi.fn().mockResolvedValue('main');
manager = new ConcurrencyManager(mockGetCurrentBranch);
});
describe('acquire', () => {