Skip to content

[task] Extract detection and validation logic from compiler.go #3488

@github-actions

Description

@github-actions

Objective

Reduce the complexity of compiler.go (1600+ lines) by extracting detection and validation methods into more focused files.

Context

The main compiler.go file contains a mix of core compilation logic, validation logic, parsing logic, and configuration detection. This is Issue #2 from the semantic function clustering analysis (Priority 2: Medium Impact, Medium Effort). Extracting non-core logic will improve maintainability and separation of concerns.

Related to #3478

Approach

  1. Review compiler.go and identify methods suitable for extraction
  2. Extract detectTextOutputUsage to a detection-focused file (e.g., detection.go or text_output_detection.go)
  3. Extract computeAllowedDomainsForSanitization to a domain-related file (e.g., domain_sanitization.go or integrate into existing validation)
  4. Extract parseBaseSafeOutputConfig if it's primarily validation-focused
  5. Ensure all methods maintain their current functionality
  6. Update tests and imports
  7. Verify full test suite passes

Files to Modify

  • Update: pkg/workflow/compiler.go (remove extracted methods)
  • Create: pkg/workflow/detection.go or similar (for detection methods)
  • Create/Update: Domain-related file for sanitization logic
  • Update: Test files that reference these methods

Acceptance Criteria

  • compiler.go reduced in size by extracting non-core logic
  • detectTextOutputUsage moved to appropriate file
  • computeAllowedDomainsForSanitization moved to appropriate file
  • parseBaseSafeOutputConfig reviewed and potentially extracted
  • All extracted methods maintain current functionality
  • All tests pass
  • Better separation of concerns achieved
  • Compiler file focused on core compilation logic

Estimated Effort

3-4 hours

Benefits

  • Smaller, more focused compiler.go
  • Better separation of concerns
  • Improved testability of extracted components
  • Easier to navigate and understand the compilation process
  • Reduced complexity in the main compiler file

Note

This is a larger refactoring task. Consider breaking it down further if needed, starting with the most straightforward extraction (detectTextOutputUsage) and then proceeding to others.
Related to #3478

AI generated by Plan Command for #3478

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions