Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 21, 2025

Extends the on: field parser to support human-readable trigger shorthands that compile deterministically to GitHub Actions trigger configurations. Covers 31+ patterns across source control, issues, discussions, releases, security, and external integration events.

Implementation

  • Unified parser (trigger_parser.go) with intermediate representation (TriggerIR)

    • Parses shorthand strings into structured event + filter combinations
    • Returns nil for simple triggers to preserve GitHub Actions compatibility
    • Only converts to objects when filters, types, or conditions are needed
    • Provides detailed error messages with syntax hints and examples
    • Includes source location tracking for precise error reporting
  • Pattern categories

    • Source control: push to <branch>, pull_request merged, pull_request affecting <path>
    • Issues/discussions: issue opened, discussion created + 10 more activity types
    • Manual: manual, manual with input <name>, workflow completed <workflow>
    • Security: dependabot pull request, security alert, code scanning alert
    • Repository: release published, repository starred, repository forked
    • External: api dispatch <event>
  • Integration via schedule_preprocessing.go

    • Tries slash command → label trigger → new trigger parser → schedule parser
    • Preserves backward compatibility with existing shorthand formats
    • Simple triggers like on: push remain as strings per GitHub Actions spec
  • Fuzz testing (trigger_parser_fuzz_test.go)

    • FuzzParseTriggerShorthand - Tests parser with arbitrary input (100+ seed cases)
    • FuzzTriggerIRToYAMLMap - Tests YAML map generation
    • Validates robustness against malformed input, edge cases, and adversarial inputs
    • Ensures no panics on empty strings, long inputs, special characters, or unicode
  • IDE-integrated error messages

    • All errors include source location with file:line:column format (IDE-parseable)
    • Displays what was provided, expected format, valid options, and concrete examples
    • Shows source context with line numbers and visual indicators (^^)
    • Errors integrate with compiler error infrastructure for consistent user experience
    • Example output:
      test.md:3:1: error: trigger syntax error: invalid push trigger format: 'push invalid'. 
      Expected format: 'push to <branch>' or 'push tags <pattern>'. 
      Example: 'push to main' or 'push tags v*'
      1 | ---
      2 | name: Test Workflow
      3 | on: push invalid
          ^^
      4 | ---
      5 | # Test
      

Examples

# Before: verbose YAML
on:
  pull_request:
    types: [closed]
  workflow_dispatch:

# After: concise shorthand
on: pull_request merged
# Branch filtering
on: push to main

# Path filtering
on: pull_request affecting src/**

# Security automation
on: dependabot pull request

# External triggers
on: api dispatch deploy-staging

Testing

  • 60+ unit tests covering all patterns
  • 14 integration tests for end-to-end compilation
  • 3 backward compatibility tests
  • 2 comprehensive fuzz tests with 100+ seed corpus
  • Error message validation for all trigger types with source location tracking
Original prompt

This section details on the original issue you should resolve

<issue_title>Trigger Short syntax</issue_title>
<issue_description>Extend the short form "on" syntax parser with , human-readable trigger shorthand and deterministically compiles it into valid GitHub Actions on: configurations. The parser/compiler must recognize common usage patterns, resolve intent unambiguously, and emit structured trigger semantics suitable for downstream code generation.

Update and unify existing parsers.

Core Responsibilities

  1. Parse shorthand triggers expressed in natural, minimal language.
  2. Classify triggers into canonical GitHub Actions event categories.
  3. Normalize intent by mapping shorthand to precise event + filter combinations.
  4. Validate determinism (no ambiguous interpretations).
  5. Produce an intermediate representation (IR) that can be rendered as YAML.

Trigger Pattern Taxonomy

1. Temporal Patterns

Used for scheduled automation.

  • daily
  • hourly
  • weekly
  • monthly

Semantic intent:
Time-based execution, abstracting cron syntax.


2. Source Control Patterns

Driven by Git activity.

  • push
  • push to <branch>
  • push tags <pattern>
  • pull request
  • pull request opened
  • pull request merged
  • pull request affecting <path>

Semantic intent:
React to repository state changes with optional branch, tag, or path filters.


3. Manual Invocation Patterns

Explicit human-triggered workflows.

  • manual
  • manual with input <name>
  • workflow completed <workflow>

Semantic intent:
User-initiated or workflow-chained execution.


4. Issue and Discussion Patterns

Workflow automation tied to project management.

  • issue opened
  • issue edited
  • issue closed
  • issue labeled <label>
  • discussion created

Semantic intent:
React to lifecycle events in issues or discussions, optionally scoped by labels.


5. Comment and Command Patterns

Text-driven control flows.

  • comment created
  • /<command>
  • /<command> in pull request
  • /<command> by member

Semantic intent:
Parse comment bodies for directives; often permission- or context-scoped.


6. Release and Repository Lifecycle Patterns

High-level repository events.

  • release published
  • release prereleased
  • repository starred
  • repository forked

Semantic intent:
Respond to distribution or engagement milestones.


7. Security and Dependency Patterns

Automated governance and safety.

  • dependabot pull request
  • security alert
  • code scanning alert

Semantic intent:
Automate responses to vulnerabilities and automated dependency changes.


8. External Integration Patterns

Triggers initiated outside GitHub.

  • api dispatch <event>

Semantic intent:
Allow external systems to invoke workflows via custom event payloads.


Determinism Rules

  • Each shorthand must map to exactly one GitHub Actions event family.
  • Optional qualifiers (branch, label, path, role) must be explicit.
  • No shorthand may rely on implicit defaults beyond common GitHub conventions.

Output Expectations

The agent should output:

  • A structured trigger IR (event, types, filters, conditions)
  • Sufficient metadata to generate valid GitHub Actions YAML
  • Clear errors for unsupported or ambiguous patterns

Non-Goals

  • Authoring full workflow YAML
  • Executing or validating workflows against GitHub APIs
  • Supporting undocumented or deprecated GitHub events

Success Criteria

The agent reliably converts shorthand triggers into precise, production-ready trigger definitions with zero ambiguity and minimal user input.</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 21, 2025
Copilot AI and others added 3 commits December 21, 2025 19:14
…support

- Create unified trigger parser with TriggerIR intermediate representation
- Add support for all trigger pattern categories from spec:
  - Source control (push, pull request with filters)
  - Issue and discussion events
  - Manual invocation (manual, workflow completed)
  - Comment patterns
  - Release and repository lifecycle
  - Security patterns (dependabot, security alerts)
  - External integration (api dispatch)
- Integrate with existing schedule preprocessing
- Maintain backward compatibility with existing parsers
- Add comprehensive unit and integration tests
- All tests passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ility

- Simple triggers like "push" and "pull_request" should remain as strings
- Only convert to objects when filters, types, or conditions are needed
- Update tests to reflect correct behavior
- All trigger tests now passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Update test to expect empty maps instead of nil for simple events
- This ensures proper YAML generation without null values
- All trigger-related tests now passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for human-readable trigger shorthand Add comprehensive trigger shorthand syntax parser Dec 21, 2025
Copilot AI requested a review from pelikhan December 21, 2025 19:34
@pelikhan
Copy link
Contributor

@copilot add fuzz tester for new parser.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2025

🤖 DIAGNOSTIC COMPLETE: Smoke Copilot No Firewall STATUS: ALL_UNITS_OPERATIONAL. MISSION_SUCCESS.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2025

✅ Firewall validation complete... Smoke Codex Firewall confirmed network sandboxing is operational. 🛡️

@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2025

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2025

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2025

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2025

🎉 Yo ho ho! Smoke Copilot Safe Inputs found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2025

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

Smoke Test Results

✅ File Writing: Created /tmp/gh-aw/agent/smoke-test-copilot-20414911508.txt
✅ Bash Tool: Verified file contents successfully
❌ Safe Input gh Tool: safeinputs-gh tool not available

Status: FAIL (1/3 tests passed)

Note: safeinputs-gh tool is missing. Cannot test GitHub CLI access via safe-inputs.

Ahoy! This treasure was crafted by 🏴‍☠️ Smoke Copilot Safe Inputs fer issue #7160 🗺️

@github-actions
Copy link
Contributor

Copilot Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP Testing (retrieved PRs)
  • ✅ File Writing (agent directory)
  • ✅ Bash Tool (verified file read)
  • ✅ GitHub MCP Default Toolset (get_me correctly unavailable)
  • ✅ Cache Memory (verified write/read)
  • ✅ Available Tools Display (45+ tools accessible)

Status: PASS

@pelikhan - All smoke tests passed successfully.

📰 BREAKING: Report filed by Smoke Copilot fer issue #7160 🗺️

@github-actions
Copy link
Contributor

Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved PRs successfully
  • ✅ File Write: Created /tmp/gh-aw/agent/smoke-test-copilot-20414911505.txt
  • ✅ Bash Tool: Verified file contents
  • ✅ Playwright MCP: Navigated to GitHub, title contains "GitHub"
  • ❌ Safe Input gh: Auth error (expected in this environment)

Overall Status: PASS (4/5 - gh tool limitation is environmental)

🤖 DIAGNOSTIC REPORT GENERATED BY Smoke Copilot No Firewall fer issue #7160 🗺️

@github-actions
Copy link
Contributor

Recent merged PRs: #7158 "Add --network host to Playwright Docker containers for localhost access"; #7163 "Exclude copilot and GitHub Actions bots from ai-moderator review"
OpenAI curl block: ✅
GitHub MCP merged PR fetch: ✅
File write/read /tmp/gh-aw/agent/smoke-test-codex-firewall-20414911509.txt: ✅
Blocked domain curl: ✅
Network: SANDBOXED
Overall: PASS

🔥 Firewall tested by Smoke Codex Firewall fer issue #7160 🗺️

@github-actions
Copy link
Contributor

Merged PR titles: Add --network host to Playwright Docker containers for localhost access; Add short trigger syntax for labeled events with explicit item types.
GitHub MCP: ✅
File write/read (/tmp/gh-aw/agent): ✅
Playwright title check: ✅
Cache memory write/read: ✅
safeinputs-gh (gh issues list --limit 3): ❌ (gh CLI unauthenticated)
Overall: FAIL

🔮 The oracle has spoken through Smoke Codex fer issue #7160 🗺️

@github-actions
Copy link
Contributor

Smoke Test Results - Claude Engine

Last 2 Merged PRs:

  • Add --network host to Playwright Docker containers for localhost access
  • Exclude copilot and GitHub Actions bots from ai-moderator review

Test Results:

  • ✅ GitHub MCP: Retrieved PR data successfully
  • ✅ File Writing: Created /tmp/gh-aw/agent/smoke-test-claude-20414911511.txt
  • ✅ Bash Tool: Verified file creation
  • ✅ Playwright MCP: Navigated to GitHub, title contains "GitHub"
  • ✅ Cache Memory: Created /tmp/gh-aw/cache-memory/smoke-test-20414911511.txt

Overall Status: ✅ PASS

💥 [THE END] — Illustrated by Smoke Claude fer issue #7160 🗺️

- Add FuzzParseTriggerShorthand to test ParseTriggerShorthand function
  - Validates parser handles arbitrary input without panicking
  - Tests all trigger pattern categories with valid/invalid variations
  - Includes edge cases: empty input, long strings, special characters
  - Validates TriggerIR structure consistency and correctness
- Add FuzzTriggerIRToYAMLMap to test YAML map generation
  - Tests various event types and type combinations
  - Validates output structure for all cases
- Comprehensive seed corpus with 100+ test cases
- Follows existing fuzz test patterns in codebase
- All fuzz tests pass validation

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 21, 2025

@copilot add fuzz tester for new parser.

Added comprehensive fuzz testing in commit 382afaf.

Created trigger_parser_fuzz_test.go with:

  • FuzzParseTriggerShorthand - Tests parser with arbitrary input (100+ seed cases)
  • FuzzTriggerIRToYAMLMap - Tests YAML map generation

The fuzz tests validate:

  • No panics on any input (empty, long strings, special characters, unicode)
  • Error handling consistency
  • TriggerIR structure validity for all recognized patterns
  • All GitHub Actions event types are handled correctly

Follows the existing fuzz test patterns in the codebase (similar to label_trigger_parser_fuzz_test.go and schedule_parser_fuzz_test.go).

@pelikhan
Copy link
Contributor

@copilot make sure the syntax error message uses the compiler error former and provides hints on valid syntax in the output .

- Add detailed error messages with valid syntax examples
- Include format expectations and valid options for each trigger type
- Provide specific examples in error messages (e.g., 'push to main', 'issue opened')
- List all valid activity types when invalid type is provided
- Errors now show: what was provided, what's expected, valid options, and examples
- Improves user experience when trigger syntax is incorrect

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 21, 2025

@copilot make sure the syntax error message uses the compiler error former and provides hints on valid syntax in the output .

Improved error messages in commit f43d3b5.

All trigger parser errors now include:

  • What was provided (with quotes for clarity)
  • Expected format specification
  • List of all valid options
  • Concrete usage examples

Example error output:

invalid push trigger format: 'push invalid'. 
Expected format: 'push to <branch>' or 'push tags <pattern>'. 
Example: 'push to main' or 'push tags v*'

The errors flow through the existing compiler error handling and are displayed to users with the failed workflow context.

Copilot AI changed the title Add comprehensive trigger shorthand syntax parser Add comprehensive trigger shorthand syntax parser with fuzz testing and helpful error messages Dec 21, 2025
@pelikhan
Copy link
Contributor

@copilot the error should provide a source location (using the compiler error infrastructure) to provide a better error message experience

- Update preprocessScheduleFields to accept markdown path and content
- Create createTriggerParseError helper to wrap errors with CompilerError
- Error messages now include file:line:column format (IDE-parseable)
- Display source context with line numbers and visual indicators
- Update all test calls to pass required parameters
- Improves debugging experience with precise error locations

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 21, 2025

@copilot the error should provide a source location (using the compiler error infrastructure) to provide a better error message experience

Added source location in commit 1903812.

Error messages now include:

  • File path and line:column (IDE-parseable format: file.md:3:1:)
  • Source context with line numbers
  • Visual indicator (^^) pointing to error location

Example:

test.md:3:1: error: trigger syntax error: invalid push trigger format: 'push invalid'. 
Expected format: 'push to <branch>' or 'push tags <pattern>'. 
Example: 'push to main' or 'push tags v*'
1 | ---
2 | name: Test Workflow
3 | on: push invalid
    ^^
4 | ---
5 | # Test

The location is determined by finding the on: field in the frontmatter, making it easy to navigate directly to the error in any IDE.

Copilot AI changed the title Add comprehensive trigger shorthand syntax parser with fuzz testing and helpful error messages Add comprehensive trigger shorthand syntax parser with fuzz testing and IDE-integrated error messages Dec 21, 2025
@pelikhan pelikhan marked this pull request as ready for review December 21, 2025 21:02
@pelikhan pelikhan merged commit 06bddac into main Dec 21, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/extend-short-syntax-parser branch December 21, 2025 21:04
github-actions bot added a commit that referenced this pull request Dec 21, 2025
Add documentation for the new shorthand label trigger syntax that supports:
- Basic format: on: issue labeled bug
- Space-separated labels: on: issue labeled bug enhancement
- Comma-separated labels: on: issue labeled bug, enhancement

Covers features from PRs #7153, #7160, and #7169.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trigger Short syntax

2 participants