WorkflowRun
A WorkflowRun sequences work across groups in one
AgentSet. A step runs an agent assignment, a verify Job,
or a Git land operation. Steps start when all their dependsOn steps succeed.
Independent steps can run at the same time.
Configure the groups
Section titled “Configure the groups”The sample AgentSet has four
groups named retriever, backend, frontend, and qa. Create the
referenced Agents with the kagent Harness in the same namespace as the
AgentSet and WorkflowRun. Give the retriever a search tool that can reach the
source named in its instructions. Give backend and frontend access to the Git
remote and credentials that can push to the candidate branch. QA needs read
access and the checkout’s test dependencies.
Configure kagent structured output for tool-using agents that supply JSON
handoffs. The sample schemas
define terminal results for the retriever, both builders, and QA. In each
Agent’s inline template, set outputSchemaFrom.name to
checkout-workflow-schemas. Set outputSchemaFrom.key to
documents.json for the retriever, candidate.json for backend and
frontend, or qa.json for QA. The sample run references the same keys
through its step output contracts.
The controller uses its Git credentials
to read the remote and advance the target branch. Set
spec.repositoryLease.gitCredentialsSecretRef (when using a run-wide lease) or
land.gitCredentialsSecretRef (for landing-time leases) to override controller
credentials with a Secret in the WorkflowRun’s namespace. Set the repository URL
in the sample agent instructions and in land.repository. Adapt the search
source, test instructions, and leased paths to the repository.
kubectl --namespace team-a apply -f config/samples/workflow-schemas.yamlkubectl --namespace team-a apply -f config/samples/workflow-agentset.yamlkubectl --namespace team-a create -f config/samples/workflowrun.yamlkubectl --namespace team-a get workflowrun checkout-rounding --watchkubectl --namespace team-a get workflowrun checkout-rounding -o yamlPass results between groups
Section titled “Pass results between groups”A run supports up to 32 steps. Each step has a unique name and lists its
prerequisites in dependsOn. To pass a result, use inputsFrom to assign
a local input name to a top-level JSON field from a direct or transitive
prerequisite. kslip appends the run name, UID, and resolved inputs to the
instructions as labeled JSON context. The sample uses the run UID to name a
candidate branch.
An agent step targets a group. The controller selects a bound seat with no active or queued assignment and leaves the step waiting when all eligible seats are busy. A seat becoming available wakes waiting runs for its group. If concurrent runs choose the same seat, the Assignment queue serializes their work.
When a step supplies data to another step or has an output contract, have
the agent return a strict JSON object. kslip reads structured assignment
data first and accepts a complete JSON object from the text response when
structured data is absent. Use output.schemaFrom with a ConfigMap
name and key in the run’s namespace to share a Draft-07 JSON Schema
with kagent. kslip copies referenced schemas into run status before it
dispatches any work. Edits to the ConfigMap affect the validation contract
of runs that start after the edit. Use output.schema with an inline
Draft-07 schema for a workflow-specific contract. Each step declares at
most one schema source. successWhen evaluates a cost-limited CEL boolean
expression over inputs and output. A schema error, a false gate, or a missing required
handoff field fails the run. When successWhen evaluates to false, the step fails
with reason GateRejected and includes the rejected JSON output in the failure
message. Structured results are limited to 16 KiB per step.
When a step returns plain text without an output contract or a downstream
consumer, its status shows a preview limited to 16 KiB of JSON-encoded text.
The rendered instructions and context are limited to 48 KiB per assignment.
Retrieval is an agent assignment. The sample searches for short excerpts and hands their text and source URIs to backend. The retriever’s tools determine which sources it can access.
Hand off a candidate
Section titled “Hand off a candidate”The candidate-only sample
uses the same AgentSet and candidate schema. When the run reaches
Succeeded, the candidate entry in status.steps contains the reported
output.candidateBranch and full output.commit SHA. The controller validates
these fields against the schema. External CI reads the Git remote to confirm
that the branch tip matches the reported SHA before verifying that exact
commit. The Git server can require the trusted CI check on the target
branch through branch protection.
External promotion runs outside kslip’s PathLease ordering and
leased-path enforcement.
Land a candidate
Section titled “Land a candidate”The sample run passes backend’s
commit to frontend and frontend’s exact candidate SHA to QA. The QA seat
reports passed and testedCommit. The gate requires passed and a
reported SHA equal to the candidate. This is an agent attestation. The
WorkflowRun controller evaluates the result and schedules landing after it
passes.
A land step names the repository and target branch. Its candidateBranch
and commit fields select the source branch and full commit SHA from
prerequisite results. Supply lease paths as literal reads and writes
lists or select lists from results using readsFrom and writesFrom.
Use the patterns described in PathLease.
The controller acquires an ordered PathLease when the landing step becomes ready. It verifies the candidate branch tip, checks that the candidate fast-forwards the current target, and compares the final trees to enforce the lease’s write paths. A rename counts as changes to both paths. The check covers the net tree difference. Intermediate commits remain in Git history, and a candidate that changes history with an identical tree can land. The controller pushes the exact commit only if the target still matches the SHA used for these checks.
If the target already contains the candidate, the step reports
AlreadyLanded without updating Git. If another push wins the
compare-and-swap, the controller checks the latest target before retrying
the same candidate. A divergent target reports TargetAdvanced. An absent
target branch reports TargetMissing. The candidate branch and QA result
remain available for inspection. Landing-time leases
coordinate publication with other kslip writers, while builds and QA can
overlap. Each repository lands independently. A later failure leaves any
earlier landing in place.
Reserve paths and verify independently
Section titled “Reserve paths and verify independently”Use spec.lease to coordinate non-Git workflows over arbitrary hierarchical
resource paths (for example, scope: prod/payments,
reads: [config/global/**], writes: [rings/canary/services/checkout]).
kslip acquires a PathLease under spec.lease.scope before
dispatching steps, defaults mode to Exclusive so overlapping mutations
serialize safely, and releases the lease when the run settles.
Set spec.repositoryLease to claim static read and write paths for a Git
repository and target branch. kslip waits until the lease is held before
it dispatches the graph. The controller records the live target SHA under
that lease and supplies it to each agent. Set baseCommit on the lease to
require a specific starting target. Use mode: Exclusive to hold back an
overlapping run, or mode: Ordered to allow work to overlap and wait for
preceding leases before publication. Ordered is the default. A run sets at most
one of spec.lease and spec.repositoryLease.
A verify step runs an operator-registered verifier image as a Kubernetes Job.
Status records each Job attempt, its outcome (Passed, Rejected, or
InfrastructureError), and any bounded /dev/termination-log diagnostic on
exit code 1. Use infrastructureRetries to retry runner errors. Each Job has
its own timeoutSeconds, which defaults to 600 and is capped by the run
deadline.
- Candidate verification (Git): Set
candidateBranchandcommitalongsidespec.repositoryLease. The Job receivesKSLIP_REPOSITORY,KSLIP_TARGET_BRANCH,KSLIP_BASE_COMMIT,KSLIP_CANDIDATE_BRANCH, andKSLIP_CANDIDATE_COMMITand tests the exact candidate on the recorded base. - General verification (non-Git): Omit
candidateBranchandcommitto run an independent Job without a repository lease (for example, an SLO probe, rollout check, or bug reproducer, as in the rollout check sample). Supply staticverify.paramsand upstreaminputsFromfields. kslip passesKSLIP_RUN_NAME,KSLIP_RUN_UID,KSLIP_STEP_NAME, a compact JSON object inKSLIP_INPUTS,KSLIP_PARAM_<NAME>for each static parameter, andKSLIP_INPUT_<NAME>for each scalar dependency input.
A land step in a run with a repository lease uses the run-wide write
paths. Omit the landing step’s separate read and write fields in that case.
Set land.verification to the name of a successful verifier dependency to
require evidence for the exact candidate and base. By default kslip fails the
landing with TargetAdvanced if the target changed after the base was recorded.
Set land.allowDisjointRebase: true to replay the verified candidate onto the
live target when every target commit since BaseCommit touches only paths
outside the run’s declared reads and writes (overlapping target changes
still fail with TargetAdvanced). The controller releases the run-wide lease
after work and any push readback settle.
WorkflowBacklog supplies the repository, target, and run-wide lease when it renders an immutable recipe as a WorkflowRun.
Read or stop a run
Section titled “Read or stop a run”status.steps records assignments, verifier attempts, results, and
confirmed landed SHAs. status.observedGeneration and the Ready condition
(True on Succeeded, False otherwise) summarize run readiness alongside
Kubernetes Events emitted on start and terminal phase transitions. Recipe steps
include their original recipePath.
An agent step’s readyAt records when the controller first observes its
dependencies satisfied, even when the step then waits for a seat.
The timeout defaults to 45 minutes and accepts a positive Go duration up to
2h. The limit includes time spent waiting for seats or leases.
The workflow stops an assignment whose task waits for input or authorization. The failure message includes the task’s waiting diagnostic when available.
Set spec.cancel to true to stop new work and retain the outcome.
The seat checks the owning run’s identity, state, and absolute deadline before
sending an assignment to kagent. Cancellation, timeout, failure, and deletion
stop unfinished assignments. The run reports Stopping while it confirms
those stops or reads back an uncertain Git push. A confirmed push stays on the
target branch.