Skip to content

fix: standard-workflow fixes split out of the native workflows PR - #1857

Open
v1r3n wants to merge 3 commits into
mainfrom
fix/non-native-fixes
Open

v1r3n wants to merge 3 commits into
mainfrom
fix/non-native-fixes

Conversation

@v1r3n

@v1r3n v1r3n commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Split out of #1832. That PR now holds only native workflows and is stacked on this one.

Why

#1832 mixed native workflows with fixes for standard workflows: decider bugs found with a TLA+ model of the decider, and bugs found by the durability bench (server, database and worker kills and pauses). These fixes don't depend on native workflows. This PR moves all of them out so they can be reviewed and merged on their own.

Some of this change is also in #1846 (decider), #1847 (durability), #1854 (timeout policy) and #1855 (idempotency key), split out earlier. Those four PRs conflict with each other in TestWorkflowExecutor, so #1832 can't be stacked on them. This PR is the complete set #1832 builds on. Reviewers can use those four PRs to look at one area at a time. Whichever PRs merge, #1832 is then rebased on what landed.

What changed

Decider fixes for standard workflows. These are bugs 1 to 15 in proposals/workflow-semantics/DECIDER_BUGS.md.

  • An optional task that fails last is saved COMPLETED_WITH_ERRORS.
  • A JOIN waits for a failed attempt that can still be retried.
  • A JOIN that names a SWITCH waits for the case the SWITCH took.
  • Reruns now complete when started from a task in a fork, a task in a loop, a SUB_WORKFLOW task, or an older attempt.
  • A rerun task that a worker finished at once does not run again.
  • A retry after a failing TERMINATE ends the workflow FAILED.
  • Retry and rerun give the task a new total time budget.
  • A skipped first task of a branch or a case no longer stops the flow. Skipping a fork also skips its JOIN.
  • A poll or a task update no longer overwrites a cancellation. A task is saved only if its stored status is still the one the server read (ExecutionDAO.updateTaskIfStatus). The check and the write are atomic on Postgres, MySQL, SQLite and Redis.
  • A reopened JOIN is queued only after it is saved.
  • The spec and its checkers are in proposals/workflow-semantics/ (Workflow.tla, server_check.py). DecideTrace (-Dconductor.trace.dir) records each decide, so server_check.py can compare a server run with the spec step by step. It is off by default.

Durability bench fixes

  • Start:
    • createWorkflow writes the decider queue entry before the workflow row.
    • A failed start no longer deletes the workflow.
    • If the first evaluation fails, the start still succeeds and the sweeper evaluates the workflow later.
  • A transient storage failure in scheduleTask or in a DO_WHILE retries the decide instead of failing the workflow.
  • The decide loop saves the workflow if an earlier iteration changed it.
  • The sweeper reads a task again before it puts the task back in the queue.
  • A system task that another run completed is not overwritten. JOIN and PULL_WORKFLOW_MESSAGES hold their queue message only briefly (isExecuteIdempotent).
  • SQLite pop is scoped to its queue. Postgres task and workflow definition writes are single upserts.

Workflow message queue

  • A durable SQL store for SQLite, Postgres and MySQL.
  • Pulls claim messages, so a pull that runs again returns the same messages.
  • A push is applied inside a decide (WorkflowExecutor.decide(workflowId, change)).
  • When a workflow ends with undelivered messages, they are logged and counted (workflow_messages_discarded).

Also

  • The response timeout and the total timeout follow the task's timeoutPolicy.
  • A start with an idempotency key returns the existing workflow.
  • The skip-task endpoint (PUT /api/workflow/{id}/skiptask/{ref}) now reads its JSON body.
  • The workflow returned by the API names the task it failed at (failedTaskId).
  • ui-next:
    • The execution menu no longer offers actions the server refuses: Terminate on FAILED or TIMED_OUT, and Retry on COMPLETED.
    • "Jump to task" uses failedTaskId.
    • In a run, an agent task with no card snapshot is not labelled UNRESOLVED.
    • The scheduler page exports only its component.
  • Docs are updated for the above, and docs/llms-full.txt is regenerated.

Behaviour changes (release notes)

  • The response timeout follows timeoutPolicy. Before, it always retried the task.
    • RETRY retries the task.
    • TIME_OUT_WF, the default, times the workflow out.
    • ALERT_ONLY only logs.
    • This is the biggest upgrade risk. A task whose worker goes silent, with no policy set, now times its workflow out instead of being retried. That includes SIMPLE tasks with no registered definition.
  • Retrying a COMPLETED workflow returns 409. Use rerun or restart instead.
  • Terminating a FAILED or TIMED_OUT workflow returns 409, and bulk terminate lists those ids as failed. Terminate-and-remove still removes workflows that already ended. A sub-workflow child that already ended is left as it is.
  • A rerun from a task inside a fork also redoes what the other branches scheduled after it. A rerun from inside a DO_WHILE reopens the loop at that iteration.
  • Skipping a FORK_JOIN or FORK_JOIN_DYNAMIC also skips its JOIN.
  • An operator retry or rerun gives the task a new totalTimeoutSeconds budget. Automatic retries keep the old budget.
  • A message push returns 503 when the workflow is busy. The client should retry.

How it was split

This branch is #1832's tree with the native-workflow code removed. That covers NativeContinuationService, the continuation markers and NativeState, the native-code evaluator, the native paths in the decider, the executor, JOIN and poll, the gRPC mappings, the native UI views and proposals/native-workflows/. The branch is then rebased on main. Nothing outside native workflows was changed. The only exception is wording: comments, DECIDER_BUGS.md and the spec README that referred to native workflows.

Testing

All runs are on this branch, rebased on main:

  • Unit tests:
    • core: 1024
    • common: 107
    • rest: 135
    • sqlite-persistence: 122
    • redis-persistence: 81
    • http-task: 26
    • mysql-persistence: 54
    • postgres-persistence: 158
    • grpc: 4
    • All pass. spotlessCheck is clean.
    • PostgresLockDAOTest.testLockAcquisitionAndRelease failed once on its lease-timing check and passed on a rerun. It is flaky on main too.
  • test-harness: SimpleWorkflowSpec passes 14/14.
  • ui-next:
    • tsc is clean.
    • vitest: 1171 of 1172 tests pass. persistCopyInLocalStorage > rejects and drops the stale draft when the quota is exceeded fails, and it fails the same way on main.
    • Lint has no errors.
  • Against a live server (SQLite, traced): server_check.py --tests 100 --size 4 --seed 2026 matches the spec step by step for 96 of 100 runs. The same 4 runs fail on Code native workflows #1832's previous tip, so they predate the split. All 4 are operator reruns:
    • s2026x6, s2026x49, s2026x97: a rerun from a copy inside a dynamic fork of sub-workflows ends FAILED.
    • s2026x59: a rerun from a task ends COMPLETED with that task CANCELED.
    • These are open, and not in this PR.

🤖 Generated with Claude Code

Everything in #1832 that is not native workflows: decider fixes for standard
workflows, the fixes the durability bench found, the durable workflow message
queue, timeout policy and idempotent starts, and small API and UI fixes. #1832
is stacked on this change and now holds only native workflows.

Decider (proposals/workflow-semantics/DECIDER_BUGS.md, bugs 1 to 15, found by a
TLA+ model of the decider and checked against the server):
- an optional task that fails last is saved COMPLETED_WITH_ERRORS
- a JOIN waits for a failed attempt that can still be retried, and a JOIN that
  names a SWITCH waits for the case it took
- reruns from a task in a fork, in a loop, from a SUB_WORKFLOW task, or from an
  older attempt complete; a rerun task a worker finished at once does not run
  again
- a COMPLETED workflow cannot be retried and an ended one cannot be terminated
  (409); a retry after a failing TERMINATE ends FAILED; retry and rerun give a
  task a fresh total time budget
- a skipped first task of a branch or case does not stop the flow; a skipped
  fork skips its JOIN
- a poll or a task update does not overwrite a cancellation: tasks are saved
  only if their stored status is still the one read
  (ExecutionDAO.updateTaskIfStatus, atomic on Postgres, MySQL, SQLite, Redis)
- reopened JOINs are queued only after they are saved
- DecideTrace (-Dconductor.trace.dir) and the spec's server_check.py compare
  server runs with Workflow.tla step by step

Durability bench (server, database and worker kills and pauses):
- createWorkflow writes the decider queue entry before the row; a failed start
  does not delete the workflow; a failed first evaluation is left to the sweeper
- a transient storage failure in scheduleTask or DO_WHILE retries the decide
  instead of failing the workflow; the decide loop saves a workflow an earlier
  iteration changed
- the sweeper re-reads a task before re-queueing it
- a system task another run completed is not overwritten; JOIN and
  PULL_WORKFLOW_MESSAGES reserve their message briefly (isExecuteIdempotent)
- SQLite pop is scoped to its queue; Postgres definition writes are single
  upserts

Workflow message queue: a durable SQL store (SQLite, Postgres, MySQL), claims
so a re-run pull returns the same messages, a push applied inside a decide
(WorkflowExecutor.decide(workflowId, change)), and undelivered messages of an
ended workflow logged and counted.

Also:
- response and total timeouts follow the task's timeout policy
- a start with an idempotency key returns the existing workflow
- the skip-task endpoint reads its JSON body
- the API workflow names the task it failed at (failedTaskId)
- ui-next: hides Terminate and Retry where the server refuses them, "Jump to
  task" uses failedTaskId, an agent with no card snapshot is not UNRESOLVED in a
  run, and the scheduler page exports only its component
- docs updated for the above

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size: XL Applied by the review-policy workflow needs: 2 approvals Applied by the review-policy workflow labels Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

👥 Review policy — action needed. This PR changes 8,803 lines, which crosses the large-PR threshold (2,000). Large PRs require 2 approvals; it currently has 0. 2 more to go.

This is a review-policy gate, not a CI/test failure — see the review-policy / approvals check.

@v1r3n v1r3n mentioned this pull request Nov 18, 2026
…ording

- Classes this change uses are imported, not written out in full (main and test code,
  Java and Groovy); calls already covered by a static import use it.
- DECIDER_BUGS.md, the spec README, a SQLite test and a TaskCard comment no longer refer to
  native workflows, which are not part of this change.

spotlessApply run; core 1024, common 107, rest 135, sqlite 122, redis 81, mysql 54,
postgres 158 (PostgresLockDAOTest's lease-timing check is flaky, on main too), grpc 4,
http-task 26.

Co-Authored-By: Claude <noreply@anthropic.com>
The e2e tests are passing in CI because they are cached. E.g.:

https://github.com/conductor-oss/conductor/actions/runs/44349914306/job/134962466309

    Starting a Gradle Daemon (subsequent builds will be faster)
    > Task :conductor-e2e:processResources NO-SOURCE
    > Task :conductor-e2e:compileJava NO-SOURCE
    > Task :conductor-e2e:classes UP-TO-DATE
    > Task :conductor-e2e:compileTestJava FROM-CACHE
    > Task :conductor-e2e:processTestResources
    > Task :conductor-e2e:testClasses
    > Task :conductor-e2e:test FROM-CACHE
    > Task :conductor-e2e:jacocoTestReport FROM-CACHE

This is wrong.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mp-orkes

Copy link
Copy Markdown
Contributor

BLOCKING

With the cache fix (cd8cc5c) e2e tests fail: https://github.com/conductor-oss/conductor/actions/runs/44560086396/job/135686714387

  1. "Rerun CANCELLED sibling SUB_WORKFLOW task in parent reschedules FAILED sibling, leaves COMPLETED sibling alone". A rerun from one fork branch starts a completed sibling sub-workflow again.
  2. "ALERT_ONLY policy + totalTimeout exceeded: workflow terminates when task explicitly fails". With ALERT_ONLY, the workflow now keeps retrying after the total timeout.

Both pass on main with the same cache fix (#1861: 227 run, 0 failed). Both failures come from changes in this PR. They were hidden because the e2e test results came from cache.

finalizeRerun(workflow, rerunFromTask);
return true;
}
// Remove all tasks after the "rerunFromTask"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause of the WorkflowRerunTests failure. This PR removes the path that main has for a rerun from a SUB_WORKFLOW task in a fork. The removal by seq now deletes the completed sibling branch, and scheduleForgotten starts it again with a new child workflow.

// like one with no retries left. Under TIME_OUT_WF the workflow times out.
if (taskDefinition.getTotalTimeoutSeconds() > 0
&& task.getFirstScheduledTime() > 0
&& taskDefinition.getTimeoutPolicy() != TaskDef.TimeoutPolicy.ALERT_ONLY) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause of the RetryPolicyTests failure. With ALERT_ONLY the total timeout guard is skipped, so the task is retried after totalTimeoutSeconds is spent. Before, the workflow ended.

LOGGER.debug(reason);
task.setStatus(TIMED_OUT);
task.setReasonForIncompletion(reason);
timeoutTaskWithTimeoutPolicy(reason, taskDef, task);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default timeoutPolicy is TIME_OUT_WF. A response timeout now ends the workflow with no retry for every task definition that keeps the defaults. Reproduced: retryCount 1, responseTimeoutSeconds 2, no policy set, one attempt and the workflow is TIMED_OUT. Can this go behind a property that is off by default?

return Optional.empty();
}
if (timeOutWorkflow) {
task.setStatus(TIMED_OUT);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With TIME_OUT_WF, a task that the worker failed and that is over totalTimeoutSeconds is rewritten to TIMED_OUT, and the workflow ends TIMED_OUT. Before, both were FAILED. Failure workflows, listeners and searches that use FAILED see a different status.

LOGGER.debug(reason);
task.setStatus(TIMED_OUT);
task.setReasonForIncompletion(reason);
timeoutTaskWithTimeoutPolicy(reason, taskDef, task);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With ALERT_ONLY the task stays IN_PROGRESS and updateTime does not change, so the response timeout fires again on every decide pass. ExecutorUtils.computePostpone returns 0 for this task, so the sweeper evaluates the workflow again immediately while the worker is dead.

@Override
public String startWorkflow(StartWorkflowInput input) {
if (StringUtils.isNotBlank(input.getIdempotencyKey())) {
return startWorkflowWithIdempotencyKey(input);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SchedulerService copies the idempotency key of the schedule to every trigger. The server ignored the key until now. Now every trigger after the first returns the first workflow. Reproduced with a 5 second cron for 27 seconds: 6 executions without a key, 1 with a key.

.getBytes(StandardCharsets.UTF_8))
.toString());
}
if (input.getIdempotencyStrategy() == IdempotencyStrategy.FAIL) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only FAIL has a branch. FAIL_ON_RUNNING returns the existing workflow, also while it runs. Reproduced: the second start returns 200 with the same id.

executionDAOFacade.removeWorkflow(workflowId, false);
} catch (Exception rwe) {
LOGGER.error("Could not remove the workflowId: " + workflowId, rwe);
executionDAOFacade.getWorkflowModelFromExecutionDAO(input.getWorkflowId(), false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This read runs before the lock that startWorkflowIdempotent takes. Two concurrent FAIL starts can both get "not found", and the second then returns the existing workflow. No caller gets the 409.

}
throw e;
}
return startWorkflowIdempotent(input).getWorkflowId();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A start with no key runs decide in the request. This path only pushes to the decider queue, so the start returns before any task is scheduled. A2AWorkflowAgent.sendMessage reads the workflow immediately after the start and gets no tasks.

// a crash leaves a queue entry for a workflow that does not exist, which the sweeper
// removes. The entry is delayed by the offset timeout, so the sweeper does not see it
// before the row is written.
queueDAO.push(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This holds only if the row write takes less than workflowOffsetTimeout (30 s). After a longer pause between the two writes, the sweeper removes the queue entry as "not found" and the workflow is abandoned again. A transactional start outbox does not depend on timing.

LOGGER.debug(reason);
task.setStatus(TIMED_OUT);
task.setReasonForIncompletion(reason);
timeoutTaskWithTimeoutPolicy(reason, taskDef, task);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaskDef.timeoutPolicy has no @NotNull, so "timeoutPolicy": null is accepted and the switch in timeoutTaskWithTimeoutPolicy throws an NPE. The response timeout path now reaches it by default. Also, a response timeout now counts in task_timeout as well as in task_response_timeout.

: input.getName();
input.setWorkflowId(
UUID.nameUUIDFromBytes(
(name + ":" + input.getIdempotencyKey())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"a:b" + "c" gives the same id as "a" + "b:c". The version and the input are not part of the id. WorkflowModel has no key field, so Workflow.idempotencyKey stays null.

@mp-orkes mp-orkes left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • CI is Red
  • There are a lot of potential breaking changes. Haven't validated all of them all but Claude's review makes sense. 2 of them are why CI is red. Take a look at my comments for a tl;dr on each.

mp-orkes added a commit that referenced this pull request Nov 19, 2026
This branch had the native workflow changes and all the changes of #1857. With `main` as the base, the PR showed both. This commit removes what belongs to #1857, so the diff against `main` is native workflows only.

Where the native code used a part of #1857:

- `WorkflowMessageQueueDAO`: the `claim` default methods stay. The handler lane calls `claim`; without a durable queue it pops.
- `WorkflowExecutorOps.decide`: a native wake-up saves the workflow at once. It used the `workflowDirty` flag of #1857.
- `WorkflowExecutorOps.rerunWF`: standard workflows rerun as on `main`. A native rerun keeps its plan, starts a new child for a `SUB_WORKFLOW` task, and saves and queues its reopened JOINs.
- `Join`: `isExecuteIdempotent` goes with #1857; the live join targets stay.
- Tests: `TestDeciderOutcomes` keeps the failure matrix helper for the native matrix. A native test in `TestWorkflowExecutor` verifies `updateTask` in place of `updateTaskIfStatus`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
v1r3n added a commit that referenced this pull request Nov 25, 2026
WorkflowModel kept failedTaskId but the API's Workflow had no such field, so a
failed run never said which task ended it. Taken from #1857 (95d2c72),
which carries it with its UI use ("Jump to task").

A native run failing at a patch in a nested loop now returns that task's id;
the operator checks pass 66/66.
v1r3n added a commit that referenced this pull request Nov 25, 2026
Each claim in 01, 02, 03, 04, 06, 07 and the README checked against the server
and the SDK, and corrected where they differ:
- markers are kept in nativeState.markers on the workflow row (the API shows
  each on its task), so the stored row grows by one marker per pause;
- a completion's variables are applied as sent: no fence on resumedWith;
- pinning: a worker that keeps an execution's code in memory, pin {domain,
  stamp}, the pinned queue first with a shared fallback after pinTimeout;
- features of the standard-workflow PR #1857 (idempotent starts, the push
  inside a decide, the conditional task save, the discarded-message count) are
  marked as not on this branch;
- a diverged attempt is held and retried, not failed; one TERMINATE entry
  marks where the code threw; a switch on replay takes its recorded case;
  native JOINs are woken with no delay (#1882); lock and decide ordering;
- the SDK's completion retries (3 attempts, 2 s apart), the handler claimant
  ("handlers"), proto fields, metric and test names, counts, the README path;
- names moved by the split of NativeContinuationService (#1882).

07 stays the plan: its state model, SDK section and drift table now match the
code, with a drift row for pinning, and its opening note lists the later
changes the plan sections do not reflect. 06 keeps its history of bugs found,
with "(since changed: ...)" notes where behavior moved on.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: 2 approvals Applied by the review-policy workflow size: XL Applied by the review-policy workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants