[WIP] Refactor validation architecture for better consolidation #11900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.
Original prompt
This section details on the original issue you should resolve
<issue_title>[refactor] Semantic Function Clustering Analysis: Validation Architecture Consolidation Opportunity</issue_title>
<issue_description>Analysis of repository: githubnext/gh-aw
A comprehensive semantic analysis of 470 Go source files in the
pkg/directory has identified refactoring opportunities through function clustering and duplicate detection.Executive Summary
The codebase demonstrates excellent organization with strong helper file conventions and domain-driven design. The primary opportunity for improvement is completing the validation architecture consolidation already in progress.
Key Metrics:
Critical Finding: Validation Architecture Consolidation
Issue: The
pkg/workflow/package contains 28 separate validation files with duplicated validation patterns, though consolidation is already underway.Current State
Validation Files (28 files, ~4,000+ total lines):
sandbox_validation.go(188 lines)safe_outputs_domains_validation.go(215 lines)permissions_validation.go(60+ lines)docker_validation.go(130 lines)bundler_script_validation.go(148 lines)bundler_runtime_validation.go,bundler_safety_validation.gofirewall_validation.go,npm_validation.go,pip_validation.godispatch_workflow_validation.go,engine_validation.gofeatures_validation.go,mcp_config_validation.gorepository_features_validation.go,runtime_validation.gosecrets_validation.go,step_order_validation.gostrict_mode_validation.go,template_injection_validation.gotemplate_validation.go,agent_validation.gocompiler_filters_validation.go,dangerous_permissions_validation.gogithub_toolset_validation_error.go,mcp_gateway_schema_validation.gosafe_output_validation_config.go,safe_outputs_target_validation.goHelper Files (already consolidated):
validation_helpers.go(190 lines) - Consolidates reusable validation patternserror_helpers.go(200 lines) - Error type definitions and constructorsDuplicated Patterns Across 28 Files
1. Repeated
NewValidationError()CallsEvery validation file contains multiple calls with identical structure:
2. Common Field Validation Patterns
if field == "" { return NewValidationError(...) }if value < min || value > max { ... }if field == nil || len(field) == 0 { ... }3. Consistent Logging Pattern
Each file initializes:
logger := logger.New("workflow:*_validation")Example: Duplicated Empty String Validation
In
sandbox_validation.go:In
docker_validation.go:In
npm_validation.go:Recommendation: Create helper function:
Example: Duplicated Range Validation
In
runtime_validation.go:In
bundler_runtime_validation.go: