Skip to content

Address PR #27 review feedback: path normalization, tests, and conventions#28

Merged
data-douser merged 3 commits intofix/pr24-review-feedbackfrom
copilot/sub-pr-27
Feb 8, 2026
Merged

Address PR #27 review feedback: path normalization, tests, and conventions#28
data-douser merged 3 commits intofix/pr24-review-feedbackfrom
copilot/sub-pr-27

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

📝 Update Information

Primitive Details

  • Type: Both (Tools and Supporting Infrastructure)
  • Name: Multiple utilities and tools using path resolution
  • Update Category: Bug Fix, Code Quality, Test Coverage

⚠️ CRITICAL: PR SCOPE VALIDATION

This PR is for updating existing MCP server primitives and must ONLY include these file types:

ALLOWED FILES:

  • Server implementation files (server/src/**/*.ts)
  • Updated primitive implementations
  • Modified registration files (server/src/tools/*.ts)
  • Updated or new test files (server/test/**/*.ts)
  • Documentation updates (README.md, server docs)
  • Updated type definitions (server/src/types/*.ts)
  • Modified supporting library files (server/src/lib/*.ts)
  • Configuration updates if needed (package.json, tsconfig.json)

🚫 FORBIDDEN FILES:

  • Files unrelated to the primitive update
  • Temporary or test output files
  • IDE configuration files
  • Log files or debug output
  • Analysis or summary files

Rationale: This PR should contain only the files necessary to update and test the primitive.

🚨 PRs that include forbidden files will be rejected and must be revised.


🛑 MANDATORY PR VALIDATION CHECKLIST

BEFORE SUBMITTING THIS PR, CONFIRM:

  • ONLY server implementation files are included
  • NO temporary or output files are included
  • NO unrelated configuration files are included
  • ALL existing tests continue to pass
  • NEW functionality is properly tested

  • Impact Scope: Localized (path resolution utilities and related tests)

Update Metadata

  • Breaking Changes: No
  • API Compatibility: Maintained
  • Performance Impact: Neutral (normalization adds negligible overhead)

🎯 Changes Description

Current Behavior

Review feedback identified several issues:

  1. Import ordering violated alphabetical convention in language-server.ts
  2. Monitoring storage directory lost leading dot, breaking .gitignore patterns
  3. CODEQL_MCP_TMP_DIR accepted relative paths without normalization, causing unpredictable resolution
  4. Missing unit tests for getPackageVersion() and getUserWorkspaceDir()
  5. Missing test coverage for relative path resolution in CLI tools

Updated Behavior

  • Imports alphabetically ordered within categories
  • Monitoring storage restored to .ql-mcp-tracking (hidden, matches .gitignore)
  • CODEQL_MCP_TMP_DIR relative paths now normalized against process.cwd()
  • Comprehensive unit tests for version and workspace utilities
  • Test coverage for relative path resolution in tests, database, dir/packDir parameters

Motivation

Addresses all PR #27 review feedback to ensure code quality, correctness, and maintainability.

🔄 Before vs. After Comparison

Path Normalization

// BEFORE: Relative paths used as-is
const PROJECT_TMP_BASE = process.env.CODEQL_MCP_TMP_DIR || join(getPackageRootDir(), '.tmp');

// AFTER: Relative paths normalized against cwd
const PROJECT_TMP_BASE = process.env.CODEQL_MCP_TMP_DIR
  ? (isAbsolute(process.env.CODEQL_MCP_TMP_DIR) 
      ? process.env.CODEQL_MCP_TMP_DIR 
      : resolve(process.cwd(), process.env.CODEQL_MCP_TMP_DIR))
  : join(getPackageRootDir(), '.tmp');

Storage Location

// BEFORE: Missing leading dot
storageLocation: process.env.MONITORING_STORAGE_LOCATION || join(getProjectTmpBase(), 'ql-mcp-tracking')

// AFTER: Restored leading dot to match .gitignore
storageLocation: process.env.MONITORING_STORAGE_LOCATION || join(getProjectTmpBase(), '.ql-mcp-tracking')

Import Ordering

// BEFORE: Out of alphabetical order
import { getProjectTmpDir } from '../utils/temp-dir';
import { getResolvedCodeQLDir } from './cli-executor';
import { getPackageVersion } from '../utils/package-paths';

// AFTER: Alphabetically ordered within relative imports
import { getPackageVersion } from '../utils/package-paths';
import { getProjectTmpDir } from '../utils/temp-dir';
import { getResolvedCodeQLDir } from './cli-executor';

🧪 Testing & Validation

Test Coverage Updates

  • Existing Tests: All 384 unit tests pass
  • New Test Cases: Added 6 new test cases
  • Regression Tests: Covers path resolution edge cases
  • Edge Case Tests: Relative vs absolute path handling

Validation Scenarios

  1. Path Normalization: Tests verify CODEQL_MCP_TMP_DIR with relative paths resolves correctly
  2. Version Caching: Tests confirm getPackageVersion() reads package.json once and caches result
  3. Workspace Resolution: Tests validate env override and monorepo vs npm-installed fallback behavior
  4. Relative Path Resolution: Tests ensure CLI tools resolve relative tests, database, dir/packDir against user workspace

Test Results

  • Unit Tests: All pass (384/384 tests, +6 new)
  • Integration Tests: All pass except pre-existing network failure (45/46)
  • Manual Testing: Validated path resolution behavior
  • Performance Testing: No regressions detected

📋 Implementation Details

Files Modified

  • Core Implementation: server/src/utils/temp-dir.ts, server/src/utils/package-paths.ts
  • Supporting Libraries: server/src/lib/language-server.ts, server/src/lib/session-data-manager.ts
  • Tests: server/test/src/utils/package-paths.test.ts, server/test/src/lib/cli-tool-registry.test.ts
  • Documentation: Comments updated for clarity

Code Changes Summary

  • Error Handling: Path normalization prevents relative-path bugs
  • Type Safety: Maintained existing TypeScript types
  • Input Validation: Added isAbsolute() check for env var paths
  • Output Format: No changes to output formats

Dependencies

  • No New Dependencies: Uses existing path module functions

🔍 Quality Improvements

Bug Fixes

  • Issue: Relative paths in CODEQL_MCP_TMP_DIR could resolve unpredictably
  • Root Cause: No normalization of env var before use
  • Solution: Check isAbsolute() and resolve() against process.cwd()
  • Prevention: Added comment documenting normalization requirement

Code Quality Enhancements

  • Readability: Clearer comments on path resolution logic
  • Maintainability: Import ordering matches project conventions
  • Testability: New tests prevent regressions
  • Reusability: Path normalization pattern documented for reuse

🔗 References

Related Issues/PRs

Validation Materials

  • Test Cases: 6 new unit tests covering path resolution and utility functions
  • Performance Benchmarks: No measurable impact on test execution time

🚀 Compatibility & Migration

Backward Compatibility

  • Fully Compatible: No breaking changes
  • Deprecation Warnings: None
  • Breaking Changes: None

API Evolution

  • Enhanced Parameters: None
  • Improved Responses: None
  • Better Error Messages: Path resolution more predictable
  • Maintained Contracts: All API contracts preserved

👥 Review Guidelines

For Reviewers

Please verify:

  • ⚠️ SCOPE COMPLIANCE: PR contains only server implementation files
  • ⚠️ NO UNRELATED FILES: No temporary, output, or unrelated files
  • ⚠️ BACKWARD COMPATIBILITY: Existing functionality preserved
  • Functionality: Updates work as described
  • Test Coverage: All existing tests pass, new tests comprehensive
  • Performance: No performance regressions
  • Code Quality: Maintains or improves code quality
  • Documentation: Updated documentation accurate
  • Error Handling: Improved error handling
  • Type Safety: TypeScript types properly updated

Testing Instructions

# Full test suite
npm install
npm run build-and-test

# Server unit tests only
npm run test:server

# Code quality checks
npm run lint
npm run format:check

Validation Checklist

  1. Regression Testing: All 384 unit tests pass
  2. New Feature Testing: 6 new tests validate path normalization and utilities
  3. Performance Testing: No measurable performance impact
  4. Error Testing: Path edge cases covered
  5. Integration Testing: Integration tests pass (1 pre-existing network failure unrelated)
  6. Documentation Review: Comments accurate and helpful

📊 Impact Assessment

Performance Impact

  • Memory Usage: No change (minimal additional logic)
  • Execution Time: Negligible (single isAbsolute() and resolve() call at module init)
  • Throughput: No impact

Server Impact

  • Startup Time: No measurable impact
  • Runtime Stability: Improved (eliminates relative path ambiguity)
  • Resource Usage: No change
  • Concurrent Usage: Safe (module-level constant initialized once)

AI Assistant Impact

  • Enhanced Accuracy: More predictable path resolution
  • Better Coverage: Test coverage expanded
  • Improved Reliability: Eliminates edge case bugs
  • Enhanced User Experience: Hidden tracking files reduce noise

🔄 Deployment Strategy

Rollout Considerations

  • Safe Deployment: Safe for immediate deployment
  • Gradual Rollout: Not required (low-risk changes)
  • Monitoring: Standard monitoring sufficient
  • Rollback Plan: Simple revert if needed

Post-Deployment Validation

  • Monitoring: Monitor for path resolution errors (expect none)
  • User Feedback: No user-visible changes
  • Performance Tracking: CPU/memory usage unchanged
  • Error Tracking: Watch for CODEQL_MCP_TMP_DIR-related errors (expect reduction)

Update Methodology: This update follows best practices:

  1. ✅ Comprehensive backward compatibility analysis
  2. ✅ Thorough testing of all changes
  3. ✅ Performance impact assessment
  4. ✅ Clear documentation of changes
  5. ✅ Robust error handling improvements
  6. ✅ Maintained code quality standards

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 8, 2026 21:49
…d unit tests

Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix dynamic package version and respect CODEQL_MCP_TMP_DIR Address PR #27 review feedback: path normalization, tests, and conventions Feb 8, 2026
Copilot AI requested a review from data-douser February 8, 2026 22:01
@data-douser data-douser marked this pull request as ready for review February 8, 2026 22:09
@data-douser data-douser requested review from a team and enyil as code owners February 8, 2026 22:09
@data-douser data-douser merged commit 708f1e6 into fix/pr24-review-feedback Feb 8, 2026
@data-douser data-douser deleted the copilot/sub-pr-27 branch February 8, 2026 22:09
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.

2 participants