Repository navigation
fix(server): preserve workflow handoff replay and deferred stages (CHE-11245) [squash] - #2331
Merged
Merged
Conversation
Author
|
Merge-Eligibility: REFUSED
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Status
Draft PR for cross-lab review (
agent_review). Round 1 fix commit20eeeae8f2afbe60bef596481eb81eee9ba4e48bfollows initial commit22e3d586c6ee611891e4eedeed6e62549c60d468on basea91aa3dce4e6418196b22d3df16cb8615e4b7fd6(main). Keep this PR in draft while CI runs and cross-lab review is pending.Conditions
main, CHE-11169 integrates both repairs into PR fix(ci): shorten backend critical path (CHE-11169) [squash] #2315. CHE-11169 then reruns full CI.Changelog
Changelog(fix): Workflow squad stage handoffs now preserve deferred stages, coalesce replays, and allow step watchdog redispatch.
Agent-facing
Agent-facing: no
Change
TaskService.EnqueueWorkflowSquadLeaderRunInTx(server/internal/service/task_handoff_tx.go) and handler helpers (server/internal/handler/issue_workflow_edge_tx.go,server/internal/handler/issue_handoff_dispatch.go,server/internal/handler/system1_route_endpoint.go).issue_handoff_dispatch, workflow edges,RouteIssue) stampworkflow_handoff_revisionandfire_atunderLockIssueRunBudgetthenLockWorkflowSquadHandoff. Each call promotes due deferred rows after commit.watchdog:squad intents (server/internal/handler/issue_handoff_dispatch.go) keep pending-run deduplication (enqueueSquadLeaderRunWithOverlayInTx). A stalled squad step whose prior leader run ended at the sameissue.Revisionnow starts a new leader run.CancelStaleStepRunsandCancelStaleStepRunsInTxwhentrigger.WorkflowHandoffis true (server/internal/handler/issue.go,server/internal/handler/issue_workflow_edge_tx.go,server/internal/handler/system1_route_endpoint.go). Entering a subsequent squad workflow stage preserves pending and deferred prior squad stages.createWorkflowSquadHandoffTask(server/internal/service/workflow_squad_handoff.go) to acquireLockIssueRunBudgetbeforeLockWorkflowSquadHandoffand execute insideTxScoped(q).ErrDuplicatePendingTaskas coalesced debug output inserver/internal/service/task.go.TestWorkflowSquadHandoffConcurrentIntentAndServiceReplay,TestWorkflowSquadHandoffBatchStageOrderingAndStopChoices, andTestWorkflowSquadHandoffWatchdogRedispatchesAfterFailedLeaderRuninserver/internal/handler/issue_workflow_squad_test.go.issue_handoff_dispatchandagent_task_queuestates without adding columns or transitions.Blast Radius
server/internal/handlerandserver/internal/service.UpdateIssue,BatchUpdateIssues,dispatchHandoffIntent,moveIssueOnEdgeTx,RouteIssue, andEnqueueTaskForWorkflowSquadLeader.server/internal/handlerandserver/internal/servicebackend CI shards, duplicateagent_task_queueleader rows on replay, dropped deferred squad stages, or stalled squad steps failing watchdog redispatch.pgvector/pgvector:pg17PostgreSQL database).Cost delta
LockIssueRunBudget+GetWorkflowSquadHandoffTasklookup per workflow squad handoff transaction.PendingTaskForIssueAndAgentfor status handoffs is cheaper by one advisory lock call. That alternative fails because it coalesces distinct squad stages and ignoresworkflow_handoff_revisionafter task completion. Keying status handoffs on(issue_id, agent_id, squad_id, workflow_handoff_revision)while keepingwatchdog:intents on pending-run deduplication is the minimal exact mechanism.agent_task_queueduplicate leader runs per(issue_id, workflow_handoff_revision)and Postgres lock-wait errors in backend logs. Revert commits22e3d586c6ee611891e4eedeed6e62549c60d468and20eeeae8f2afbe60bef596481eb81eee9ba4e48bif lock contention or missing squad dispatch occurs.Evidence
5f736b3b-2efe-4427-af0f-a464254bccdf(bounded Go compile parallelism-p=2). No diff violation.pgvector/pgvector:pg17, fresh./cmd/migrate up) repro before fix confirmedTestWorkflowHandoffCancelsDeferredSquadStagesfailed (fixture did not retain a deferred stage handoff). It also confirmedTestWorkflowSquadHandoffReplayDoesNotDuplicatefailed (same handoff replay = <nil>, want coalesced), matching CHE-11169 comment 01a24640-e41f-743d-b4a6-de257e50fdf0.20eeeae8f2afbe60bef596481eb81eee9ba4e48b:Closes CHE-11245