refactor(#257): extract shared workflow-polling utility#272
refactor(#257): extract shared workflow-polling utility#272fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
Extract duplicated workflow-polling loops from admin.go and enrollment.go into a shared AwaitWorkflowCompletion function in internal/layers/workflowpoll.go. The new utility uses exponential backoff (doubling from InitialInterval up to MaxInterval) with a configurable timeout, replacing the fixed-interval polling that both callers previously implemented inline. admin.go: awaitRepoMaintenance now delegates through awaitRepoMaintenanceWithConfig using DefaultPollConfig. awaitRepoMaintenanceWithInterval is kept as a compatibility shim for existing tests. enrollment.go: awaitWorkflowRun now delegates to the shared AwaitWorkflowCompletion with DefaultPollConfig. Note: pre-commit could not run in sandbox (shellcheck-py network restriction). Post-script runs authoritative pre-commit on the runner. Closes #257
E2E tests did not runE2E tests run automatically for org/repo members and collaborators on pull requests. For other contributors, a maintainer must add the See E2E testing guide for details. |
|
🤖 Finished Review · ❌ Failure · Started 12:59 PM UTC · Completed 12:59 PM UTC |
|
/fs-review |
|
🤖 Finished Review · ✅ Success · Started 3:57 PM UTC · Completed 4:10 PM UTC |
ReviewVerdict: comment — medium-severity findings worth discussing, none blocking. Clean refactoring that correctly consolidates the duplicated workflow-polling loops from Findings1. Shim timeout math triples the effective timeoutSeverity: medium · File: The compatibility shim computes For the production path this doesn't matter — Suggestion: Use 2. Timer/select race can overshoot the deadlineSeverity: medium · File: The Suggestion: Replace the manual 3. Test gaps for key behavioral branchesSeverity: medium · File: The new test file covers success, timeout, cancellation, progress callback, and the
4.
|
| Severity | Count |
|---|---|
| Critical | 0 |
| High | 0 |
| Medium | 3 |
| Low | 2 |
All findings are non-blocking. The refactoring achieves its goal, the production path is correct, and the medium findings are edge cases in the compatibility shim and test infrastructure. Nice deduplication work.
| } | ||
|
|
||
| // nextInterval doubles the current interval, capping at max. | ||
| func nextInterval(current, max time.Duration) time.Duration { |
There was a problem hiding this comment.
[low] style
Parameter name 'max' in nextInterval(current, max time.Duration) shadows the builtin max function introduced in Go 1.21 (this repo uses Go 1.26).
Suggested fix: Rename to maxInterval to match the PollConfig.MaxInterval field name.
|
/fs-fix |
|
🤖 Finished Fix · ❌ Failure · Started 5:38 PM UTC · Completed 5:51 PM UTC |
Extract duplicated workflow-polling loops from admin.go and enrollment.go into a shared AwaitWorkflowCompletion function in internal/layers/workflowpoll.go. The new utility uses exponential backoff (doubling from InitialInterval up to MaxInterval) with a configurable timeout, replacing the fixed-interval polling that both callers previously implemented inline.
admin.go: awaitRepoMaintenance now delegates through awaitRepoMaintenanceWithConfig using DefaultPollConfig. awaitRepoMaintenanceWithInterval is kept as a compatibility shim for existing tests.
enrollment.go: awaitWorkflowRun now delegates to the shared AwaitWorkflowCompletion with DefaultPollConfig.
Note: pre-commit could not run in sandbox (shellcheck-py network restriction). Post-script runs authoritative pre-commit on the runner.
Closes #257
Post-script verification
agent/257-extract-workflow-poll)c776c248ac9a91f10998ca7107e974a6c9d76514..HEAD)