fix: retry branch reconciliation without re-executing effects - #534
Merged
Conversation
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.
Summary
Closes #533.
Root cause
reconcile_branch_result()retriedagents_reconcile_lock_unavailableby enqueueing the original branch hook and payload. The new action enteredrun_branch_action(), rehydrated the descriptor, and executed completed branch steps again before making another reconciliation attempt.Behavior change
A completed branch now stores a read-after-write-verified reconcile receipt before the first reconciliation attempt. The receipt normally lives inside the branch's already-indexed descriptor row, avoiding concurrent appends to the shared run index. A failed write stops the original action before reconciliation rather than enqueueing an unreadable retry.
When a built-in descriptor is missing or expired, its deterministic
store_refreceives a verified receipt-only row instead. No shared-index write occurs. The reconcile-only retry records the terminalworkflow_branch_descriptor_missingresult, then deletes that exact row after successful reconciliation. Expired local rows also delete themselves when read.Lock contention enqueues
RECONCILE_HOOKwith a small durable receipt reference. Its callback reloads that receipt and calls only the idempotent reconciliation path; it cannot re-enterexecute_branch(). Late duplicate retries whose receipts were already cleaned up verify the authoritative completed state and no-op.Consumer-owned refs continue through the existing
wp_agent_workflow_branch_store_put,wp_agent_workflow_branch_store_get, andwp_agent_workflow_branch_store_forgetcontract. Missing custom descriptors create receipt-only records only through those owner filters, and exact receipt cleanup also stays in that store. No local option fallback occurs.Receipts persist opaque
reconcile_continuationerror data and exposewp_agent_workflow_reconcile_retry, allowing PR #536's authoritative multi-phase continuation to advance after rebase instead of relying only on completed-handle redelivery.Regression coverage
Tests
php tests/workflow-as-branch-smoke.phpphp tests/workflow-async-branch-payload-smoke.phpphp tests/workflow-request-controller-smoke.phpphp tests/workflow-scoped-drain-smoke.phpcomposer testcomposer phpstangit diff --checkAI assistance
Implemented with OpenCode AI assistance. The implementation, review remediation, diff, and test results were reviewed during development.