Skip to content

Commit c487906

Browse files
authored
fix: fix beads auto-detection and address resulting test timeouts (#215)
* fix: fix beads auto-detection and address resulting test timeouts ## Summary Fixed the beads auto-detection bug that prevented the beads plugin from activating when TASK_BACKEND was not explicitly set. ## Root Cause The `BeadsPlugin.isEnabled()` method was checking `process.env.TASK_BACKEND === 'beads'` directly, but when auto-detection occurred (no env var set), the plugin would not activate even though the system correctly detected beads availability. ## Solution Updated `BeadsPlugin.isEnabled()` to use `TaskBackendManager.detectTaskBackend()` for consistent detection logic that handles both explicit configuration and auto-detection. ## Changes 1. **BeadsPlugin.isEnabled()** - Now uses TaskBackendManager.detectTaskBackend() to properly detect beads in all scenarios 2. **Test Updates** - Fixed tests that expected markdown format: - plan-management.test.ts: Added vi.stubEnv('TASK_BACKEND', 'markdown') - git-branch-detection.test.ts: Added beforeEach() to disable auto-detection - plugin-system-integration.test.ts: Updated 12 test suites to explicitly disable beads 3. **Timeout Fix** - Increased vitest testTimeout to 30s to account for auto-detection overhead ## Impact - Users no longer need to set TASK_BACKEND=beads manually for auto-detection - All 320 tests pass - All 66 beads-specific tests pass - Beads integration fully functional with auto-detection * refactor: remove redundant environment variable stubs in beads tests Since BeadsPlugin.isEnabled() now uses TaskBackendManager.detectTaskBackend(), we don't need to stub the TASK_BACKEND environment variable in tests. The mock of TaskBackendManager is sufficient to control the beads detection behavior. - Removed vi.stubEnv() calls in beads-plugin.test.ts - Removed vi.stubEnv() calls in beads-plugin-behavioral.test.ts - Removed corresponding vi.unstubAllEnvs() call This simplifies the test setup and makes it clearer that the behavior is controlled purely through the TaskBackendManager mock, not environment variables.
1 parent f25e583 commit c487906

11 files changed

Lines changed: 233 additions & 50 deletions

.beads/issues.jsonl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
{"id":"responsible-vibe-1.4.2","title":"Review and clean up code for production readiness","description":"Systematic code cleanup: 1) Remove any debug output or temporary logging, 2) Review TODO/FIXME comments, 3) Clean up experimental code, 4) Ensure proper error handling throughout the beads integration changes. Focus on BeadsIntegration class and start-development.ts changes.","status":"closed","priority":2,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-01-18T01:58:34.775435+01:00","created_by":"Oliver Jägle","updated_at":"2026-01-18T02:00:27.513595+01:00","closed_at":"2026-01-18T02:00:27.513595+01:00","close_reason":"Closed","dependencies":[{"issue_id":"responsible-vibe-1.4.2","depends_on_id":"responsible-vibe-1.4","type":"parent-child","created_at":"0001-01-01T00:00:00Z"}]}
2222
{"id":"responsible-vibe-1.4.3","title":"Update beads integration documentation","description":"Review and update the beads integration documentation (packages/docs/user/beads-integration.md) to reflect the implemented changes: 1) Sequential phase dependencies, 2) Enhanced task description guidance, 3) Updated command examples using 'bd close' instead of 'bd ready', 4) New createPhaseDependencies feature. Ensure documentation matches final implementation.","status":"closed","priority":2,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-01-18T01:58:41.798555+01:00","created_by":"Oliver Jägle","updated_at":"2026-01-18T02:01:24.433743+01:00","closed_at":"2026-01-18T02:01:24.433743+01:00","close_reason":"Closed","dependencies":[{"issue_id":"responsible-vibe-1.4.3","depends_on_id":"responsible-vibe-1.4","type":"parent-child","created_at":"0001-01-01T00:00:00Z"}]}
2323
{"id":"responsible-vibe-1.4.4","title":"Final validation and testing","description":"Run final validation: 1) Execute full test suite to ensure all changes work correctly, 2) Build project to verify no compilation errors, 3) Review test coverage for new functionality, 4) Validate that phase dependency logic and enhanced instructions work as expected. Ensure code is ready for production deployment.","status":"closed","priority":3,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-01-18T01:58:47.383309+01:00","created_by":"Oliver Jägle","updated_at":"2026-01-18T02:02:03.486303+01:00","closed_at":"2026-01-18T02:02:03.486303+01:00","close_reason":"Closed","dependencies":[{"issue_id":"responsible-vibe-1.4.4","depends_on_id":"responsible-vibe-1.4","type":"parent-child","created_at":"0001-01-01T00:00:00Z"}]}
24+
{"id":"responsible-vibe-10","title":"responsible-vibe: bugfix (development-plan-fix-auto-beads-integration.md)","description":"Responsible vibe engineering session using bugfix workflow for responsible-vibe","status":"open","priority":2,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-02-09T10:45:07.512336+01:00","created_by":"Oliver Jägle","updated_at":"2026-02-09T10:45:07.512336+01:00"}
25+
{"id":"responsible-vibe-10.1","title":"Reproduce","description":"You are in the bug reproduction phase. Work to reliably reproduce the reported bug by gathering specific information: • What are the exact OS, browser/runtime versions, and hardware specs? • What is the precise sequence of actions that trigger the bug? • What error messages, logs, or stack traces are available? • Does this happen every time or intermittently? • How many users are affected and what is the business impact? Create test cases that demonstrate the problem. Document your findings and create tasks as needed.","status":"open","priority":3,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-02-09T10:45:07.678198+01:00","created_by":"Oliver Jägle","updated_at":"2026-02-09T10:45:07.678198+01:00","dependencies":[{"issue_id":"responsible-vibe-10.1","depends_on_id":"responsible-vibe-10","type":"parent-child","created_at":"0001-01-01T00:00:00Z"}]}
26+
{"id":"responsible-vibe-10.2","title":"Analyze","description":"You are in the bug analysis phase. Examine the code paths involved in the bug, identify the root cause, and understand why the issue occurs. Use debugging tools, add logging, and trace through the problematic code. Document your analysis and create tasks as needed.","status":"open","priority":3,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-02-09T10:45:07.845043+01:00","created_by":"Oliver Jägle","updated_at":"2026-02-09T10:45:07.845043+01:00","dependencies":[{"issue_id":"responsible-vibe-10.2","depends_on_id":"responsible-vibe-10","type":"parent-child","created_at":"0001-01-01T00:00:00Z"},{"issue_id":"responsible-vibe-10.2","depends_on_id":"responsible-vibe-10.1","type":"blocks","created_at":"0001-01-01T00:00:00Z"}]}
27+
{"id":"responsible-vibe-10.3","title":"Fix","description":"Implement the solution based on your analysis. If exists, follow the design from . Before implementing, assess the approach: • How critical is this system? What is the blast radius if the fix causes issues? • Should this be a minimal fix or a more comprehensive solution? Make targeted changes that address the root cause without introducing new issues. Be careful to maintain existing functionality while fixing the bug.","status":"open","priority":3,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-02-09T10:45:08.043431+01:00","created_by":"Oliver Jägle","updated_at":"2026-02-09T10:45:08.043431+01:00","dependencies":[{"issue_id":"responsible-vibe-10.3","depends_on_id":"responsible-vibe-10","type":"parent-child","created_at":"0001-01-01T00:00:00Z"},{"issue_id":"responsible-vibe-10.3","depends_on_id":"responsible-vibe-10.2","type":"blocks","created_at":"0001-01-01T00:00:00Z"}]}
28+
{"id":"responsible-vibe-10.4","title":"Verify","description":"You are in the bug verification phase. Test the fix thoroughly to ensure the original bug is resolved and no new issues were introduced. Run existing tests, create new ones if needed, and verify the solution is robust.","status":"open","priority":3,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-02-09T10:45:08.19836+01:00","created_by":"Oliver Jägle","updated_at":"2026-02-09T10:45:08.19836+01:00","dependencies":[{"issue_id":"responsible-vibe-10.4","depends_on_id":"responsible-vibe-10","type":"parent-child","created_at":"0001-01-01T00:00:00Z"},{"issue_id":"responsible-vibe-10.4","depends_on_id":"responsible-vibe-10.3","type":"blocks","created_at":"0001-01-01T00:00:00Z"}]}
29+
{"id":"responsible-vibe-10.5","title":"Finalize","description":"You are in the finalize phase. This phase ensures code quality and documentation accuracy through systematic cleanup and review. **STEP 1: Code Cleanup** Systematically clean up development artifacts: 1. **Remove Debug Output**: Search for and remove all temporary debug output statements used during bug investigation. Look for language-specific debug output methods (console logging, print statements, debug output functions). Remove any debugging statements that were added for investigation purposes. 2. **Review TODO/FIXME Comments**: - Address each TODO/FIXME comment by either implementing the solution or documenting why it's deferred - Remove completed TODOs - Convert remaining TODOs to proper issue tracking if needed 3. **Remove Debugging Code Blocks**: - Remove temporary debugging code, test code blocks, and commented-out code - Clean up any experimental code that's no longer needed - Ensure proper error handling replaces temporary debug logging **STEP 2: Documentation Review** Review and update documentation to reflect the bug fix: 1. **Update Long-Term Memory Documents**: Based on what was actually implemented: • If exists, update if design details were refined or changed during the fix 2. **Compare Against Implementation**: Review documentation against the actual bug fix implemented 3. **Update Changed Sections**: Only modify documentation sections that have functional changes 4. **Remove Development Progress**: Remove references to investigation iterations, progress notes, and temporary decisions 5. **Focus on Final State**: Ensure documentation describes the final fixed state, not the debugging process 6. **Ask User to Review Document Updates**: Ask the document changes **STEP 3: Final Validation** - Run existing tests to ensure cleanup didn't break functionality - Verify documentation accuracy with a final review - Ensure bug fix is ready for production Update task progress and mark completed work as you finalize the bug fix.","status":"open","priority":3,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-02-09T10:45:08.365716+01:00","created_by":"Oliver Jägle","updated_at":"2026-02-09T10:45:08.365716+01:00","dependencies":[{"issue_id":"responsible-vibe-10.5","depends_on_id":"responsible-vibe-10","type":"parent-child","created_at":"0001-01-01T00:00:00Z"},{"issue_id":"responsible-vibe-10.5","depends_on_id":"responsible-vibe-10.4","type":"blocks","created_at":"0001-01-01T00:00:00Z"}]}
2430
{"id":"responsible-vibe-2","title":"Responsible-Vibe Development: responsible-vibe","description":"Development session using epcc workflow for responsible-vibe","status":"open","priority":2,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-01-18T02:16:58.742079+01:00","created_by":"Oliver Jägle","updated_at":"2026-01-18T02:16:58.742079+01:00"}
2531
{"id":"responsible-vibe-2.1","title":"Explore","description":"epcc workflow explore phase tasks","status":"closed","priority":2,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-01-18T02:16:58.967896+01:00","created_by":"Oliver Jägle","updated_at":"2026-01-18T10:10:34.63295+01:00","closed_at":"2026-01-18T10:10:34.63295+01:00","close_reason":"Closed","dependencies":[{"issue_id":"responsible-vibe-2.1","depends_on_id":"responsible-vibe-2","type":"parent-child","created_at":"0001-01-01T00:00:00Z"}]}
2632
{"id":"responsible-vibe-2.1.1","title":"Examine current proceed_to_phase implementation","status":"closed","priority":2,"issue_type":"task","owner":"github@beimir.net","created_at":"2026-01-18T02:17:43.747866+01:00","created_by":"Oliver Jägle","updated_at":"2026-01-18T02:18:38.69261+01:00","closed_at":"2026-01-18T02:18:38.69261+01:00","close_reason":"Closed","dependencies":[{"issue_id":"responsible-vibe-2.1.1","depends_on_id":"responsible-vibe-2.1","type":"parent-child","created_at":"0001-01-01T00:00:00Z"}]}

.beads/last-touched

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
responsible-vibe-9
1+
responsible-vibe-10.5
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"conversationId": "responsible-vibe-fix-auto-beads-integration-n6zwbu",
3+
"projectPath": "/Users/oliverjaegle/projects/privat/mcp-server/responsible-vibe",
4+
"epicId": "responsible-vibe-10",
5+
"phaseTasks": [
6+
{
7+
"phaseId": "reproduce",
8+
"phaseName": "Reproduce",
9+
"taskId": "responsible-vibe-10.1"
10+
},
11+
{
12+
"phaseId": "analyze",
13+
"phaseName": "Analyze",
14+
"taskId": "responsible-vibe-10.2"
15+
},
16+
{
17+
"phaseId": "fix",
18+
"phaseName": "Fix",
19+
"taskId": "responsible-vibe-10.3"
20+
},
21+
{
22+
"phaseId": "verify",
23+
"phaseName": "Verify",
24+
"taskId": "responsible-vibe-10.4"
25+
},
26+
{
27+
"phaseId": "finalize",
28+
"phaseName": "Finalize",
29+
"taskId": "responsible-vibe-10.5"
30+
}
31+
],
32+
"createdAt": "2026-02-09T09:45:09.010Z",
33+
"updatedAt": "2026-02-09T09:45:09.010Z"
34+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Development Plan: responsible-vibe (fix-auto-beads-integration branch)
2+
3+
*Generated on 2026-02-09 by Vibe Feature MCP*
4+
*Workflow: [bugfix](https://mrsimpson.github.io/responsible-vibe-mcp/workflows/bugfix)*
5+
6+
## Goal
7+
Fix the beads auto-detection bug: The `BeadsPlugin.isEnabled()` method checks `process.env.TASK_BACKEND === 'beads'` but when auto-detection is used (no env var set), the variable is never set. The `server-config.ts` correctly auto-detects beads and creates BeadsPlanManager/BeadsInstructionGenerator, but the BeadsPlugin's `isEnabled()` check fails because it only checks the env variable.
8+
9+
**Root Cause**: The auto-detection result from `TaskBackendManager.detectTaskBackend()` is not being used by `BeadsPlugin.isEnabled()`. The plugin checks `process.env.TASK_BACKEND` directly instead of using the detection result.
10+
11+
**Solution**: Pass the detection result to the plugin or have the plugin use the same detection logic.
12+
13+
## Reproduce
14+
<!-- beads-phase-id: responsible-vibe-10.1 -->
15+
### Tasks
16+
17+
*Tasks managed via `bd` CLI*
18+
19+
## Analyze
20+
<!-- beads-phase-id: responsible-vibe-10.2 -->
21+
22+
### Phase Entrance Criteria:
23+
- [ ] Bug has been successfully reproduced
24+
- [ ] Root cause location has been identified
25+
26+
### Tasks
27+
28+
*Tasks managed via `bd` CLI*
29+
30+
## Fix
31+
<!-- beads-phase-id: responsible-vibe-10.3 -->
32+
33+
### Phase Entrance Criteria:
34+
- [ ] Root cause is fully understood
35+
- [ ] Fix approach has been determined
36+
37+
### Tasks
38+
39+
*Tasks managed via `bd` CLI*
40+
41+
## Verify
42+
<!-- beads-phase-id: responsible-vibe-10.4 -->
43+
44+
### Phase Entrance Criteria:
45+
- [ ] Fix has been implemented
46+
- [ ] Code compiles without errors
47+
48+
### Tasks
49+
50+
*Tasks managed via `bd` CLI*
51+
52+
## Finalize
53+
<!-- beads-phase-id: responsible-vibe-10.5 -->
54+
55+
### Phase Entrance Criteria:
56+
- [ ] All tests pass
57+
- [ ] Bug is verified as fixed
58+
59+
### Tasks
60+
- [ ] Squash WIP commits: `git reset --soft <first commit of this branch>. Then, Create a conventional commit. In the message, first summarize the intentions and key decisions from the development plan. Then, add a brief summary of the key changes and their side effects and dependencies
61+
62+
*Tasks managed via `bd` CLI*
63+
64+
## Key Decisions
65+
1. **Root cause identified**: `BeadsPlugin.isEnabled()` checks `process.env.TASK_BACKEND === 'beads'` directly, but when auto-detection is used (no env var), the plugin's `isEnabled()` returns false even though `server-config.ts` already determined beads should be active via `TaskBackendManager.detectTaskBackend()`.
66+
67+
2. **Fix approach**: Remove the redundant `isEnabled()` check in `server-config.ts` since we already check `isBeadsBackend` before creating the plugin. The `isEnabled()` method in the plugin should either:
68+
- Option A: Use `TaskBackendManager.detectTaskBackend()` instead of checking env var directly
69+
- Option B: Accept the detection result in the constructor and use it
70+
- Option C: Since `server-config.ts` already gates plugin creation on `isBeadsBackend`, remove the `isEnabled()` check there entirely
71+
72+
3. **Chosen approach**: Option C - The check at line 166-168 in `server-config.ts` is redundant. We already determined `isBeadsBackend` is true before creating the plugin. The plugin's `isEnabled()` method should be updated to use `TaskBackendManager.detectTaskBackend()` for consistency.
73+
74+
## Notes
75+
- Pre-existing test failures in `plan-management.test.ts` and timeout issues in E2E tests are not caused by our fix
76+
- These failures occur because the tests expect markdown checkboxes (`- [ ]`) but when `bd` is available on the system, the beads format is used instead
77+
- All 40 beads-specific integration tests pass with our fix
78+
- Unit tests were updated to properly mock `TaskBackendManager` since it's in a different package (`@codemcp/workflows-core`)
79+
80+
---
81+
*This plan is maintained by the LLM and uses beads CLI for task management. Tool responses provide guidance on which bd commands to use for task management.*

packages/mcp-server/src/plugin-system/beads-plugin.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
BeadsIntegration,
2323
createLogger,
2424
PlanManager,
25+
TaskBackendManager,
2526
} from '@codemcp/workflows-core';
2627
import { BeadsTaskBackendClient } from '../components/beads/beads-task-backend-client.js';
2728

@@ -30,7 +31,8 @@ const logger = createLogger('BeadsPlugin');
3031
/**
3132
* BeadsPlugin class implementing the IPlugin interface
3233
*
33-
* Activation: Only when process.env.TASK_BACKEND === 'beads'
34+
* Activation: When beads backend is detected (either via TASK_BACKEND=beads env var
35+
* or auto-detection when bd CLI is available)
3436
* Priority: Sequence 100 (middle priority)
3537
* Encapsulation: All beads functionality contained within this plugin
3638
*/
@@ -60,9 +62,15 @@ export class BeadsPlugin implements IPlugin {
6062
}
6163

6264
isEnabled(): boolean {
63-
const enabled = process.env.TASK_BACKEND === 'beads';
65+
// Use TaskBackendManager to properly detect beads backend,
66+
// which supports both explicit TASK_BACKEND env var and auto-detection
67+
const taskBackendConfig = TaskBackendManager.detectTaskBackend();
68+
const enabled =
69+
taskBackendConfig.backend === 'beads' && taskBackendConfig.isAvailable;
6470
logger.debug('BeadsPlugin enablement check', {
65-
TASK_BACKEND: process.env.TASK_BACKEND,
71+
backend: taskBackendConfig.backend,
72+
isAvailable: taskBackendConfig.isAvailable,
73+
autoDetected: !process.env['TASK_BACKEND'],
6674
enabled,
6775
});
6876
return enabled;

packages/mcp-server/test/e2e/git-branch-detection.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ describe('Git Branch Detection', () => {
3131
});
3232

3333
describe('Plan File Naming Based on Branch', () => {
34+
beforeEach(() => {
35+
// Explicitly disable beads auto-detection to test markdown format
36+
vi.stubEnv('TASK_BACKEND', 'markdown');
37+
});
38+
3439
it('should use branch name in plan file when on feature branch (not default)', async () => {
3540
// Create a temp project on a feature branch
3641
const scenario = await createSuiteIsolatedE2EScenario({

packages/mcp-server/test/e2e/plan-management.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ describe('Plan Management', () => {
3030
let cleanup: () => Promise<void>;
3131

3232
beforeEach(async () => {
33+
// Explicitly disable beads auto-detection to test markdown format
34+
vi.stubEnv('TASK_BACKEND', 'markdown');
35+
3336
const scenario = await createSuiteIsolatedE2EScenario({
3437
suiteName: 'plan-management',
3538
tempProjectFactory: createTempProjectWithDefaultStateMachine,

0 commit comments

Comments
 (0)