-
Notifications
You must be signed in to change notification settings - Fork 101
Add dispatching to support easy adding/replacement of agents #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d51908a
Add dispatch workflow architecture with workflow_dispatch triggers
ggallen b70ed7e
Test github stuff.
ggallen 12dcf69
Fix.
ggallen f4cced0
Add combined workflow.
ggallen afe646a
Fix paths.
ggallen bad2c2b
Fix asset name.
ggallen 208ac56
Fix dispatch.yml issues identified in PR review
ggallen 800872f
Address remaining review feedback
ggallen 044f8c0
Remove fork-specific workflow files
ggallen 6ce6d41
Address ralphbean's review feedback
ggallen 23badd7
Add comment explaining AGENT_PREFIX vs STAGE_PREFIX naming
ggallen c2f0f65
Remove all .github/ changes from PR
ggallen 0e531b6
Remove confusing comment from setup-agent-env.sh
ggallen 39b82b5
Fix critical dispatch.yml issues from review
ggallen 323a2b2
Address remaining review feedback
ggallen 09dfded
Add behavioral test assertions for dispatch and agent workflows
ggallen 5b41e35
Remove unnecessary DISPATCH_* env var indirection
ggallen 0e7c30b
Address low-severity review feedback
ggallen 5d52292
Update fix.yml workflow to work with dispatch architecture
ggallen b8e8f1c
Address dispatch.yml security and robustness feedback
ggallen 46e7457
Pass actual GitHub usernames as trigger_source instead of "bot"/"human"
ggallen aaf0901
Fix trigger_source username handling in scripts and documentation
ggallen 9fddb15
docs: update pre-fix.sh header to reflect username-based TRIGGER_SOURCE
ggallen 120147d
fix: address should-fix review feedback on trigger_source handling
ggallen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ __pycache__/ | |
| _site/ | ||
| bin/ | ||
| .playwright/ | ||
| .claude/settings.local.json | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
internal/scaffold/fullsend-repo/.github/workflows/dispatch.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| # Dispatcher workflow that fans out to agent workflows based on stage | ||
| name: Dispatch | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| stage: | ||
| description: 'Stage name (triage, code, review, fix)' | ||
| required: true | ||
| type: string | ||
| event_type: | ||
| description: 'Original GitHub event type' | ||
| required: true | ||
| type: string | ||
| source_repo: | ||
| description: 'Source repository (owner/repo)' | ||
| required: true | ||
| type: string | ||
| event_payload: | ||
| description: 'GitHub event payload as JSON' | ||
| required: true | ||
| type: string | ||
| trigger_source: | ||
| description: 'Trigger source username (for fix stage audit trail)' | ||
| required: false | ||
| type: string | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| dispatch: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| actions: write | ||
| contents: read | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
|
ggallen marked this conversation as resolved.
|
||
| - name: Generate token for triggering workflows | ||
| id: app-token | ||
| uses: actions/create-github-app-token@v3 | ||
| with: | ||
| client-id: ${{ vars.FULLSEND_FULLSEND_CLIENT_ID }} | ||
| private-key: ${{ secrets.FULLSEND_FULLSEND_APP_PRIVATE_KEY }} | ||
| owner: ${{ github.repository_owner }} | ||
| repositories: .fullsend | ||
|
|
||
| - name: Validate inputs | ||
| env: | ||
| STAGE: ${{ inputs.stage }} | ||
| SOURCE_REPO: ${{ inputs.source_repo }} | ||
| TRIGGER_SOURCE: ${{ inputs.trigger_source }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # Validate source_repo format (defense-in-depth before fan-out) | ||
| if [[ ! "$SOURCE_REPO" =~ ^[a-zA-Z0-9._-]+/[a-zA-Z0-9._-]+$ ]]; then | ||
| echo "::error::Invalid source_repo format: must be owner/repo" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Validate stage name format (alphanumeric, underscore, hyphen only) | ||
| if [[ ! "$STAGE" =~ ^[a-z][a-z0-9_-]*$ ]]; then | ||
| echo "::error::Invalid stage name: must start with lowercase letter and contain only [a-z0-9_-]" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Validate trigger_source format if provided (GitHub username with optional [bot] suffix) | ||
| if [[ -n "${TRIGGER_SOURCE:-}" ]]; then | ||
| if [[ ! "$TRIGGER_SOURCE" =~ ^[a-zA-Z0-9_-]+(\[bot\])?$ ]]; then | ||
| echo "::error::Invalid trigger_source format: must be alphanumeric with optional [bot] suffix" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| - name: Find and trigger agent workflows for stage | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| STAGE: ${{ inputs.stage }} | ||
| EVENT_TYPE: ${{ inputs.event_type }} | ||
| SOURCE_REPO: ${{ inputs.source_repo }} | ||
|
ggallen marked this conversation as resolved.
|
||
| EVENT_PAYLOAD: ${{ inputs.event_payload }} | ||
| TRIGGER_SOURCE: ${{ inputs.trigger_source }} | ||
|
ggallen marked this conversation as resolved.
|
||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| echo "Scanning for workflows with stage: $STAGE" | ||
|
|
||
| dispatched=0 | ||
| dispatched_workflows=() | ||
| scanned=0 | ||
| skipped=0 | ||
|
|
||
| for workflow in .github/workflows/*.yml .github/workflows/*.yaml; do | ||
| # Skip if file doesn't exist (glob expansion when no matches) | ||
|
ggallen marked this conversation as resolved.
|
||
| [[ -f "$workflow" ]] || continue | ||
|
|
||
| scanned=$((scanned + 1)) | ||
| workflow_name=$(basename "$workflow") | ||
|
|
||
| # Never dispatch ourselves (guard against accidental stage marker) | ||
| if [[ "$workflow_name" == "dispatch.yml" || "$workflow_name" == "dispatch.yaml" ]]; then | ||
| echo "Skipped $workflow_name (self-dispatch guard)" | ||
| skipped=$((skipped + 1)) | ||
| continue | ||
| fi | ||
|
|
||
| # Extract stage from comment (first line with # fullsend-stage:) | ||
| # Format: # fullsend-stage: <stage-name> | ||
| # Stage names: lowercase letter + [a-z0-9_-]* | ||
| # || true prevents pipefail abort when grep finds no match | ||
| workflow_stage=$(grep -E '^# fullsend-stage:' "$workflow" | head -1 | sed -n 's/^# fullsend-stage: *\([a-z][a-z0-9_-]*\).*/\1/p' || true) | ||
|
|
||
| # Skip if no stage marker | ||
| if [[ -z "$workflow_stage" ]]; then | ||
| echo "Skipped $workflow_name (no stage marker)" | ||
| skipped=$((skipped + 1)) | ||
| continue | ||
| fi | ||
|
|
||
| # Skip if stage doesn't match | ||
| if [[ "$workflow_stage" != "$STAGE" ]]; then | ||
| echo "Skipped $workflow_name (stage=$workflow_stage, wanted=$STAGE)" | ||
| skipped=$((skipped + 1)) | ||
| continue | ||
| fi | ||
|
|
||
|
ggallen marked this conversation as resolved.
|
||
| echo "Triggering $workflow_name for stage $STAGE" | ||
|
|
||
| # Build gh workflow run arguments | ||
| DISPATCH_ARGS=( | ||
| --repo "$GITHUB_REPOSITORY" | ||
| -f event_type="$EVENT_TYPE" | ||
| -f source_repo="$SOURCE_REPO" | ||
| -f event_payload="$EVENT_PAYLOAD" | ||
| ) | ||
|
|
||
| # Forward trigger_source if provided (fix stage only) | ||
| if [[ -n "${TRIGGER_SOURCE:-}" ]] && [[ "$STAGE" == "fix" ]]; then | ||
| DISPATCH_ARGS+=(-f trigger_source="$TRIGGER_SOURCE") | ||
| fi | ||
|
|
||
| if ! output=$(gh workflow run "$workflow_name" "${DISPATCH_ARGS[@]}" 2>&1); then | ||
| echo "::error::Failed to dispatch $workflow_name: $output" | ||
| exit 1 | ||
| fi | ||
| dispatched=$((dispatched + 1)) | ||
| dispatched_workflows+=("$workflow_name") | ||
| done | ||
|
ggallen marked this conversation as resolved.
|
||
|
|
||
| echo "Scanned $scanned workflow(s), skipped $skipped, dispatched $dispatched" | ||
|
|
||
| if [[ $dispatched -eq 0 ]]; then | ||
| echo "::error::No workflows found for stage: $STAGE" | ||
| exit 1 | ||
| fi | ||
|
ggallen marked this conversation as resolved.
|
||
|
|
||
| echo "Successfully dispatched $dispatched workflow(s) for stage $STAGE: ${dispatched_workflows[*]}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.