-
Notifications
You must be signed in to change notification settings - Fork 316
Description
You are working on implementing a concurrency policy computation system for the GitHub Agentic Workflows (gh-aw) tool. This Go-based GitHub CLI extension converts markdown workflow files into GitHub Actions YAML, and you need to add intelligent concurrency management.
CONTEXT: Issue #820 requests a sophisticated concurrency policy system that computes default policies from multiple sources and allows user overrides. The system should merge policies from different contexts (workflow, issue-specific, PR-specific) into a final concurrency configuration.
CORE REQUIREMENTS:
- Implement a policy merging system that combines multiple policy sources
- Support default policies: workflow (default), issue.number with cancel, pull_request with cancel, and alias policies
- Merge all policy keys and concatenate values to generate final concurrency policy
- Allow user-provided values to override computed policies
- Generate proper GitHub Actions concurrency YAML from the computed policies
TECHNICAL IMPLEMENTATION:
- Extend the workflow compiler in pkg/workflow/compiler.go to handle concurrency policy computation
- Modify the frontmatter parser in pkg/parser/ to parse concurrency policy configurations
- Implement JSON schema processing for policy definitions with structure like: {"*": {"id": "workflow"}, "issues": {"node": "issue.number"}, "pull_requests": {"node": "pull_requests.number"}}
- Add YAML generation logic to output valid GitHub Actions concurrency sections
- Ensure backward compatibility with existing workflows
KEY CONSTRAINTS:
- Follow existing Go code patterns and console message formatting using pkg/console/console.go
- Use the Makefile build system and ensure all changes pass make agent-finish validation
- Add comprehensive unit tests for policy merging scenarios
- Support different workflow trigger types (issues, pull_requests, schedule, manual)
- Validate policy configurations and provide helpful error messages
- Maintain performance during workflow compilation
TESTING REQUIREMENTS:
- Test basic policy merging with default plus context-specific policies
- Verify user override behavior takes precedence over computed policies
- Test different GitHub Actions trigger types and their appropriate concurrency rules
- Handle edge cases like empty policies, conflicting keys, invalid configurations
- Validate generated YAML syntax is correct for GitHub Actions
CODEBASE CONTEXT:
- This is a Go project using cobra CLI framework
- Main entry point is cmd/gh-aw/main.go
- Core packages are in pkg/cli/, pkg/parser/, pkg/workflow/
- Use existing patterns from similar compiler enhancements
- Follow the project's console formatting conventions for user-facing output
- Ensure generated .lock.yml files contain proper concurrency sections
Focus on implementing the policy computation logic that merges multiple policy sources into a final concurrency configuration, while maintaining the existing workflow compilation architecture and providing clear error handling and validation.