Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: vibe_check_mentor pattern detection fundamentally broken - regex doesn't handle verb conjugations #299

@kesslerio

Description

@kesslerio

Problem

The vibe_check_mentor has NEVER worked correctly despite ~30 PRs attempting to fix it. I've identified the root cause through systematic analysis.

Test Evidence:

query = "I'm thinking about building a custom HTTP client wrapper for the GitHub API"
result = vibe_check_mentor(query)

# EXPECTED: High-confidence detection of infrastructure_without_implementation
# ACTUAL: Zero detections, corrupted persona responses, generic advice

Actual Output:

{
  "immediate_feedback": {
    "summary": "No concerning patterns detected - looking good!",
    "confidence": 0.0,
    "detected_patterns": []
  },
  "perspectives": {
    "senior_engineer": {
      "message": "For the exact, http client, a custom:\n\n\n\n",
      "confidence": 0.68
    }
  }
}

Root Cause Analysis

Issue #1: Regex Patterns Don't Match Verb Conjugations

The patterns in data/anti_patterns.json use exact word matching with word boundaries \b, which fails to match common English grammar:

Current Pattern (BROKEN):

\b(?:custom|build|implement|create)\s+(?:our\s+own|new|custom)\s+(?:http|client|server|api|wrapper)

Test Proof:

import re

pattern = r'\b(?:custom|build|implement|create)\s+(?:our\s+own|new|custom)\s+(?:http|client|server|api|wrapper)'
text = 'building a custom HTTP client wrapper'

match = re.search(pattern, text, re.IGNORECASE)
print(f'Match found: {match is not None}')
# OUTPUT: Match found: False

Why it fails:

  • "building" != "build" (word boundary issue)
  • "implementing" != "implement"
  • "creating" != "create"
  • Pattern doesn't account for past tense, gerunds, or other conjugations

Fixed Pattern (WORKS):

\b(?:custom|build(?:ing)?|implement(?:ing)?|creat(?:e|ing))\s+(?:a\s+)?(?:our\s+own|new|custom)\s+(?:http|client|server|api|wrapper)

Verification:

pattern_fixed = r'\b(?:custom|build(?:ing)?|implement(?:ing)?|creat(?:e|ing))\s+(?:a\s+)?(?:our\s+own|new|custom)\s+(?:http|client|server|api|wrapper)'
text = 'building a custom HTTP client wrapper'

match = re.search(pattern_fixed, text, re.IGNORECASE)
print(f'Match found: {match is not None}')
# OUTPUT: Match found: True
print(f'Matched text: {match.group()}')
# OUTPUT: Matched text: building a custom HTTP

Issue #2: Corrupted Persona Responses

Persona messages are malformed:

"For the exact, http client, a custom:"

This suggests LLM prompt truncation or template issues in vibe_mentor_enhanced.py's generate_contribution() method.

Issue #3: Low Confidence Scores

When patterns don't match:

  • System returns confidence: 0.0 (should be 0.9+ for obvious anti-pattern)
  • Falls back to generic advice
  • Personas generate gibberish responses

Historical Context

Failed Attempts (~30 PRs):

Why All PRs Failed:
They assumed pattern detection worked and tried to improve response generation. But if patterns never match in the first place, no amount of response engineering helps.

Impact

  • Critical functionality broken: vibe_check_mentor can't detect obvious anti-patterns
  • False negatives: System says "looking good" for textbook violations
  • User trust destroyed: Generic/corrupted advice instead of specific guidance
  • Wasted engineering effort: ~30 PRs fixing symptoms, not root cause

Proposed Fix

Phase 1: Fix Regex Patterns (Critical)

Update ALL patterns in data/anti_patterns.json to handle verb conjugations:

Pattern categories needing fixes:

  1. infrastructure_without_implementation - all verb indicators
  2. symptom_driven_development - verb patterns
  3. complexity_escalation - action verb patterns
  4. documentation_neglect - planning verb patterns

Regex changes needed:

  • buildbuild(?:ing|s)?
  • implementimplement(?:ing|s|ed)?
  • createcreat(?:e|ing|es|ed)
  • planningplan(?:ning|s|ned)?
  • etc.

Phase 2: Fix Persona Response Generation

Investigate vibe_mentor_enhanced.py:

  • generate_contribution() method
  • MCP sampling prompt construction
  • Response validation and truncation handling

Phase 3: Add Regression Tests

Create test suite with real-world examples:

test_cases = [
    ("building a custom HTTP client", should_detect=True, confidence_min=0.7),
    ("implementing our own auth system", should_detect=True, confidence_min=0.7),
    ("creating a custom API wrapper", should_detect=True, confidence_min=0.7),
]

Acceptance Criteria

  • Test query "building a custom HTTP client wrapper" detects infrastructure_without_implementation with confidence > 0.7
  • Persona responses are coherent, specific, and reference the actual anti-pattern
  • No corrupted/truncated messages in output
  • Regression test suite passes for all verb variations
  • System provides specific technical guidance, not generic platitudes

Files Requiring Changes

  1. data/anti_patterns.json - fix ALL regex patterns
  2. src/vibe_check/tools/vibe_mentor_enhanced.py - investigate persona generation
  3. tests/ - add comprehensive regression tests

Related Issues/PRs


This is a P0 critical bug - the core functionality of vibe_check_mentor is fundamentally broken and has been since inception. All previous fixes addressed symptoms while the root cause (broken regex patterns) went undetected.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions