-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
Description
Objective
Convert the three simplest safe output handlers to use the factory pattern, eliminating direct environment variable access.
Context
This is Phase 1 of the safe output manager refactoring (#8098). These handlers are the simplest and will establish the pattern for other handlers.
Target Branch
sot (safe output transition)
Handlers to Refactor
actions/setup/js/add_labels.cjs(~50 lines)actions/setup/js/close_issue.cjsactions/setup/js/close_discussion.cjs
Implementation Pattern
Each handler must be converted from:
// OLD: Direct env var access
const output = loadAgentOutput();
const maxIssues = parseInt(process.env.GH_AW_ISSUE_MAX || '5');To:
// NEW: Factory pattern
async function main(config = {}) {
const maxIssues = config.max || 5;
return async function(outputItem, resolvedTemporaryIds) {
// Process single message
// Return { temporaryId?, repo, number }
};
}
module.exports = { main };Changes Required
For each handler:
- Remove
loadAgentOutput()call - Accept message as function parameter
- Accept config in
main()instead of reading env vars - Return result object with temp ID if applicable
- Export factory function via
module.exports = { main }
Testing
After refactoring:
# Run handler tests
npm test -- add_labels.test.cjs
npm test -- close_issue.test.cjs
npm test -- close_discussion.test.cjs
# Integration test
npm test -- safe_output_handler_manager.test.cjsAcceptance Criteria
- All three handlers use factory pattern
- No direct
process.envaccess in handlers - All existing tests pass
- Factory returns correct function signature
- Handlers process individual messages correctly
Related to Safe output manager #8098
AI generated by Plan Command for #8098
Copilot