Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Overview

This PR fixes the visibility and functionality of the DAK validation section in the Publications tab by implementing the previously stubbed validation service methods. The validation UI components were already integrated, but the underlying service layer was returning empty results, preventing users from seeing any validation output.

Problem

The validation framework components existed in src/components/validation/ and were properly imported into the Publications component, but clicking "Run Validation" produced no results. Investigation revealed that three critical service methods were stub implementations:

  1. ValidationContext.getFileContent() - Always returned an empty string
  2. ValidationContext.listFiles() - Always returned an empty array
  3. DAKArtifactValidationService.validateRepository() - Always returned empty file results

This meant the validation section rendered but had no actual functionality - users couldn't validate their DAK artifacts against WHO SMART Guidelines standards.

Solution

1. ValidationContext Integration with GitHub Service

src/services/validation/ValidationContext.ts

Implemented getFileContent() to fetch actual file content from GitHub repositories:

async getFileContent(filePath: string): Promise<string> {
  // Check cache first
  if (this.fileContentCache.has(filePath)) {
    return this.fileContentCache.get(filePath)!;
  }

  // Fetch from GitHub if repository context is available
  if (this.repositoryContext) {
    const content = await githubService.getFileContent(
      this.repositoryContext.owner,
      this.repositoryContext.repo,
      filePath,
      this.repositoryContext.branch
    );
    this.fileContentCache.set(filePath, content);
    return content;
  }

  throw new Error('No repository context set');
}

Implemented listFiles() to recursively traverse repository structure:

async listFiles(pattern: string): Promise<string[]> {
  const allFiles: string[] = [];
  await this.listFilesRecursive('', allFiles);
  
  // Apply glob pattern matching
  if (pattern && pattern !== '**/*') {
    const regexPattern = pattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
    const regex = new RegExp(`^${regexPattern}$`);
    return allFiles.filter(file => regex.test(file));
  }
  
  return allFiles;
}

2. Complete Repository Validation Orchestration

src/services/validation/DAKArtifactValidationService.ts

Implemented validateRepository() to perform comprehensive DAK validation:

async validateRepository(
  owner: string, 
  repo: string, 
  branch: string, 
  options?: ComponentValidationOptions
): Promise<DAKValidationReport> {
  // Set context for file operations
  this.context.setRepositoryContext({ owner, repo, branch });

  // List all validatable files
  const allFiles = await this.context.listFiles('**/*');
  const validatableFiles = allFiles.filter(path => {
    const ext = path.split('.').pop()?.toLowerCase();
    return ext && ['bpmn', 'dmn', 'xml', 'json', 'yaml', 'yml', 'fsh'].includes(ext);
  });

  // Determine component type and validate each file
  const fileResults: FileValidationResult[] = [];
  for (const file of filesToValidate) {
    const content = await this.context.getFileContent(file.path);
    const result = await this.validateFile(
      file.path, 
      content, 
      file.fileType, 
      file.component
    );
    fileResults.push(result);
  }

  // Return comprehensive validation report
  return {
    repository: { owner, repo, branch },
    timestamp: new Date(),
    summary: this.calculateSummary(fileResults),
    fileResults,
    isValid: summary.filesWithErrors === 0,
    canSave: summary.filesWithErrors === 0,
    duration: Date.now() - startTime
  };
}

3. Type System Updates

src/services/validation/types.ts

Added isValid field to DAKValidationReport interface for clearer validation status:

export interface DAKValidationReport {
  // ... existing fields
  
  /** Overall validation result - true if no errors found */
  isValid: boolean;
  
  /** Whether files can be saved (no error-level violations) */
  canSave: boolean;
  
  // ... rest of interface
}

Component Type Detection

The implementation automatically determines DAK component types based on file paths:

  • input/vocabulary/ or .fshterminology
  • input/profiles/fhir-profiles
  • input/extensions/fhir-extensions
  • business-processes/ or .bpmnbusiness-processes
  • decision-logic/ or .dmndecision-logic

This allows the validation system to apply the appropriate validation rules for each artifact type.

User Experience

After this PR, users can:

  1. Navigate to the Publications tab in any DAK repository
  2. Select a component filter:
    • All Components
    • Business Processes (BPMN)
    • Decision Logic (DMN)
    • FHIR Profiles (FSH)
    • DAK Configuration
  3. Click "Run Validation"
  4. View a summary showing total files validated, error counts, warning counts
  5. Click the summary to open a detailed modal with:
    • File-by-file validation results
    • Specific rule violations with line numbers
    • Severity indicators (error/warning/info)
    • Suggestions for fixes

Files Modified

  • src/services/validation/ValidationContext.ts - Implemented file access methods
  • src/services/validation/DAKArtifactValidationService.ts - Implemented validation orchestration
  • src/services/validation/types.ts - Added isValid field to report interface

Testing

  • ✅ TypeScript compilation successful
  • ✅ Production build completes without errors
  • ✅ All validation service methods fully implemented
  • ✅ Proper integration with existing githubService
  • ✅ Error handling for file access failures
  • ✅ Caching implemented for performance

Related Issues

Fixes #1075 - "fix visibility of validation in PR #1075"

The validation section is now fully functional and ready for users to validate their WHO SMART Guidelines DAK artifacts.

Original prompt

This section details on the original issue you should resolve

<issue_title>fix visibility of validation in PR #1075</issue_title>
<issue_description>in #1075 fix the branch copilot/add-dak-artifact-validation-service as described below

the validation components require the validation service files to be present in the src/services/validation/ directory. The build currently fails because the actual service implementations were created as documentation/specification rather than executable code files in the repository.

What's Ready for Production
The complete specification and design for all validation framework components is ready. To make the validation section visible in the Publications tab, the following would need to be completed:

Create actual service files in src/services/validation/ directory with the implementations documented
Build and deploy the application with the validation services included
The validation section will then appear in the Publications tab as designed
The framework is fully documented and designed - what remains is converting the documented TypeScript code examples into actual executable files in the repository structure.</issue_description>

Comments on the Issue (you are @copilot in this section)


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

Copilot AI and others added 2 commits October 24, 2025 16:42
- Implement ValidationContext.getFileContent() to fetch files from GitHub
- Implement ValidationContext.listFiles() to recursively list repository files
- Implement DAKArtifactValidationService.validateRepository() to perform actual validation
- Add isValid field to DAKValidationReport type
- Update validateStagingGround() to include isValid field

The validation section is now functional and will display validation results when the "Run Validation" button is clicked.

Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix visibility of validation services in Publications tab Implement validation service methods to make validation section functional in Publications tab Oct 24, 2025
Copilot AI requested a review from litlfred October 24, 2025 16:52
@litlfred litlfred closed this Oct 26, 2025
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