Skip to content

feat: Batch Retrieval and Failure Tracking MCP methods#33

Merged
srstomp merged 5 commits intomasterfrom
story-6d20cbf9-batch-retrieval
Feb 4, 2026
Merged

feat: Batch Retrieval and Failure Tracking MCP methods#33
srstomp merged 5 commits intomasterfrom
story-6d20cbf9-batch-retrieval

Conversation

@srstomp
Copy link
Copy Markdown
Owner

@srstomp srstomp commented Feb 4, 2026

Summary

Implements story-6d20cbf9: ohno MCP Batch Retrieval and Failure Tracking

This adds new MCP methods to ohno for batch-based task retrieval and failure tracking, moving dependency filtering, priority ordering, and blocker checking from the coordinator to ohno.

New Features

  • Failure Records Storage - New task_failures table for tracking task failures with type, reason, and attempt
  • Needs Rework Flag - needs_rework boolean flag on tasks with auto-clear on completion
  • record_task_failure MCP tool - Records failures for pattern learning (spec/quality/implementation types)
  • get_next_batch MCP tool - Smart batch retrieval with:
    • Tasks where status=todo OR needs_rework=1
    • Filters out tasks with unmet dependencies
    • Orders by epic priority (P0→P3) then created_at
    • Attaches failure_context for rework tasks
    • Configurable batch size (default 3, max 5)

Tasks Completed

  • task-137358d6: Add failure records storage to database
  • task-80960bdb: Add needs-rework task status or flag
  • task-4f665a26: Add record_task_failure MCP method
  • task-f15770f3: Add get_next_batch MCP method

Test plan

  • All 490 tests passing (178 core + 190 MCP + 122 CLI)
  • New tests for failure records (9 tests)
  • New tests for needs_rework flag (10 tests)
  • New tests for record_task_failure MCP (17 tests)
  • New tests for get_next_batch MCP (28 tests)

🤖 Generated with Claude Code

srstomp and others added 5 commits February 4, 2026 10:40
- Added CREATE_TASK_FAILURES_TABLE schema with fields: id, task_id, failure_type, failure_reason, attempt, created_at
- Added index on task_id for efficient querying
- Added FailureType enum and TaskFailure interface to types.ts
- Added generateFailureId() utility function
- Implemented addTaskFailure() and getTaskFailures() methods in TaskDatabase
- Exported new types and schema from index.ts
- Added comprehensive test coverage with 9 passing tests

Test coverage includes:
- Adding failure records with all fields
- Optional attempt parameter handling
- All failure types (spec, quality, implementation)
- Querying failures by task_id
- Correct ordering (DESC by created_at)
- Schema validation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Added comprehensive test coverage for needs_rework flag in db.test.ts
- Added set_needs_rework tool to MCP server with schema and handler
- Tests verify flag can be set/cleared, persists across reloads, and auto-clears on task completion
- MCP tool allows marking tasks for rework via API

Test coverage includes:
- Setting and clearing needs_rework flag
- Activity logging when flag is modified
- Auto-clearing on task completion (done/archived)
- Flag persistence across database reloads
- Default value of 0 for new tasks
- Integration with getTasks query

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The test "should return failures ordered by created_at DESC" was creating
a promise without awaiting it, causing the test to complete while the
promise was still pending. This left the database in an inconsistent state
and caused an "unhandled rejection: Database closed" error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add RecordFailureSchema with task_id, failure_type, reason, and optional attempt
- Add record_task_failure tool definition to TOOLS array
- Implement handler that calls db.addTaskFailure()
- Returns { success: true, failure_id: string }
- Add comprehensive tests for schema validation and handler
- Validates failure_type as enum: spec, quality, or implementation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add BatchTask interface extending Task with failure_context field
- Implement getNextBatch(size) method in TaskDatabase
  - Returns tasks where status=todo OR needs_rework=1
  - Filters out tasks with unmet blockedBy dependencies
  - Orders by epic priority (P0 first), then created_at
  - Limits to size (default 3, max 5)
  - Attaches failure_context from getTaskFailures() for tasks with needs_rework=1
- Add get_next_batch MCP tool with batch_size parameter (default 3, max 5)
- Add comprehensive tests for both db method and MCP tool
  - 15 tests for getNextBatch in db.test.ts
  - 8 tests for get_next_batch handler in server.test.ts
  - Schema validation tests for GetNextBatchSchema

All tests passing (190 MCP tests, 178 core tests, 122 CLI tests)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude bot commented Feb 4, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@srstomp srstomp merged commit 3b73801 into master Feb 4, 2026
2 checks passed
@srstomp srstomp deleted the story-6d20cbf9-batch-retrieval branch February 4, 2026 12:24
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