Skip to content

Code native workflows - #1832

Open
v1r3n wants to merge 54 commits into
mainfrom
design/native-workflows
Open

v1r3n wants to merge 54 commits into
mainfrom
design/native-workflows

Conversation

@v1r3n

@v1r3n v1r3n commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Native workflows let a developer write a Conductor workflow as Java code. This PR is the server side.

This PR had four subjects before: native workflows, fixes for standard workflows, a durable message queue and a formal specification. It is now one PR in a chain. Each PR in the chain has one subject. This makes the review easier, stops the scope from growing, and keeps unrelated changes apart.

SEE: conductor-oss/java-sdk#190

PR chain

  1. #1863, durable workflow message queue. Merged.
  2. #1832, native workflows and their design documents (this PR). Base: main.
  3. #1864, TLA+ specification of the native protocol. Base: #1832.

Merge order: #1832, then #1864.

  • #1832 needs #1863 because native workflows deliver signals, updates and queries through the workflow message queue.
  • #1864 is apart because no code, build file or document refers to the specification.
  • The fixes for standard workflows that were in this PR are not in the chain. They follow in #1846 and in other PRs.

What changed

  • Native workflows. Each call that the code makes becomes a real task. The task is in the UI graph with the usual operator actions. The server records a continuation marker on the task that the code paused on, and a worker replays the code against the recorded tasks.
  • Server.
    • NativeContinuationService.
    • The continuation marker (Task.continuation) and Workflow.nativeState, with their gRPC mappings.
    • The native-code SWITCH evaluator.
    • Native paths in the decider, the executor (complete, retry, rerun, restart), JOIN and the poll.
    • Task saves outside the workflow lock (a worker result, an async system task, a sub-workflow task) keep the stored continuation marker. For a task with a marker, the save takes the workflow lock, and a stale copy does not reopen a finished task.
    • The conductor.app.nativeWorkflow.* limits.
    • Pinned executions. A worker can keep the code of an execution in memory and continue it with no replay. The server offers the next continuation to that worker first. If the worker does not take it in conductor.app.nativeWorkflow.pinTimeout (5 s), any worker takes it and replays.
  • ui-next. Views for native workflows:
    • held steps, code loops drawn as loops, and native joins;
    • previews of what the code has yet to do, and "Waiting for a worker";
    • definitions generated from code shown read-only.
  • Documents. specs/native-workflows/ has the design, the protocol, the durability guarantees and the test plan.

How to test

  1. Start the server with --conductor.workflow-message-queue.enabled=true.
  2. Check out the branch design/native-workflows of conductor-oss/java-sdk.
  3. Run one of the examples in native-examples against the server.
  4. Open the execution in the UI. Each call of the code is a task in the graph.

Notes

  • Merge with a squash. The history of this branch has commits of the fixes that a later commit removed. A merge commit can bring those removals to main.
  • Enabled by default. conductor.app.nativeWorkflow.enabled is true by default. When the workflow message queue is disabled, Conductor accepts a native definition with handlers and logs a warning; the handlers do not run.
  • Handler lane. It claims messages under the lane name, with the run number as the ordinal. See the claim rules in #1863.
  • Standard workflows. They rerun as on main. A native rerun uses its own plan.
  • Review hotspots: NativeContinuationService, WorkflowExecutorOps (decide, rerunWF), Join, and ExecutionDAOFacade.updateTaskKeepingContinuation with its callers in AsyncSystemTaskExecutor.
  • The Java SDK changes are here: Native workflows: workflows as plain Java, with numbered examples java-sdk#190

🤖 Generated with Claude Code

…sage queue

Native workflows: Conductor workflows written as Java code. The code's
calls become real tasks; the server records continuation markers on the
tasks the code paused on and replays the code against them. A decide
offers each continuation under the lock it already takes; the poll hands
it out with no lock and no write, and a completion or a pushed message is
applied inside the decide it triggers.

Decider semantics: fixes for the 13 issues in
proposals/workflow-semantics/DECIDER_BUGS.md, found by a TLA+ model of the
decider and checked against the server: optional tasks failing last, JOIN
with a pending retry, fork/sub-workflow/loop reruns, rerun from a replaced
attempt, JOIN naming a SWITCH, terminate/retry of ended workflows, time
budget on rerun and retry, skipping forks, and a task stuck IN_PROGRESS.
Task updates no longer take the workflow lock: they are saved only if the
stored status is still the one read (ExecutionDAO.updateTaskIfStatus,
atomic on Postgres, MySQL, SQLite and Redis).

Workflow message queue: a durable SQL store (SQLite, Postgres, MySQL) with
claim-based pulls, so a re-run of a pull returns the same messages. A push
runs inside a decide.

Also: the skip-task endpoint reads its JSON body, a response timeout
follows the task's timeout policy, and ui-next hides actions the server
refuses. Docs updated throughout.
@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 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

👥 Review policy — satisfied. This PR changes 19,078 lines (≥ 2,000) and has the required 2 approvals. ✅

@v1r3n v1r3n changed the title feat: native workflows, decider semantics fixes, durable workflow message queue Native workflows Nov 11, 2026
@v1r3n v1r3n changed the title Native workflows Code native workflows Nov 11, 2026
@v1r3n
v1r3n marked this pull request as draft November 11, 2026 04:40
The Java SDK now passes a workflow a stub for each task class its
constructor takes, so tasks are called directly (tasks.task1(a, b)) as
well as by method reference. Both emit the same entries.
@github-actions github-actions Bot removed the needs: 2 approvals Applied by the review-policy workflow label Nov 11, 2026
v1r3n added 17 commits November 12, 2026 19:54
…s, loop iterations in the UI

- spec/check_drawing.py: the spec checker for how plain Java ifs, switches and
  loops are drawn. It generates random programs (nested loops, else-if chains,
  old and arrow switches, guards, helpers, return/throw), runs them on a
  server, and checks each execution against the same control-flow definitions
  the SDK implements: an arm is what runs only because its outcome was taken,
  within the method and the loop pass; a decision is drawn when an arm holds a
  call and no case falls into the next. Checks S/C/P/L/R and replay. Catalogue,
  seed 2 (240 executions) and seed 13 (400 executions): 0 failing.
- NativeContinuationService: a fragment is split at every entry with
  metadata.after, and each run is inserted after its own anchor (anchors were
  honoured only on the first entry).
- ui-next: Java loop steps are shown as iterations of one loop task
  (codeLoopsAsIterations); failed task and detached task fixes.
- TLA+ protocol spec: throw model (MC_NThrow), switch and hold configs, path
  and kitchensink checkers; protocol and execution-model docs updated.
…dings

Spec (Workflow.tla):
- a decision schedules what the server's getTasksToBeScheduled schedules in one
  step and in its order: a SWITCH with its chosen case, a fork with its branch
  heads and then its JOIN, a dynamic fork with its copies and then its JOIN;
  skipped nodes are passed over in the same decision (passOverSkipped)
- forks record their JOIN's place; the output comes from what was scheduled
  last, a task or a JOIN; a rerun that forgets a JOIN schedules it again
- a workflow reopened with a TERMINATE on record starts nothing new before it
  ends again (endsAgain, ReopenedEndsAgain)
- the operator's rerun target is a world choice tests can fix (RerunTargets)
- stronger properties: ScheduledTogether (replaces ForkStartsTogether),
  NewRunNewChild (an attached child is the one created for the run),
  FailureWorkflowSound (one failure workflow per failing end), OutputSound

Models MC_TermReady, MC_ForkLast, MC_DynLast, MC_SkipHead; check.py has 72
mutants and 34 witnesses, and accepts TLC's unnamed temporal violations.

Scripts: server_check.py accepts only 409 as a refusal, pins the rerun target,
and derives each test from --seed alone; verify.sh fails when server_check.py
fails; enumerate.py fails when nothing was checked.

Verified: check.py (17 models), enumerate.py (all 1,314 programs up to 3
nodes), verify.sh against a server (40/40 tests).
…ot pass on no evidence

NativeProtocol.tla:
- a switch inside a case belongs to that case (OwnerOf), so the code after it
  in the outer case is scheduled
- a lane that never paused (it only started other lanes) settles when its
  entries ended; joined lanes' previews are not required to run
- a retry removes the mark and the previews of what the throw skipped, not a
  switch's previews of cases not taken (as retryNative does)
- the main lane raising cancels tasks still running (as terminate does)
- stronger FailedNamesItsCause: exactly what the main lane's raise names
- new properties EndedIsQuiet and UntakenStayDrawn

Models MC_NNestedSwitch, MC_NSpawnOnly, MC_NLanePreview, MC_NThrowSwitch,
MC_NFailRunning; check.py has 31 mutants and 25 witnesses.

Checkers: kitchensink_mutants.py first checks the recording passes and never
counts a server error as a rejection; check_drawing.py fails when an execution
gets no replay verdict or nothing ran; check_runs.py and check_paths.py fail on
no input; check_runs.py no longer exempts unknown tasks ending in _<n>;
check_paths.py rejects a reference drawn twice (check_paths_mutants.py 21/21).

Verified: check.py (14 models), check_paths_mutants.py 21/21,
kitchensink_mutants.py 19/19, check_runs.py over 1,105 native executions.
…y step

Bug 14 (DECIDER_BUGS.md): a retry after a failure at a fork could fail the
workflow again at once. retry() reopened a cancelled JOIN and put it on the
system-task queue before saving the retry; the async executor ran the JOIN on
the stored workflow, where the failed attempt was not yet marked retried, and
ended the workflow again. resetUnsuccessfulJoinTasks and scheduleForgotten
queued reopened JOINs before saving in the same way. All three now save first.
TestWorkflowExecutor.testRetryQueuesAReopenedJoinOnlyAfterSavingTheRetry fails
without the fix.

Step-by-step checking of server runs against Workflow.tla:
- DecideTrace: with -Dconductor.trace.dir set, each decide appends the
  workflow's status and tasks to <dir>/<workflowId>.jsonl; off by default.
- Workflow.tla TraceView; server_check.py --trace-dir checks that the spec goes
  through every state a decide left, in order, then reaches the final state;
  failure workflows are counted.
- server_mutants.py breaks one server rule at a time and requires the traced
  tests to catch it: 5 of 5 caught.

Verified: 99 of 100 traced tests up to 4 nodes with retries, restarts and
reruns matched at every step (1 unchecked: TLC timeout); check.py passes.
…t needs

Production lines on the branch: +4937 -261 before, +4557 -259 after. Native
logic moves out of shared classes into NativeContinuationService;
WaitTaskMapper, WorkflowMonitor and WorkflowTask are back to main, and common's
WorkflowDef only relaxes the empty-task-list check.

Removed (nothing used them):
- the any-of JOIN (joinStrategy: ANY) and the dev WAIT time scale;
- 11 of 14 native metrics (kept: native_fragment_rejected,
  native_completion_deferred, native_stale_completion) and the code-type queue
  depth gauge;
- NativeState.protocol, metadata.native.protocol, the protocolVersions,
  handlerBatchSize, joinPollInterval and maxFragmentTasks properties (the
  definition limit, nested entries counted, and the byte limit bound a
  fragment);
- the bootstrap task's synthetic inputData.input, isNativeTask, isWorkerActive,
  onEvaluated (repairAndWake wakes the same markers in the same decide), the
  COMPLETED finish branch.

Merged: one native check, on the definition; insertAfter, previousTask and
removeAll as NativeContinuationService helpers (WorkflowDefInsertAfterTest
moves to core as NativeDefinitionEditsTest); retry's undo of a throw and
re-arm of the main lane (undoThrow, rearmLastMain); a lastMain record; one
continuation-marker parser shared with TaskMapperContext; changed variables
computed once; lease takes the task the poll read; continuation completions
routed once in updateTask, without mayDecide.

Fixed:
- gRPC mapping of a marker with no result or error (NPE): they default to
  empty maps;
- a rejected fragment no longer leaves half its entries or variables behind:
  every check runs before anything is written, a run may anchor on an entry an
  earlier run of the fragment drew;
- a native rerun queued reopened JOINs before saving them (bug 14's pattern);
- a stale continuation completion after a rerun overwrote the rerun task; it is
  now refused with 409;
- a restart onto a latest definition that is not native kept the old
  nativeState;
- a retry after the code threw left what that continuation drew (an if, a
  lane), so the run diverged; it is removed with the mark. NativeProtocol.tla's
  Retry does the same (MC_NThrowDrawn; SequenceOrder exempts marks);
- bug 15: a rerun task a worker finished at once ran again 30 s later, because
  finalizeRerun wrote its stale SCHEDULED copy after queueing it.

Workflow.tla now describes two things the server does on a rerun: forgotten
JOINs come back in the order of their forks, and a task retried after the
rerun's task goes back to its attempt before it. server_check.py gains --only.

Verified: core 1087, common 110, grpc 9, NativeWorkflowSpec 5, ui-next tsc and
vitest; conformance 153/153, RetryThrow, branches 126/126, operator checks,
the kitchen sink with kitchensink_spec (3 proved) and 19/19 mutants,
check_paths 341/341, check_runs, check_drawing catalogue and seed 2 (296/296);
traced server_check 100/100, server_mutants 5/5; both check.py, verify.sh with
the server, enumerate.py.
…the UI, read-only code definitions

Server:
- NativeCodeEvaluator (evaluatorType native-code): a native workflow's SWITCH
  reads the case its code took (switchCaseValue); nothing is evaluated against
  workflow data. Fragment validation rejects a native SWITCH with any other
  evaluator, so the server no longer trusts the SDK to send only fixed values.

UI (ui-next):
- The definition page draws a native definition's Java loops as loop nodes
  (metadata.loops, as the execution page does), and selecting a node resolves
  it in that drawn definition: before, a loop node or an operator inside a loop
  opened another task's form (often a SIMPLE one, with its schema section).
- A definition generated from code is read only: a banner names the code;
  the diagram has no edit handles; the JSON editor, task and workflow forms are
  disabled; Save, Save as new version, Reset and Delete and their shortcuts are
  gone. Download and Run stay.
- A native execution whose code has not run yet previews the registered
  definition, marked Preview; one whose continuation waits in a queue no worker
  polls (30 s) shows "Waiting for a worker of <code type>" in the header and
  the summary. The status stays RUNNING.
- native-code is a SWITCH evaluator type, shown read only; Java-loop nodes
  carry it.

Docs: native-code, the SWITCH rule, the registered definition's codeVersion
and schema references; the 02 example no longer shows metadata.native.protocol.

Verified: core tests; ui-next tsc, lint and 1129 tests; conformance 153/153,
RetryThrow, branches 126/126, operator checks, the kitchen sink with its spec
and 19/19 mutants, check_paths and check_runs 339/339, check_drawing catalogue
and seed 2 (296/296).
…nly the state the code needs

- Continuations always go to the shared queue of the code type: task domains,
  `*` included, route a run's tasks only. getActiveDomain is back to main's.
- nativeState keeps bootstrap, handlers and replies:
  - the slot is the one LEASED marker (activeContinuation and activeUntil go);
  - replay follows the markers' appliedAt, kept increasing within a run
    (step goes);
  - every handled message is in replies, a signal with only its time, which
    de-duplicates retried sends (seen goes);
  - the code type and continuation timeout are read from the definition's
    metadata.native.
- The continuation marker drops worker, queue, attempts (always the epoch) and
  error: the main lane's exception is the run's reasonForIncompletion, and the
  decider completes a native run only while it has none. The derived state
  flags are no longer serialized.
- NativeProtocol.tla derives the slot from the leased mark; an expired lease
  is only delivered again. OneContinuationAtATime: at most one leased mark.
- UI: the code type from the workflow's name and version, the number of
  applied continuations, no domain in "waiting for a worker".
- Docs follow the code.
…keep counting epochs

- The main lane's result goes to the run's output at apply; the marker no longer carries it.
- Markers are stored without their empty values: a waiting marker is {lane, n, state}.
- reset() keeps the epoch, and restart and rerun reuse the old markers, so an id never sees
  the same epoch twice and a completion of an earlier offer is refused.
- An entry's metadata.continuation is the lane's n; its lane is metadata.lane.
…t to do

- While a native run is in progress, the diagram shows the rest of the registered definition
  (drawn from the code) after the step the code is at, as previews: at the top level, in the
  arm of the switch it is in, and in the branches of the fork it waits for. A preview whose
  reference a step already used is renamed, so it is not taken for that step.
- 02-protocol: a throw's TERMINATE mark carries the Java loops around the line it threw from.
…es state, named as on tasks

- queuedAt -> scheduledTime, appliedAt -> endTime, deferred -> reasonForIncompletion.
- epoch -> retryCount, 0-based like a task's: raised when an attempt ends without applying
  (deferred, retried, rerun, restarted), kept by a redelivery; still the completion's fence.
- leasedAt removed: nothing decided on it.
- The bootstrap is stored without lane, n and endTime (always main #1, always applied first);
  the handler marker without its lane.
- The handler lane, when it has messages, is offered before any code continuation; "waiting
  for handlers" is only a reason shown, no longer state read from it.
- check_runs checks AppliedInOrder; docs and the spec README follow the code.
…; two comments fixed

- ignore-epoch is now no-retry-count-fence, named for the check it removes.
- A duplicated javadoc in NativeContinuationService and a garbled comment in
  PullWorkflowMessages are fixed.
- TaskContinuation keeps leased, retryCount, endTime, done, recorded and resumedWith, and n on
  the handler lane's marker only. lane, state, scheduledTime and the marker's
  reasonForIncompletion are gone.
- Which continuation a marker is comes from the task's entry (metadata.lane,
  metadata.continuation). The bootstrap's and the handler lane's synthetic tasks get an entry
  that names it the same way.
- State is derived: applied is endTime > 0, leased is leased, runnable is a terminal, evaluated
  task whose marker is neither. The WAITING to RUNNABLE repairs are removed.
- Offer order: the handler lane while messages are queued, then the bootstrap until it applied,
  then the continuation whose task ended first.
- A deferral or hold sets the workflow's reasonForIncompletion; the next applied continuation
  clears it. The UI finds the held step as the leased marker and reads the run's reason.
- The bootstrap records its endTime, so replay sorts every step by endTime.
- done stays: a JOIN reads the definition and the tasks in two reads without the lock.
- Tests: a completion must name the retryCount of the offer it answers; a deferred attempt
  cannot apply once its retry is offered.
- Docs follow the code; stale text about domain routing, Workers.buildId and the sweeper
  repairs is fixed, and redelivery times are stated for the SQL queues.
- The schedule table's columns, getDefaultShowColumns and their two helpers move unchanged
  from Schedules.tsx to scheduleColumns.tsx, which the page and its test import. This clears
  the two react-refresh/only-export-components lint errors; unused imports are removed.
…est plan names the primitives

kitchensink_spec.py interprets the kitchen sink's new section 5: switchOn, a switch expression,
the doWhile passes and their loop tag, the passes of the loops the server runs (forEach,
repeatUntil), a fan-out, and a workflow started by name with its child checked. The spec README
cites the latest run.
…ons, external waits

07's API table lists the changes: async/join/fanOut on java.util.concurrent.Future (fanOut
returns a List), agent(ref) as a conversation with pollInterval/pushNotifications,
external(ref).await(T.class, timeout), workflows(Type.class, factory), Workers as
AutoCloseable, typed statuses and WorkflowTimeoutException, and llm(..).as(Record.class).
01, 02 and 03 follow the renames.

Co-Authored-By: Claude <noreply@anthropic.com>
The durable workflow message queue (#1863) is now on main.

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

@kowser-orkes kowser-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.

I have reviewed the code for critical pieces of code

  • Also used LLM to review the code
  • And tested it

I have added my recommendation and question. Overall it looks good to me

The pop chose ids in the queue polled but marked and returned every row
with those ids, in any queue. A message id is unique within a queue, not
across queues: a native continuation offered on a worker's own queue and,
as a fallback, on the shared queue under the same id was popped from both
and run twice. The update now names the queue too.
… code in memory

A worker may keep an execution's code parked where it paused, so that its
next continuation wakes it instead of replaying the method. A completion
that does so carries pin: {domain, stamp}; the server records both on
nativeState and offers the next continuation to <domain>:<codeType> first,
while that domain polls, with the shared queue as a fallback after
conductor.app.nativeWorkflow.pinTimeout (5 s).

- lease hands out the stamp and the variables on a copy of the marker, so a
  worker continuing from memory fetches nothing; neither is stored
- a lease from the pinned queue makes the shared message visible again after
  the pin timeout, so a worker killed with its poll open delays the
  execution by that much at most
- the slot holder's repair push goes to the shared queue only
- a completion without pin, a rerun, a retry of the code, a rejected
  fragment and a restart clear the pin and the stamp; a handler run keeps them
- update-v2 polls the pinned domain after a completion that pinned

Correctness never depends on the pin: a worker whose copy is not current
finds another stamp and replays, and two workers running one offer is the
existing redelivery case.
v1r3n and others added 4 commits November 23, 2026 21:52
…nuation marker

A native workflow keeps the marker of the continuation that waits on a task in
that task's row, and changes it only under the workflow lock. A worker's
result, an async system task's run and a child finishing its parent's task save
that row without the lock. When two of them overlap (the SDK resends a result
whose response timed out; a JOIN's message is handed out again while a run
still holds it) the one that read first can save last, putting back a marker
its continuation had already applied. The server then offered the continuation
again and the execution was held as diverged: 4 of 200 executions of
fork { child | child | task } then join.

Those paths now save through ExecutionDAOFacade.updateTaskKeepingContinuation:
for a task with a marker, under the workflow lock (waiting up to the lock's
lease), with the marker as stored. Tasks without a marker save as before.

The same 200 executions after the fix: 200 correct; 7 stale JOIN saves landed
after their continuation applied, none reverted a marker.
NativeStaleTaskWriteTest reproduces both interleavings and fails without the fix.
cf90ecc kept the marker when an unlocked path saved a stale copy of a native
task, but the rest of the copy still landed. A JOIN run that loaded the
execution before its last lane settled (the run started when a child finishes
is one) finds the JOIN not done and saved it IN_PROGRESS over the COMPLETED a
later run saved, after the code had gone on past the join; the JOIN then ran
and completed again, with its end time moved after the tasks that follow it.

updateTaskKeepingContinuation now drops the save, under the lock, once the
stored task is finished: the path that finished it saved it, and the decide
that followed acted on that.

The same 200 executions: 200 correct, 49 stale saves dropped (11 JOINs that
would have gone back to IN_PROGRESS, 38 SUB_WORKFLOW copies), no JOIN ending
after the next task was scheduled (7 of 600 before). NativeStaleTaskWriteTest
reproduces the reopened JOIN and fails without this change.
v1r3n and others added 7 commits November 24, 2026 19:00
… row

A marker sat on the row of the task the code paused on, which a worker's
result, an async system task's run and a child finishing its parent's task save
whole and without the workflow lock. The facade fix of cf90ecc and 3249fca
guarded those saves; this removes the reason for it instead, and reverts it.

Markers are now in nativeState.markers, by task id, on the workflow row, which
only code under the lock saves. TaskModel has no continuation: a stale task save
lands as for any workflow (a JOIN evaluated out of order is evaluated again) and
cannot touch a marker. The decide that schedules a task gives it its marker (a
retried attempt, the one before's, reset); the API shows each marker on its task
and nativeState without them, so the SDK and the UI read what they did. Poll and
task update tell a continuation by the task's entry metadata. A completion saves
the fragment and its marker in one write of the workflow row.

Also removed as redundant: the variable conflict check (one continuation runs
at a time, and a second run of an offer is refused by the lease check; none
fired in 1,000 executions), the re-read of the workflow after a completion
(decided in memory, under the same lock), and task saves that only carried a
marker. A completion for a task a rerun removed is refused (409) instead of
being applied to the removed task.

200 executions of fork { child | child | task } then join, with code kept in
memory and with every continuation replayed: 200 correct each, none diverged,
no stale-lease refusals. Conformance 160/160. NativeStaleTaskWriteTest lets the
stale saves land and checks the markers are untouched.
…p item is the failed task

A rerun from a task inside a forEach or repeatUntil loop dropped the rest of
that iteration and the later ones (planRerun), expecting the loop to schedule
them again, but nothing reopened a loop that had finished: it stayed COMPLETED,
the continuation after it ran, and the code found the rerun task still
SCHEDULED and failed the run ("task items_task SCHEDULED"). adjustRerun now
reopens every loop holding the rerun task at that task's iteration, without the
outputs of the iterations that run again.

The code names a failed task in a loop without its iteration (items_task, not
items_task__2), so causeTask found no task and the failed run named none. It
now takes the latest failed iteration of that name.

Operator checks: the five loop-rerun checks pass (they failed before this, also
on f7d11ec). Both new tests fail without the change.
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.
… wake a JOIN when a lane ends (#1882)

- Split NativeContinuationService (1,716 lines) by job into NativeWorkflows, NativeDefinitionEdits, NativeFragmentValidator and NativeRerunPlanner. WorkflowExecutorOps gets the service in its constructor.
- Replace the isNative branches in the decider, the executor and the sweeper with WorkflowDriver (StandardDriver, NativeDriver). No behavior change.
- Put a native JOIN on its queue with no delay when its lanes end, and remove the check each second.
finalizeRerun, the last step of a rerun, saved every task the rerun held in
memory, after rerunWF had already saved and queued the rerun task (and the
JOINs it reopened). A worker that took the task at once and finished it had
its COMPLETED overwritten with SCHEDULED, while its update had already removed
the queue message: the task waited for the sweeper. A native retry reruns the
failed task in place, so it hit this: the retry stalled for 30 s, and the
code's next continuation, offered while the task looked done, found it
scheduled again and diverged ("lane main resumed before task ... finished").

finalizeRerun now saves only the tasks it resets itself. What it resets and
queues is unchanged.

Traced live with a build that logged each removal from the task's queue: the
worker's COMPLETED update removed the message, then the rerun's bulk save put
SCHEDULED back. 40 immediate retries of a failing run: all done within 1.8 s,
the task run exactly twice, no sweeper repairs (2 of 20 and 1 of 25 stalled
before). aRetryDoesNotSaveTheTaskItRunsAgainAfterQueueingIt fails without the
change.
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.
@github-actions github-actions Bot removed the needs: 2 approvals Applied by the review-policy workflow label Nov 25, 2026
…review what is ahead

- Definition page: "Native Workflow Preview. Editing is disabled", with the
  code it is defined in. The form looks disabled (add / remove buttons
  hidden), as well as being disabled.
- Definitions list: no Clone for a native workflow; a copy would not run.
- Execution summary: "Defined in code".
- The code is named by metadata.native.source, which every SDK sets in its
  language's notation (Java com.acme.Orders#ship, Python orders.flows:ship);
  class.method for older Java SDKs. Documented in 02-protocol.md.
- Preview of what is ahead in a running execution: a fan-out matches whether
  drawn as FORK_JOIN_DYNAMIC (from the code) or FORK_JOIN (as it ran), and an
  execution whose last step the code drew differently (lanes started inside an
  if's arms) is placed from the latest step that matches, previewing only
  what is written below it. Kitchensink, replayed at each of its 55 points,
  now shows what is ahead at every point but the last.
@mp-orkes

Copy link
Copy Markdown
Contributor

Approved. Items to monitor or do after the merge:


Size explanation
Standard workflow row

{
  "workflowId": "…",
  "status": "COMPLETED",
  "input": { "days": 3 },
  "workflowDefinition": {
    "name": "simple_loop",
    "tasks": [
      {
        "type": "DO_WHILE",
        "taskReferenceName": "loop",
        "loopCondition": "$.loop.iteration < $.days",
        "loopOver": [
          { "type": "SIMPLE", "name": "send_reminder", "taskReferenceName": "send_reminder" }
        ]
      }
    ]
  }
}

Native workflow: The definition has one entry for each call.

{
  "workflowId": "a13cadb8-…",
  "status": "COMPLETED",
  "input": { "days": 3 },
  "workflowDefinition": {
    "name": "simple_loop",
    "tasks": [
      { "type": "SIMPLE", "name": "send_reminder", "taskReferenceName": "send_reminder",
        "inputParameters": { "day": 1 },
        "metadata": { "lane": "main", "site": "SimpleLoop.run:47", "continuation": 2, "appendedBy": "main#1" },
        "taskDefinition": { "name": "send_reminder", "retryCount": 3, "…": "about 40 more fields" } },
      { "type": "SIMPLE", "name": "send_reminder", "taskReferenceName": "send_reminder_2",
        "inputParameters": { "day": 2 },
        "metadata": { "lane": "main", "site": "SimpleLoop.run:47", "continuation": 3, "appendedBy": "main#2" },
        "taskDefinition": { "…": "the same copy again" } },
      { "type": "SIMPLE", "name": "send_reminder", "taskReferenceName": "send_reminder_3",
        "inputParameters": { "day": 3 },
        "metadata": { "lane": "main", "site": "SimpleLoop.run:47", "continuation": 4, "appendedBy": "main#3" },
        "taskDefinition": { "…": "the same copy again" } }
    ]
  },
  "nativeState": {
    "bootstrap": { "endTime": 1795576451193 },
    "markers": {
      "4c6db3d0-…": { "endTime": 1795576451302 },
      "9d09c469-…": { "endTime": 1795576451407 },
      "04164b6a-…": { "endTime": 1795576451516, "done": true }
    }
  }
}

@mp-orkes

Copy link
Copy Markdown
Contributor

@ajlai-orkes can we get your review on the UI changes?

@Sudakatux Sudakatux 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.

Ive tested this locally with the examples

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

size: XL Applied by the review-policy workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants