Implement lock-for-agent feature for issues#6245
Conversation
|
@copilot restart |
- Add LockForAgent field to WorkflowData struct - Parse lock-for-agent from on.issues configuration - Add lock step to activation job when enabled - Add unlock step to conclusion job (runs always, even on failure) - Pass lock-for-agent status to reaction script - Update reaction message to indicate issue is locked - Add comprehensive tests for lock-for-agent functionality - Recompile all workflows with updated JavaScript Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot add tests for JavaScript files |
I've completed the lock-for-agent feature implementation: What was implemented:
Key features:
Testing:
Commit: 5b16f9b Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot If the issue is already locked, do not lock/unlock. |
- Add lock-issue.test.cjs with 6 test cases - Add unlock-issue.test.cjs with 7 test cases - Test successful lock/unlock operations - Test error handling for missing issue number - Test API error handling (rate limits, permissions) - Test non-Error exception handling - Test different issue numbers - Verify no lock_reason parameter is provided (lock-issue) - All tests pass successfully Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added comprehensive JavaScript tests: lock-issue.test.cjs (6 tests):
unlock-issue.test.cjs (7 tests):
All 13 JavaScript tests pass. Commit: b16861e |
|
@copilot enable for ai-moderator agentic workflow |
…oderator - Update lock-issue.cjs to check if issue is already locked before locking - Update unlock-issue.cjs to check if issue is locked before unlocking - Skip lock operation if issue is already locked - Skip unlock operation if issue is not locked - Update tests to cover new behavior (7 tests for lock-issue, 8 for unlock-issue) - Enable lock-for-agent feature in ai-moderator workflow - All 15 JavaScript tests pass Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Enabled on:
issues:
types: [opened]
lock-for-agent: trueThe workflow now locks issues during moderation to prevent concurrent modifications. The compiled workflow includes both lock and unlock steps with the new smart status checking. Commit: 9b68f8f
Updated both scripts to check lock status before taking action: lock-issue.cjs:
unlock-issue.cjs:
All tests updated to verify the new behavior. Commit: 9b68f8f |
| } | ||
|
|
||
| core.info(`Locking issue #${issueNumber} for agent workflow execution`); | ||
|
|
There was a problem hiding this comment.
- set output to indicate that the issue needs to be unlocked (expose as job output too)
- use the output in unlock step in conclusion job as if condition
There was a problem hiding this comment.
Implemented output tracking and conditional unlock:
Lock Step Output:
- Sets
lockedoutput:"true"when successfully locked,"false"otherwise - Exposed as job output:
issue_locked: ${{ steps.lock-issue.outputs.locked }}
Unlock Condition:
- Checks
needs.activation.outputs.issue_locked == 'true' - Three-part condition:
always() && github.event.issue.number && needs.activation.outputs.issue_locked == 'true' - Only unlocks if activation job successfully locked the issue
Benefits:
- Prevents unlock attempts when issue was already locked
- Provides visibility into lock operations
- Maintains precise control over unlock behavior
Commit: 3962c98
- lock-issue.cjs now sets 'locked' output ('true' when locked, 'false' otherwise)
- Activation job exposes issue_locked output from lock-issue step
- Unlock step in conclusion job checks needs.activation.outputs.issue_locked
- Only unlocks if the activation job successfully locked the issue
- Prevents unlock attempts when issue was already locked
- Updated tests to verify output behavior in all scenarios
- All 15 JavaScript tests pass, all 4 Go tests pass
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implements the
lock-for-agentoptional boolean field for theon.issuestrigger in workflow frontmatter. When enabled, issues are automatically locked during agent workflow execution and unlocked upon completion to prevent concurrent modifications.Implementation
Frontmatter Configuration
Key Features
Lock Step: Added to activation job, locks the issue before agent execution
github.event.issue.number)lock-issue.cjsJavaScript (already registered with bundler)lockedoutput to"true"when successfully locked,"false"otherwiseissue_lockedoutput exposed from activation job for downstream useUnlock Step: Added to conclusion job, unlocks the issue after completion
always()condition to run even on workflow failureunlock-issue.cjsJavaScript (already registered with bundler)needs.activation.outputs.issue_locked == 'true', ensuring we only unlock issues we lockedReaction Message: When reactions are enabled, adds a 🔒 lock notification to the activation comment indicating the issue has been locked
Event Compatibility: Fully compatible with other event types (pull_request, discussion, etc.) - lock steps only execute in issue context
Changes Made
Compiler:
LockForAgentfield toWorkflowDatastructlock-for-agentfromon.issuesconfiguration inparseOnSectionalways()condition and output-based checkissue_lockedoutput to activation jobJavaScript:
add_reaction_and_edit_comment.cjsto display lock notification whenGH_AW_LOCK_FOR_AGENTenvironment variable is setlock-issue.cjsandunlock-issue.cjsnow check the issue's lock status usinggithub.rest.issues.get()before performing operationslock-issue.cjssetslockedoutput to track whether the issue was successfully lockedTests:
lock_for_agent_test.go): 4 comprehensive test caseslock-issue.test.cjs: 7 test cases covering successful operations, error handling, validation, skip-when-already-locked behavior, and output verificationunlock-issue.test.cjs: 8 test cases covering successful operations, error handling, edge cases, and skip-when-not-locked behaviorEnabled in Production: Added
lock-for-agent: trueto.github/workflows/ai-moderator.mdto prevent concurrent modifications during AI moderationTesting
always()conditionOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.