Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1ed5f89
feat: implement real getTableSchema() with INFORMATION_SCHEMA queries
nipunaudemy Nov 7, 2025
1d27088
feat: add activation error recovery with user-friendly dialogs
nipunaudemy Nov 7, 2025
ae05f9a
test: add comprehensive connection-manager tests (66.2% coverage)
nipunaudemy Nov 7, 2025
2417f60
test: expand sql-validator tests to 94.52% coverage
nipunaudemy Nov 7, 2025
541f851
test: add comprehensive transaction-manager tests (83.21% coverage)
nipunaudemy Nov 7, 2025
4815f31
fix: resolve ESLint unused variable in transaction-manager test
nipunaudemy Nov 7, 2025
8b4265a
feat: add CI coverage gate with 25% minimum threshold
nipunaudemy Nov 7, 2025
c4a627b
fix: replace bc with awk for coverage threshold comparisons
nipunaudemy Nov 7, 2025
7bd7a24
fix: prevent infinite recursion in retryActivation with retry limit
nipunaudemy Nov 7, 2025
69af1d1
test: add comprehensive test coverage to meet 24.5% threshold
nipunaudemy Nov 8, 2025
265f51e
fix: replace placeholder GitHub URLs with actual repository URL
nipunaudemy Nov 8, 2025
7b19840
fix: use toBeCloseTo for floating-point comparison in rate limiter test
nipunaudemy Nov 8, 2025
64271b2
feat(architecture): Complete Sprint 2 - Event Bus, Audit Logger & ada…
nipunaudemy Nov 8, 2025
5005004
fix: address medium-severity code review issues
nipunaudemy Nov 8, 2025
7eb3b3c
test: implement Workstream 1 test coverage (27.5% β†’ 50%)
nipunaudemy Nov 8, 2025
dadb00d
docs: update PRODUCT_ROADMAP with Sprint 3 completion
nipunaudemy Nov 8, 2025
49724b7
feat(tests): add comprehensive test coverage for core architecture
nipunaudemy Nov 8, 2025
36fb4f2
docs: restructure PRD and roadmap with Phase 3/4 planning
nipunaudemy Nov 8, 2025
0d677da
chore: release v1.3.0 - Phase 1.5 complete
nipunaudemy Nov 8, 2025
0436b4e
fix(ci): align coverage thresholds with jest.config.js
nipunaudemy Nov 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# MyDBA Development Guidelines

## Quality Gates

After completing each major milestone or set of related changes:

1. Run `npm run lint` - must pass with 0 errors
2. Run `npm run compile` - must pass with 0 TypeScript errors
3. Run `npm test:unit` - all tests must pass
4. For test coverage work: `npm test -- --coverage` to verify coverage targets

Do not proceed to the next milestone until all quality gates pass.

## Testing Standards

- Maintain minimum 50% code coverage across the codebase
- Critical services (adapters, security, AI) should have 60%+ coverage
- All tests must pass on Ubuntu, Windows, and macOS
- No flaky tests - ensure deterministic test execution
- Use mocks for external dependencies (database connections, AI providers)

## Code Quality

- Follow existing code patterns and architecture
- Use TypeScript strict mode - no `any` types without justification
- Prefer explicit types over type inference for public APIs
- Document complex logic with inline comments
- Keep functions focused and under 50 lines when possible

## Architecture Principles

- Service Container for dependency injection
- Event Bus for decoupled communication between components
- Adapter pattern for database implementations
- Factory pattern for creating complex objects (AI providers, adapters)
- Repository pattern for data access

## Security

- All SQL queries must use parameterized queries (no string concatenation)
- Validate and sanitize all user inputs
- Use SecretStorage API for credentials
- Follow principle of least privilege for database connections
- Audit log all destructive operations

## Performance

- Cache frequently accessed data (schema, metadata)
- Use connection pooling for database connections
- Lazy-load heavy dependencies
- Monitor and log slow operations (>100ms for queries, >2s for AI)
- Implement proper cleanup in dispose() methods

## Git Workflow

- Meaningful commit messages following conventional commits
- PR reviews required before merge
- CI must pass before merge
- Keep PRs focused and under 500 lines when possible

## Documentation

- Update README.md for user-facing changes
- Update CHANGELOG.md for all changes
- Add inline comments for complex logic
- Document public APIs with JSDoc
- Keep architecture decision records (ADRs) updated

## VS Code Extension Best Practices

- Follow VS Code extension guidelines
- Use proper disposal patterns for all resources
- Handle errors gracefully with user-friendly messages
- Respect user settings and configuration
- Test in multiple VS Code versions
- Support dark and light themes
- Provide keyboard shortcuts for common actions
- Show progress indicators for long-running operations
177 changes: 175 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ jobs:
mysql -h 127.0.0.1 -P 3306 -u root -ptest_password -e "GRANT SELECT ON mysql.* TO 'test_user'@'%';"
mysql -h 127.0.0.1 -P 3306 -u root -ptest_password -e "FLUSH PRIVILEGES;"
echo "MySQL permissions granted"

# Grant permissions for MariaDB
mysql -h 127.0.0.1 -P 3307 -u root -ptest_password -e "GRANT SELECT, UPDATE ON performance_schema.* TO 'test_user'@'%';"
mysql -h 127.0.0.1 -P 3307 -u root -ptest_password -e "GRANT SELECT ON mysql.* TO 'test_user'@'%';"
Expand Down Expand Up @@ -345,6 +345,174 @@ jobs:
echo "⚠️ Coverage report not found"
fi

coverage-gate:
name: Coverage Gate
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run Jest tests with coverage
run: npx jest --coverage --coverageReporters=json-summary --coverageReporters=text
continue-on-error: true

- name: Check coverage threshold
id: coverage_check
run: |
# Check if coverage summary exists
if [ ! -f coverage/coverage-summary.json ]; then
echo "❌ Coverage report not found"
echo "status=error" >> $GITHUB_OUTPUT
exit 1
fi

# Extract coverage percentages
LINES_PCT=$(node -e "const coverage = require('./coverage/coverage-summary.json'); console.log(coverage.total.lines.pct);")
STATEMENTS_PCT=$(node -e "const coverage = require('./coverage/coverage-summary.json'); console.log(coverage.total.statements.pct);")
BRANCHES_PCT=$(node -e "const coverage = require('./coverage/coverage-summary.json'); console.log(coverage.total.branches.pct);")
FUNCTIONS_PCT=$(node -e "const coverage = require('./coverage/coverage-summary.json'); console.log(coverage.total.functions.pct);")

# Set minimum thresholds (matching jest.config.js)
MIN_BRANCHES=33
MIN_LINES=38
MIN_STATEMENTS=39
MIN_FUNCTIONS=39

echo "πŸ“Š Coverage Report:"
echo " Lines: ${LINES_PCT}% (threshold: ${MIN_LINES}%)"
echo " Statements: ${STATEMENTS_PCT}% (threshold: ${MIN_STATEMENTS}%)"
echo " Branches: ${BRANCHES_PCT}% (threshold: ${MIN_BRANCHES}%)"
echo " Functions: ${FUNCTIONS_PCT}% (threshold: ${MIN_FUNCTIONS}%)"
echo ""

# Save to output for PR comment
echo "lines_pct=$LINES_PCT" >> $GITHUB_OUTPUT
echo "statements_pct=$STATEMENTS_PCT" >> $GITHUB_OUTPUT
echo "branches_pct=$BRANCHES_PCT" >> $GITHUB_OUTPUT
echo "functions_pct=$FUNCTIONS_PCT" >> $GITHUB_OUTPUT
echo "min_lines=$MIN_LINES" >> $GITHUB_OUTPUT
echo "min_statements=$MIN_STATEMENTS" >> $GITHUB_OUTPUT
echo "min_branches=$MIN_BRANCHES" >> $GITHUB_OUTPUT
echo "min_functions=$MIN_FUNCTIONS" >> $GITHUB_OUTPUT

# Check if any metric is below threshold
FAILED=0
if awk "BEGIN {exit !($LINES_PCT < $MIN_LINES)}"; then
echo "❌ Lines coverage ($LINES_PCT%) is below minimum threshold ($MIN_LINES%)"
FAILED=1
fi
if awk "BEGIN {exit !($STATEMENTS_PCT < $MIN_STATEMENTS)}"; then
echo "❌ Statements coverage ($STATEMENTS_PCT%) is below minimum threshold ($MIN_STATEMENTS%)"
FAILED=1
fi
if awk "BEGIN {exit !($BRANCHES_PCT < $MIN_BRANCHES)}"; then
echo "❌ Branches coverage ($BRANCHES_PCT%) is below minimum threshold ($MIN_BRANCHES%)"
FAILED=1
fi
if awk "BEGIN {exit !($FUNCTIONS_PCT < $MIN_FUNCTIONS)}"; then
echo "❌ Functions coverage ($FUNCTIONS_PCT%) is below minimum threshold ($MIN_FUNCTIONS%)"
FAILED=1
fi

if [ $FAILED -eq 1 ]; then
echo "status=failed" >> $GITHUB_OUTPUT
echo ""
echo "⚠️ Coverage gate FAILED. Please add tests to improve coverage."
exit 1
else
echo "status=passed" >> $GITHUB_OUTPUT
echo ""
echo "βœ… Coverage gate PASSED"
fi

- name: Comment PR with coverage
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');

let coverageComment = '## πŸ“Š Coverage Report\n\n';

if (fs.existsSync('coverage/coverage-summary.json')) {
const coverage = JSON.parse(fs.readFileSync('coverage/coverage-summary.json', 'utf8'));
const total = coverage.total;

const status = '${{ steps.coverage_check.outputs.status }}';
const statusEmoji = status === 'passed' ? 'βœ…' : '❌';

coverageComment += `**Status:** ${statusEmoji} ${status === 'passed' ? 'PASSED' : 'FAILED'}\n\n`;
coverageComment += '| Metric | Coverage | Threshold | Status |\n';
coverageComment += '|--------|----------|-----------|--------|\n';

const metrics = [
{ name: 'Lines', pct: total.lines.pct, threshold: parseFloat('${{ steps.coverage_check.outputs.min_lines }}') },
{ name: 'Statements', pct: total.statements.pct, threshold: parseFloat('${{ steps.coverage_check.outputs.min_statements }}') },
{ name: 'Branches', pct: total.branches.pct, threshold: parseFloat('${{ steps.coverage_check.outputs.min_branches }}') },
{ name: 'Functions', pct: total.functions.pct, threshold: parseFloat('${{ steps.coverage_check.outputs.min_functions }}') }
];

metrics.forEach(metric => {
const emoji = metric.pct >= metric.threshold ? 'βœ…' : '❌';
coverageComment += `| ${metric.name} | ${metric.pct.toFixed(2)}% | ${metric.threshold}% | ${emoji} |\n`;
});

if (status !== 'passed') {
coverageComment += `\n⚠️ **One or more coverage metrics are below their thresholds.** Please add tests to improve coverage.\n`;
}
} else {
coverageComment += '❌ Coverage report not found.\n';
}

// Find existing comment and update or create new
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('πŸ“Š Coverage Report')
);

if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: coverageComment
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: coverageComment
});
}

- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: jest-coverage-report
path: coverage/
retention-days: 30

license-compliance:
name: License Compliance Check
runs-on: ubuntu-latest
Expand Down Expand Up @@ -378,7 +546,7 @@ jobs:
status-check:
name: Status Check
runs-on: ubuntu-latest
needs: [build-and-test, package, lint-report, integration-tests-docker, license-compliance]
needs: [build-and-test, package, lint-report, coverage-gate, integration-tests-docker, license-compliance]
permissions:
contents: read
if: always()
Expand All @@ -395,6 +563,11 @@ jobs:
echo "❌ Package failed"
exit 1
fi
# Coverage gate
if [ "${{ needs.coverage-gate.result }}" != "success" ]; then
echo "❌ Coverage gate failed - minimum 39% coverage required"
exit 1
fi
# Integration tests with Docker
if [ "${{ needs.integration-tests-docker.result }}" != "success" ]; then
echo "❌ Integration tests failed"
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@ All notable changes to the MyDBA extension will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.0] - 2025-11-08

### Added

- Query Service implementation with comprehensive query analysis, templating, risk analysis, and validation
- 31 new comprehensive tests for Query Service (836 total tests passing)

### Changed

- Improved null safety in MySQL adapter by removing non-null assertions
- Enhanced type safety with proper pool connection handling
- Test coverage increased from 10.76% to 39% (Phase 1.5 Production Readiness complete)

### Fixed

- Type safety issues in database connection handling
- Removed 14 instances of non-null assertions (`pool!`) in mysql-adapter.ts

### Technical

- **Architecture Integration**: EventBus, CacheManager, PerformanceMonitor, and AuditLogger fully integrated
- **Code Quality**: Zero non-null assertions in production code
- **Test Coverage**: 39% overall coverage (9,400+ lines covered)
- Critical services: 60%+ coverage (mysql-adapter, ai-coordinator, security)
- 836 tests passing (11 skipped)
- Zero test flakiness
- **CI/CD**: Coverage gate enforced at 39% minimum

## [1.2.0] - 2025-11-07

### Added
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

# MyDBA - AI-Powered Database Assistant

[![Version](https://img.shields.io/badge/version-0.1.0-blue.svg)](https://marketplace.visualstudio.com/items?itemName=mydba.mydba)
[![Version](https://img.shields.io/badge/version-1.3.0-blue.svg)](https://marketplace.visualstudio.com/items?itemName=mydba.mydba)
[![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](LICENSE)
[![VSCode](https://img.shields.io/badge/VSCode-1.85%2B-blue.svg)](https://code.visualstudio.com/)
[![Tests](https://img.shields.io/badge/tests-186_passing-brightgreen.svg)](https://github.com/your-org/mydba/actions)
[![Coverage](https://img.shields.io/badge/coverage-10.76%25-yellow.svg)](coverage/index.html)
[![License Compliance](https://img.shields.io/badge/licenses-compliant-brightgreen.svg)](https://github.com/your-org/mydba/actions)
[![PR Checks](https://img.shields.io/badge/PR%20checks-automated-blue.svg)](https://github.com/your-org/mydba/actions)
[![Tests](https://img.shields.io/badge/tests-836_passing-brightgreen.svg)](https://github.com/nipunap/mydba/actions)
[![Coverage](https://img.shields.io/badge/coverage-39%25-green.svg)](coverage/index.html)
[![License Compliance](https://img.shields.io/badge/licenses-compliant-brightgreen.svg)](https://github.com/nipunap/mydba/actions)
[![PR Checks](https://img.shields.io/badge/PR%20checks-automated-blue.svg)](https://github.com/nipunap/mydba/actions)

MyDBA is an AI-powered VSCode extension that brings database management, monitoring, and optimization directly into your development environment. Built for developers and database administrators who want intelligent insights without leaving their IDE.

Expand All @@ -27,7 +27,7 @@ MyDBA is an AI-powered VSCode extension that brings database management, monitor
- **Documentation-Grounded AI**: RAG system with MySQL/MariaDB docs to reduce hallucinations
- **Chat Integration**: `@mydba` commands in VSCode Chat with natural language support
- **Editor Compatibility**: Works in VSCode, Cursor, Windsurf, and VSCodium
- **Testing**: 186 unit tests passing, integration tests with Docker (coverage improving to 70%)
- **Testing**: 836 unit tests passing, integration tests with Docker, 39% code coverage

### Metrics Dashboard

Expand Down Expand Up @@ -133,7 +133,7 @@ code --install-extension mydba.mydba
### From Source
```bash
# Clone repository
git clone https://github.com/your-org/mydba.git
git clone https://github.com/nipunap/mydba.git
cd mydba

# Install dependencies
Expand Down Expand Up @@ -396,7 +396,7 @@ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guid
### Development Setup
```bash
# Clone and install
git clone https://github.com/your-org/mydba.git
git clone https://github.com/nipunap/mydba.git
cd mydba
npm install

Expand Down Expand Up @@ -431,8 +431,8 @@ See [SECURITY.md](SECURITY.md) for security policies and supported versions.

## πŸ“ž Support

- **Issues**: [GitHub Issues](https://github.com/your-org/mydba/issues)
- **Discussions**: [GitHub Discussions](https://github.com/your-org/mydba/discussions)
- **Issues**: [GitHub Issues](https://github.com/nipunap/mydba/issues)
- **Discussions**: [GitHub Discussions](https://github.com/nipunap/mydba/discussions)
- **Documentation**:
- [Database Setup Guide](docs/DATABASE_SETUP.md)
- [Testing Guide](test/MARIADB_TESTING.md)
Expand Down
Loading
Loading