Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9738afb
native workflows in code
v1r3n Nov 12, 2026
48a1d18
feat(native-workflows): read plain ifs, switches and loops from contr…
v1r3n Nov 13, 2026
8bb689a
revert(native-examples): restore the hello example (the llm loop was …
v1r3n Nov 13, 2026
248cec2
refactor(native-workflows): send only what the server reads; draw gua…
v1r3n Nov 13, 2026
9f1da4e
feat(native-workflows): schemas from signatures, loops in the definit…
v1r3n Nov 14, 2026
83974bc
feat(native-workflows): host workflow code on TaskRunner; keep only t…
v1r3n Nov 15, 2026
ff6bf0c
refactor(native-workflows): markers keep counting epochs; an entry's …
v1r3n Nov 15, 2026
97f3b59
fix(native-workflows): the mark of a throw inside a Java loop is in t…
v1r3n Nov 15, 2026
847cabf
refactor(native-workflows): markers as the server now stores them
v1r3n Nov 15, 2026
b750a35
chore(native-workflows): bench mutants apply to the current code
v1r3n Nov 15, 2026
2496300
refactor(native-workflows): markers as the server now stores them, wi…
v1r3n Nov 16, 2026
6c9a389
feat(native-workflows): Conductor.doWhile; tasks are called through s…
v1r3n Nov 17, 2026
1f8298f
feat(native-examples): one workflow per construct, and the kitchen si…
v1r3n Nov 17, 2026
a4ce19b
refactor(native-sdk): start from conductor.workflows(...) or conducto…
v1r3n Nov 17, 2026
8c5ad7c
docs(native-examples): LoopShapes writes each loop in plain Java and …
v1r3n Nov 17, 2026
8052142
feat(native-sdk): WorkflowHandle.resultAsync() returns a CompletableF…
v1r3n Nov 17, 2026
0925e2a
feat(native-sdk): Future for branches, agent conversations, and an ag…
v1r3n Nov 18, 2026
aa4dbea
refactor(native-sdk): a smaller WorkflowHandle on the typed clients
v1r3n Nov 19, 2026
700a23a
fix(native-sdk): negated ifs keyed by their value; repeatUntil regist…
v1r3n Nov 19, 2026
2e87913
feat(native-examples): numbered examples, from hello world to an agen…
v1r3n Nov 19, 2026
72a4096
fix(client): no next task for a paused or stopping worker; object par…
v1r3n Nov 20, 2026
a3e4946
fix(native-sdk): null results, values recorded with once, single-valu…
v1r3n Nov 20, 2026
1abb1c1
fix(client): a single Map parameter binds the whole task input
v1r3n Nov 23, 2026
89b757f
feat(native-sdk): deterministic retries, strict determinism, code kep…
v1r3n Nov 23, 2026
14c25df
chore(native-sdk): drop the variable-fencing mutant and its stale com…
v1r3n Nov 25, 2026
57c5a97
chore(native-sdk): imports instead of qualified names, remove dead co…
v1r3n Nov 25, 2026
50d7b73
chore(examples): remove examples/old
v1r3n Nov 25, 2026
a5d72e5
refactor(client): keep only the TaskRunner changes native workflows need
v1r3n Nov 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
import org.conductoross.conductor.sdk.Conductor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
Expand Down Expand Up @@ -61,6 +62,17 @@ public ConductorClient conductorClient(ClientProperties properties) {
return builder.build();
}

/**
* Native workflows over the configured client (an Orkes {@code ApiClient} with keys when one is
* configured). Closing it stops the workers it started; the client bean is left to Spring.
*/
@Bean(destroyMethod = "close")
@ConditionalOnBean(ConductorClient.class)
@ConditionalOnMissingBean
public Conductor conductor(ConductorClient client) {
return Conductor.of(client);
}

@Bean
@ConditionalOnBean(ConductorClient.class)
@ConditionalOnMissingBean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2020 Conductor Authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.netflix.conductor.client.spring;

import org.conductoross.conductor.sdk.Conductor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.env.Environment;

/**
* Hosts the application's native workflows: every class under the application's packages with a
* {@code @Workflow} method. Set {@code conductor.workflows.enabled=false} in a service that only
* starts workflows.
*/
// Last, like the other Conductor auto-configurations: an earlier position would also move the
// client auto-configuration ahead of the Orkes one, and both would then define a TaskClient.
@AutoConfiguration(after = ConductorClientAutoConfiguration.class)
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
@ConditionalOnBean(Conductor.class)
@ConditionalOnProperty(prefix = "conductor.workflows", name = "enabled", matchIfMissing = true)
public class ConductorWorkflowAutoConfiguration {

@Bean
@ConditionalOnMissingBean
public ConductorWorkflowHost conductorWorkflowHost(Conductor conductor,
ConfigurableListableBeanFactory beanFactory,
Environment environment) {
return new ConductorWorkflowHost(conductor, beanFactory, environment);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright 2020 Conductor Authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.netflix.conductor.client.spring;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.conductoross.conductor.sdk.Conductor;
import org.conductoross.conductor.sdk.Workers;
import org.conductoross.conductor.sdk.Workflow;
import org.conductoross.conductor.sdk.internal.TaskStubs;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.context.SmartLifecycle;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.MethodParameter;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;

import com.netflix.conductor.sdk.workflow.task.WorkerTask;

import lombok.extern.slf4j.Slf4j;

/**
* Finds the classes with {@code @Workflow} methods under the application's packages and hosts
* them once the application has started, stopping before the context closes.
*
* <p>A workflow class need not be a bean. Each replay gets a new instance: a constructor parameter
* of a class with {@code @WorkerTask} methods gets a stub whose calls schedule those tasks, and
* any other parameter or {@code @Autowired} field is injected from the context. A field holding a
* real task object is rejected, since its calls would run in the workflow on every replay. Task beans keep running on the worker auto-configuration's executor; this only
* registers their task definitions, from the {@code @WorkerTask} attributes.
*
* <p>Properties under {@code conductor.workflows}: {@code worker-id} and {@code dev-mode}. Per
* workflow, read from the environment: {@code conductor.workflow.<name>.threadCount}, {@code
* pollingInterval}, {@code pollTimeout}, {@code paused} and {@code continuationTimeout}, or {@code
* conductor.workflow.all.*} (see {@link Workers}).
*/
@Slf4j
public class ConductorWorkflowHost implements SmartLifecycle {

private final Conductor conductor;
private final ConfigurableListableBeanFactory beanFactory;
private final Environment environment;
private volatile Workers workers;

public ConductorWorkflowHost(Conductor conductor, ConfigurableListableBeanFactory beanFactory,
Environment environment) {
this.conductor = conductor;
this.beanFactory = beanFactory;
this.environment = environment;
}

@Override
public void start() {
Set<Class<?>> types = workflowTypes();
if (types.isEmpty()) {
log.info("No @Workflow classes under {}", packages());
return;
}
Workers w = conductor.workflows();
String workerId = environment.getProperty("conductor.workflows.worker-id");
if (workerId != null) {
w.workerId(workerId);
}
w.settings(environment::getProperty);
w.devMode(environment.getProperty("conductor.workflows.dev-mode", Boolean.class, false));
types.forEach(type -> host(w, type));
w.taskDefinitions(taskBeans().toArray());
workers = w.start();
}

@Override
public void stop() {
Workers w = workers;
workers = null;
if (w != null) {
w.close();
}
}

@Override
public boolean isRunning() {
return workers != null;
}

private <T> void host(Workers w, Class<T> type) {
w.workflows(type, () -> {
// task classes come as stubs, so their calls schedule tasks; anything else from the context
T workflow = TaskStubs.newWorkflow(type,
p -> beanFactory.resolveDependency(new DependencyDescriptor(MethodParameter.forParameter(p), true), null));
beanFactory.autowireBean(workflow);
return workflow;
});
}

private List<String> packages() {
return AutoConfigurationPackages.has(beanFactory) ? AutoConfigurationPackages.get(beanFactory) : List.of();
}

Set<Class<?>> workflowTypes() {
ClassPathScanningCandidateComponentProvider scanner =
new ClassPathScanningCandidateComponentProvider(false, environment);
scanner.addIncludeFilter((reader, factory) ->
reader.getAnnotationMetadata().hasAnnotatedMethods(Workflow.class.getName()));
Set<Class<?>> types = new LinkedHashSet<>();
for (String pkg : packages()) {
for (BeanDefinition candidate : scanner.findCandidateComponents(pkg)) {
types.add(ClassUtils.resolveClassName(candidate.getBeanClassName(), beanFactory.getBeanClassLoader()));
}
}
return types;
}

/** The same beans the worker auto-configuration polls: components with {@code @WorkerTask} methods. */
private List<Object> taskBeans() {
List<Object> beans = new ArrayList<>();
for (Object bean : beanFactory.getBeansWithAnnotation(Component.class).values()) {
boolean[] found = {false};
ReflectionUtils.doWithMethods(AopUtils.getTargetClass(bean),
m -> found[0] = true, m -> m.isAnnotationPresent(WorkerTask.class));
if (found[0]) {
beans.add(bean);
}
}
return beans;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
com.netflix.conductor.client.spring.ConductorClientAutoConfiguration
com.netflix.conductor.client.spring.ConductorWorkerAutoConfiguration
io.orkes.conductor.client.spring.OrkesConductorClientAutoConfiguration
io.orkes.conductor.client.spring.OrkesConductorClientAutoConfiguration
com.netflix.conductor.client.spring.ConductorWorkflowAutoConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.lang.reflect.Method;
import java.time.Duration;

import org.conductoross.conductor.sdk.Conductor;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
Expand All @@ -32,6 +33,9 @@
import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor;
import com.netflix.conductor.sdk.workflow.executor.task.AnnotatedWorkerExecutor;

import io.orkes.conductor.client.ApiClient;
import io.orkes.conductor.client.spring.OrkesConductorClientAutoConfiguration;

import static org.assertj.core.api.Assertions.assertThat;

class ConductorClientAutoConfigurationTest {
Expand Down Expand Up @@ -162,4 +166,24 @@ ConductorClient conductorClient() {
return USER_CLIENT;
}
}

@Test
void conductorBeanWrapsTheClientBean() {
contextRunner
.withPropertyValues("conductor.client.base-path=http://localhost:8080/api")
.run(context -> {
assertThat(context).hasSingleBean(Conductor.class);
assertThat(context.getBean(Conductor.class).client())
.isSameAs(context.getBean(ConductorClient.class));
});
}

@Test
void conductorBeanUsesTheOrkesClientWhenOneIsConfigured() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(
OrkesConductorClientAutoConfiguration.class, ConductorClientAutoConfiguration.class))
.withPropertyValues("conductor.client.root-uri=http://localhost:8080/api")
.run(context -> assertThat(context.getBean(Conductor.class).client()).isInstanceOf(ApiClient.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright 2020 Conductor Authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.netflix.conductor.client.spring;

import java.util.function.Supplier;

import org.conductoross.conductor.sdk.Conductor;
import org.conductoross.conductor.sdk.Workers;
import org.conductoross.conductor.sdk.internal.TaskStubs;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.netflix.conductor.client.http.TaskClient;
import com.netflix.conductor.client.spring.sample.AutowiredTasksWorkflow;
import com.netflix.conductor.client.spring.sample.SampleApplication;
import com.netflix.conductor.client.spring.sample.SampleTasks;
import com.netflix.conductor.client.spring.sample.SampleWorkflow;

import io.orkes.conductor.client.spring.OrkesConductorClientAutoConfiguration;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_SELF;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

class ConductorWorkflowAutoConfigurationTest {

private final Workers workers = mock(Workers.class, RETURNS_SELF);

/** A Conductor whose workers are recorded, so no server is needed. */
@Configuration
static class RecordingConductor {
static Workers workers;

@Bean
Conductor conductor() {
Conductor conductor = mock(Conductor.class);
when(conductor.workflows()).thenReturn(workers);
return conductor;
}
}

private ApplicationContextRunner runner() {
RecordingConductor.workers = workers;
return new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(ConductorWorkflowAutoConfiguration.class))
.withUserConfiguration(SampleApplication.class, RecordingConductor.class);
}

@Test
@SuppressWarnings({"unchecked", "rawtypes"})
void hostsWorkflowClassesThatAreNotBeansWithStubsForTheirTasks() {
runner().run(context -> {
assertThat(context).hasSingleBean(ConductorWorkflowHost.class);
assertThat(context).doesNotHaveBean(SampleWorkflow.class);
ArgumentCaptor<Supplier> factory = ArgumentCaptor.forClass(Supplier.class);
verify(workers).workflows(eq(SampleWorkflow.class), factory.capture());
SampleWorkflow first = (SampleWorkflow) factory.getValue().get();
assertThat(first).isNotSameAs(factory.getValue().get());
assertThat(first.tasks()).isInstanceOf(TaskStubs.Stub.class).isNotSameAs(context.getBean(SampleTasks.class));
assertThat(first.environment()).isSameAs(context.getEnvironment());
verify(workers).start();
});
}

@Test
@SuppressWarnings({"unchecked", "rawtypes"})
void rejectsAWorkflowThatGetsTheRealTaskBeanInjected() {
runner().run(context -> {
ArgumentCaptor<Supplier> factory = ArgumentCaptor.forClass(Supplier.class);
verify(workers).workflows(eq(AutowiredTasksWorkflow.class), factory.capture());
assertThatThrownBy(() -> TaskStubs.check(factory.getValue().get()))
.hasMessageContaining("field tasks of");
});
}

@Test
void registersTheTaskDefinitionsOfTaskBeansWithoutPollingThemTwice() {
runner().run(context -> {
verify(workers).taskDefinitions(context.getBean(SampleTasks.class));
verify(workers, never()).tasks(any());
});
}

@Test
void stopsTheWorkersWhenTheContextCloses() {
runner().run(context -> verify(workers, never()).close());
verify(workers).close();
}

@Test
void aServiceThatOnlyStartsWorkflowsCanTurnHostingOff() {
runner().withPropertyValues("conductor.workflows.enabled=false")
.run(context -> assertThat(context).doesNotHaveBean(ConductorWorkflowHost.class));
}

@Test
void leavesASingleTaskClientWhenTheOrkesClientIsConfigured() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(OrkesConductorClientAutoConfiguration.class,
ConductorClientAutoConfiguration.class, ConductorWorkerAutoConfiguration.class,
ConductorWorkflowAutoConfiguration.class))
.withPropertyValues("conductor.client.root-uri=http://localhost:1/api", "conductor.workflows.enabled=false")
.run(context -> assertThat(context).hasSingleBean(TaskClient.class));
}
}
Loading
Loading