Repository navigation
Conversation
…ol-flow definitions
CodeReader's branch, arm and loop reading is rebuilt on definitions written once
in design/native-workflows/README.md ("Plain ifs and switches"), replacing the
layout heuristics:
- loops are natural loops; a loop's follow is where every way out that can go
on leads, its extent what runs from its head before the follow; only its
condition (at the head, or the jump back of a do-while) is the loop's own
- a decision is a switch with what it comes round to without a step (a failed
`when` guard), or the jumps of one && / || condition
- an arm is what runs only because its outcome was taken (dominance of the
outcome's edge), within the method and the loop's extent: the code after a
guard clause is the guard's false arm; arms are instruction sets, not ranges
- a decision is drawn when an arm holds a step, each step line is in one place,
and no arm runs into a written case with a step before the arms meet
- labels as written: chars as chars, `Integer when` for guarded patterns,
javac's MatchException default as the default arm
- branches nest by their arms' instructions, not by line spans; finally copies
and recursive calls count as steps
Replayer: explicit refs numbered by occurrence; throw marks go in the arm they
were thrown in. New native-examples: branches (126 executions of every way to
write an if or switch, and nested mixes), operator fleet workflow, drawing host
for the spec checker; shipment example rewritten natively.
Verified: SDK native-workflow tests, branches.Check 126/126, conformance
153/153, operator checks, spec checker catalogue and seeds 2 and 13 (0 failing).
…rded switches without a loop - The dev time scale is gone: no __timeScale variable, Workers.timeScale is deprecated and does nothing, Replayer.process takes no extra variables. - Completions no longer carry fields the server never reads: metadata.native.protocol, error.type, metadata.thrown, the duplicate protocol/n writes, the handler lane's empty fragment and done flag, and a non-main lane's result or error (logged to the task first, as before). NativeState drops protocol. - CodeLoops no longer takes the jump back that restarts a guarded pattern switch (case ... when) for a Java loop: the SWITCH was tagged as in a loop its cases were not (check_paths P6). CodeLoopsTest covers it. - retrythrow.RetryThrow: a retry after the code threw, past an if and after starting a lane, fails again where it threw. - operator.OperatorChecks waits for the failure workflow's id, which the server records just after saving the execution FAILED.
…ion, native-code switches - Schemas: registration reads by reflection the JSON Schema of each @WorkerTask's input (one property per parameter, named as calls name it) and output (an object's properties, any other value as result), and of the @workflow method's input and output (JsonSchemas). They are registered by name (<task>_input/_output, <workflow>_input/_output) and versioned by content: an identical registered version is reused, anything else is the next version. Task definitions, the inline ones in the registered graph and the workflow definition reference them with enforceSchema false: the code decides what it accepts. A server without a schema registry is skipped. - The registered definition tags entries inside plain Java loops with metadata.loops (<Class>_loop_<first line>, as executions do; a helper or lambda called in a loop is in it), and carries metadata.native.codeVersion, a short hash of the discovered graph. - Every SWITCH the SDK draws uses evaluatorType native-code. - loops.LoopShapes: while, do-while (a task as its condition) and for (;;); with the argument worker it only hosts the code, for runs started on the server. Verified: conductor-client 179 and native-examples 30 tests; the native end to end suite (see the conductor commit).
…he state the code needs - Each hosted workflow is a TaskRunner worker of its code type: virtual threads, update-v2, no domains. Settings per workflow from conductor.workflow.<name>.* or conductor.workflow.all.* (threadCount, pollingInterval, pollTimeout, paused, continuationTimeout), else @workflow (20 threads, 100 ms, 500 ms). The hand-written poll loop, buildId and threads() go. - TaskRunner: - withTaskUpdateV2 turns update-v2 on for one configurer; - withDomains(false) polls only shared queues; - the task update-v2 hands back runs at once on the finished task's permit, instead of waiting for the poll loop; - a 4xx other than 408 and 429 is not retried; - a worker that throws is reported FAILED once, not twice. - Hosted @WorkerTask methods are configured as AnnotatedWorkerExecutor does, from conductor.worker.* or the annotation. threadCount defaults to 0 (unset): 1 for AnnotatedWorkerExecutor and Spring, 8 for the native host. - metadata.native keeps class, method, continuationTimeoutSeconds and handlers; the code type is <name>.v<version>.code. - Replay orders applied continuations by appliedAt. Every handled message is recorded in replies, which de-duplicates retried sends (seen goes). - The model copies drop the fields the server no longer keeps.
…continuation is its n - The model copy of TaskContinuation matches the server: no empty values stored, reset() keeps the epoch. - Entries write metadata.continuation as the lane's n, with the lane in metadata.lane.
…hat loop The TERMINATE mark is emitted after the exception has left the loop, so the loops around the emitting code were empty. It now takes the loops around the lines the exception was thrown from, as the switch or fork it lands in does.
- The model copies of TaskContinuation and NativeState match the server: retryCount, scheduledTime, endTime, reasonForIncompletion; no leasedAt; the bootstrap without lane, n and endTime, the handler marker without its lane. - A completion echoes retryCount; replay puts the first continuation first and orders the rest by endTime. - The durability checker, the held example and the recorded kitchen sink execution follow; the ignore-epoch bench mutant is regenerated against the new fence.
- destructive-pull, no-variable-fencing, no-message-dedupe and drop-some-signals are regenerated against the current server and SDK; each applies and compiles. - ignore-epoch is renamed no-retry-count-fence.
…th identity from the entry - The model copies of TaskContinuation and NativeState match the server: leased, retryCount, endTime, done, recorded, resumedWith, and n on the handler marker only. - WorkflowTask gains metadata (written only when non-empty), so a polled task keeps its lane and continuation number; the worker reads both from the entry for every continuation, and echoes n and retryCount. - Replay sorts every applied step by endTime, the bootstrap included. - The durability checker, the bench summary, the held example and the recorded kitchen sink execution follow; the checker reads why a completion was deferred from the run's reason. - The no-retry-count-fence server mutant is regenerated against the new fence. - Docs follow the code.
…tubs or by name
doWhile(name, body, condition) runs the body at least once and tags every step in it
with the named loop, so the console draws a do-while without reading bytecode. The
method-reference task(Tasks::m, ...) and forEach(Tasks::m) forms are removed: a stub
call schedules the same task. task("name") stays for tasks with no Java method.
…nk uses them all The primitives package has one file per construct, each showing its alternatives side by side: TaskCalls (stub, by name), SwitchCase (if, switch over strings and enums, switch expressions, switchOn), Loops (Java loops, doWhile, forEach, repeatUntil), Parallel (async, join, fanOut), SubWorkflows (child, startWorkflow), Timers (sleep, sleepUntil, awaitCondition, @schedule), Messages (@variable, @signal, @update, @query), Errors (retries, TaskFailure, compensation, failing the run), SideEffects (once, now, random, workflowId) and SystemTasks (HTTP, event, human, external wait, LLM, MCP, agent). primitives.Main runs them all against a server, checks each result and the execution, and replays each execution against its code. The kitchen sink gains a section 5 with Conductor's own constructs: switchOn, a switch expression, doWhile, forEach, repeatUntil, fanOut named after its call site, a workflow started by name, random() and workflowId(). Its recorded execution is re-recorded for the replay test.
…r.tasks(...) Conductor.host() read like the server's host and returned a Workers builder that nothing used until start(). The entry points are now what a process runs: conductor.workflows(...), conductor.tasks(...) and conductor.workflow(Type.class, factory), each returning the Workers builder for options and start(). Workers.registered() is isRegistered(); the no-op Workers.timeScale is removed. Co-Authored-By: Claude <noreply@anthropic.com>
…with its construct do-while and for(;;)-with-break next to doWhile, for-each next to forEach, a polling while next to repeatUntil; main checks the result against a server. Co-Authored-By: Claude <noreply@anthropic.com>
…uture of the result It completes with the workflow's return value, or exceptionally with WorkflowFailedException. One daemon thread per Conductor checks every pending future; completions run on the common pool; a restarting server is waited out and a refusal fails the future. Cancelling a future only stops waiting; closing the Conductor cancels the futures still waiting. result(Duration) stays as the blocking form. primitives.Main waits on two runs with allOf and checks a failed run's future. Co-Authored-By: Claude <noreply@anthropic.com>
…entic support desk Concurrency and agents: - async returns java.util.concurrent.Future (Promise is removed); join(..) then resultNow() reads results, get() waits too and wraps a failure in ExecutionException. fanOut, which waits for every item, returns the List of results, as forEach does. - agent(ref) is a conversation: each ask continues it, and answers the agent's question when the last reply needsInput(). AgentResult carries the agent's artifacts. pollInterval and pushNotifications say how the server waits for a long-running agent. API review (one mental model, idiomatic Java): - every builder sends a fresh command per call, so one kept in a variable can be reused - external(ref).await(Type.class, timeout) replaces awaitExternal(ref, Type).await(timeout) - hosting with a factory is workflows(Type.class, factory); workflow(X::run) is start options - Workers is AutoCloseable (close() replaces shutdown()); a second start() throws - typed statuses: WorkflowHandle.status() is WorkflowStatus, TaskFailure.getStatus() is Task.Status with getReason(); WorkflowFailedException carries the workflow id and status; result(timeout) throws WorkflowTimeoutException - query uses the factory a class is hosted with - llm(..).as(Record.class) reads the model's answer as JSON - taskCommand and spec leave the public API Examples: agents.Agents (long-running agents in async lanes, polled and pushed, a conversation, an agent asking for input), agents.SupportTicket (a model routes a ticket, a switchOn hands it to that team's agent or to a person, a model drafts the reply) and agents.SupportDesk (the same for an inbox, with fanOut). The stub agent gains slow, ask, fail, data and push behaviours, a chat-completions model, and one agent per team. LoopShapes' poll task is renamed shape_poll: it collided with the operator's loop_poll. Found, not fixed (server, from main): AIModelTaskMapper turns an AI task's retry count below 1 into 3; A2ACallbackResource does not resolve an agent-card URL, so a push for an agent given by card URL waits for the backstop poll. Co-Authored-By: Claude <noreply@anthropic.com>
- url() is removed: it guessed the UI's address from the API's, which is wrong whenever the UI is served elsewhere. Examples print the workflow id. - variables() is removed: query() reads a workflow's state; the raw variables are on WorkflowClient.getWorkflow. - result(timeout) waits on resultAsync(): one way of waiting for an execution. - reads use WorkflowClient.getWorkflow and the typed Workflow model (WorkflowStatus.isTerminal, nativeState replies), so an externally stored output is downloaded too; completeTask uses TaskClient.updateTask. - Http.retrying rides out a restarting server for every repeatable call (reads, messages, completing a task, a start with an idempotency key); a refusal (4xx) is thrown at once. - imports instead of fully qualified names in Conductor, WorkflowHandle and Http. The handle keeps its Conductor: the client, the factories of hosted workflow classes (for query) and the one thread that waits for results, which close() stops.
…ered as it runs - if (!approved) was drawn as if_approved with its body under "true", so an approved run showed if_approved taking its default arm. An if of one jump on a boolean that falls into its body when the boolean is false now keys that body "false": the key is the value of what the if is named after. The branches check's negated scenarios follow. - repeatUntil was registered as a DO_WHILE around the call alone, under the call's name, while the server runs <loop>_backoff, <loop>_wait and <loop>_check. The registered definition now has those three steps. - the kitchen sink recording is re-exported by the end-to-end run.
…t harness native-examples/src/main/java/examples, one file each, read in order (native-examples/README.md): 01 hello world (with a sleep that holds no thread), 02 conditionals (plain if/switch and switchOn), 03 loops (each loop in plain Java and with forEach, repeatUntil, doWhile), 04 parallel (async/join, fanOut), 05 sub workflows (child, startWorkflow), 06 signals (@signal, @update, @query, @variable, awaitCondition), 07 timers (sleep, now, @schedule), 08 error handling (retries, NonRetryableException, TaskFailure, a saga, WorkflowFailedException), 09 HTTP, 10 human in the loop (human, external), 11 LLM (text and a record), 12 MCP, 13 an agent (a conversation, a long-running agent in async) and 14 an agent harness (a model plans each step; the workflow calls MCP tools, delegates to helper agents in branches and asks a person). Each has a Gradle task (./gradlew :native-examples:ex01_hello_world) and an in-memory test under src/test/java/examples. The kitchen sink and the other packages stay as the SDK's own checks. The stub gains an orders API (09) and a scripted planner model (14). The design README documents the examples and how a negated if is keyed.
mp-orkes
requested review from
bradyyie,
kowser-orkes,
manan164 and
mp-orkes
November 19, 2026 23:53
…ameters bind the whole input TaskRunner sends a result with update-v2, which hands back the next task, only when it would poll for one now: it is running, its worker is not paused and no poll filter holds it back. A task handed to a paused worker ran despite the pause, and one handed over during shutdown was refused by the executor and waited out its response timeout. AnnotatedWorker binds an un-annotated parameter by its name only for a call from a native workflow, or when the parameter could not hold the whole input (a string, a number, a list). An object parameter keeps binding the whole input, also when one of the object's fields has the parameter's name.
…e results, reply order - an async or fanOut lane that paused on a task and returns null completes - once records the element types of a list, set or map, and returns the value read back from its JSON on the first run too, against a server and in memory: the code gets the same value the first time as on every re-run - a UUID, Duration or Date is one value under "result", as a workflow's or task's result and as a single workflow parameter - an update whose handler returns null returns null to its caller - the reply cap drops the oldest replies by when they were handled, not by the order of the server's map - in memory, a repeatUntil whose last check failed throws its TaskFailure, as against a server - a start no longer fails when another thread adds workers to the same Conductor
…t in memory Determinism - switchOn takes the case the execution recorded, whatever the code now computes; only a recorded case the code no longer has is a divergence - doWhile records each pass and replays the recorded number of passes; the condition is still evaluated, so tasks it calls are reached - conductor.workflow.<name>.strictDeterminism (off by default): workers refuse to start a workflow whose code reads Math.random, UUID.randomUUID, the clock and the like, naming each place and its replacement; otherwise a warning per place - design/native-workflows/determinism.md, and example 15 Code kept in memory between continuations - after a continuation the lanes stay parked on their virtual threads (ParkedExecutions; Replayer.begin, proceed, close); the next continuation wakes its lane with the awaited task and the variables from the poll, with no replay and no fetch - the workers poll a task domain of their own, pin-<workerId>-<random>, while they hold executions, and each completion names it with a stamp; the server offers the execution's next continuation there first - a continuation whose stamp is not the one this process sent last replays, so a retry, a rerun, a restart or another host's completion always replays - parkTimeout (1 h, 0 to turn off) and maxParked (1000) per workflow; dev mode keeps nothing - TaskRunnerConfigurer.withFixedDomain Also: no next task for a paused or stopping worker (TaskRunner).
…ment The server no longer fences a completion's variables on resumedWith (one continuation runs at a time; the variables are applied as sent), so the no-variable-fencing mutant has nothing to disable. The comment on the handler completion's resumedWith said the server applies only what changed and reruns on a conflict; it now says what resumedWith is for.
…de, fix lint - Replace 298 fully qualified class names written inline (java.time.Duration, org.objectweb.asm nodes, org.conductoross.conductor.sdk.internal.*, Mockito, CountDownLatch, ...) with imports, in the code this branch added; none clashed with another name in its file. - Remove CodeReader.Branch.onlyArmWithoutCalls, which nothing calls. - Registration: one class LOGGER instead of three inline getLogger calls. - Lint: scope the casts the code needs (Jackson's raw Collection class in Json, the skeleton's task list in Registration, generic test data in three tests) and the intended fall-through of the br_switch_fallthrough example; no lint warnings remain in files this branch added. Spotless clean; conductor-client 1157 tests and native-examples 57 pass.
The pre-native getting-started examples are superseded by native-examples. The module was not in settings.gradle, and the CI guard that docs do not mention examples/old still holds.
Removed: - the middle TaskRunner constructor: one constructor takes updateV2, useDomains and fixedDomain; - stopPolling() and its call in TaskRunnerConfigurer.shutdown; - the poll-filter check before update-v2: native workers use no filters; - markFailed: executeTask returns handleException, which sends the failure once; - the reworked domain lookup: main's lookup stays, with one override after it. Kept, each shown needed by a host handoff check (close a host mid-run, start another; 50 executions, kept in memory and replayed): - the shutdown wait for a poll in flight; - running a task update-v2 hands back during shutdown on its own thread. Without them, 1-2 continuations per handoff were dropped and their executions stalled about 115 s; with them none, takeover 7-13 s.
This branch has not been deployed
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.
Why
Native workflows let you write a Conductor workflow as a plain Java method, and Conductor runs it durably on the server:
@WorkerTaskmethods;ifandswitchand loops withforandwhile;sleep, signals and human tasks, and calls HTTP, LLMs, MCP tools and agents.This PR is the Java SDK side. The server side is conductor-oss/conductor#1832, which is stacked on conductor-oss/conductor#1857.
What changed
SDK API (
org.conductoross.conductor.sdk)Conductor:conductor.workflows(...).tasks(...).start();start,execute,attach, andworkflow(X::run)for start options.WorkflowHandle:result/resultAsync,status,signal,update,query,completeTask.task(name);async/join/fanOut,switchOn,doWhile,forEach,repeatUntil;child/startWorkflow;sleep/sleepUntil/awaitCondition;once/now/random/workflowId;http,event,human,external,llm,mcp,agent.@Workflow,@Signal,@Update,@Query,@Variable,@Schedule.TaskFailure,WorkflowFailedException,WorkflowTimeoutException.Drawing
internal/CodeReaderreads plainif,switchand loops from the compiled code, so an execution is drawn with:internal/Replayerruns the code again against the recorded execution, as a worker does.Testing support
DurableTestEnvironmentruns a workflow in memory, with stubbed tasks, HTTP calls, models, tools, agents and people.DurableReplay.assertCompatiblechecks a code change against a recorded execution.Spring:
ConductorWorkflowHostinconductor-client-springandconductor-client-spring-boot4, plus thenative-examples-springapp.Examples:
native-examples/src/main/java/examples, numbered in reading order (seenative-examples/README.md):./gradlew :native-examples:ex01_hello_world) and an in-memory test.native-examplesare the SDK's own checks:primitives;stubs/ai_stub.pystands in for a web API, a chat model, an MCP server and A2A agents.Design doc:
design/native-workflows/README.md.Known limits
iforswitchafter the last call, whose arm calls nothing and returns, is not drawn when more than one such return is possible.joinof branches started in another arm or another loop pass is missing from the registered definition. Executions draw it.Testing
Unit tests:
:conductor-client:test --tests 'org.conductoross.*'(160),:native-examples:test(54),:conductor-client-spring:test(10) and:conductor-client-spring-boot4:test(37) pass. Spotless is clean.Against a server built from conductor-oss/conductor#1832, configured with:
conductor.workflow-message-queue.enabled=trueconductor.ai.litellm.baseURLpointing at the stubconductor.a2a.callback.urlEnd-to-end, all passing:
check_drawing: the catalogue plus one random seed, 88 generated programs and 380 executions;check_pathsandcheck_runson 750 executions;Examples:
check_pathsand render in the UI.