workstream
Workstream model for lane-level execution and integration state.
This package defines immutable workstream specifications, mutable runtime state for each workstream lane, and the workstream-level lifecycle runner with its I/O protocols.
Subpackages
core: Specs, runtime state, protocols, and runner. implementations: Concrete protocol implementations.
WorkstreamIntegrator
Bases: Protocol
Create integration PR for a workstream lane.
Source code in src/agentrelay/workstream/core/io.py
33 34 35 36 37 38 39 40 41 42 43 44 | |
create_integration_pr(workstream_runtime)
Create a PR from the integration branch to the merge target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workstream_runtime
|
WorkstreamRuntime
|
Workstream runtime whose integration branch should be submitted as a PR. |
required |
Source code in src/agentrelay/workstream/core/io.py
37 38 39 40 41 42 43 44 | |
WorkstreamPreparer
Bases: Protocol
Provision workspace infrastructure for a workstream lane.
Source code in src/agentrelay/workstream/core/io.py
20 21 22 23 24 25 26 27 28 29 30 | |
prepare_workstream(workstream_runtime)
Provision worktree and integration branch for this workstream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workstream_runtime
|
WorkstreamRuntime
|
Workstream runtime to provision. |
required |
Source code in src/agentrelay/workstream/core/io.py
24 25 26 27 28 29 30 | |
WorkstreamTeardown
Bases: Protocol
Clean up workstream workspace infrastructure.
Source code in src/agentrelay/workstream/core/io.py
47 48 49 50 51 52 53 54 55 56 57 58 | |
teardown_workstream(workstream_runtime)
Delete worktree and integration branch for this workstream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workstream_runtime
|
WorkstreamRuntime
|
Workstream runtime whose resources should be cleaned up. |
required |
Source code in src/agentrelay/workstream/core/io.py
51 52 53 54 55 56 57 58 | |
StandardWorkstreamRunner
dataclass
Standard workstream lifecycle runner.
Drives workstream-level operations (prepare, integrate, teardown) by delegating to per-step protocol implementations. The orchestrator calls these methods at appropriate scheduling points.
Attributes:
| Name | Type | Description |
|---|---|---|
_preparer |
WorkstreamPreparer
|
Provision worktree and integration branch. |
_integrator |
WorkstreamIntegrator
|
Create integration PR. |
_teardown |
WorkstreamTeardown
|
Clean up worktree and integration branch. |
Source code in src/agentrelay/workstream/core/runner.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
prepare(workstream_runtime)
Provision workspace infrastructure for a workstream.
Creates the worktree and integration branch. Transitions from
PENDING to ACTIVE on success, or FAILED on error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workstream_runtime
|
WorkstreamRuntime
|
Workstream runtime to provision. |
required |
Source code in src/agentrelay/workstream/core/runner.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
integrate(workstream_runtime)
Create the integration PR for the workstream.
Transitions to PR_CREATED on success, or FAILED on error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workstream_runtime
|
WorkstreamRuntime
|
Workstream runtime to integrate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
WorkstreamRunResult |
WorkstreamRunResult
|
Snapshot of state after the operation. |
Source code in src/agentrelay/workstream/core/runner.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
teardown(workstream_runtime)
Clean up workstream workspace infrastructure.
Deletes the worktree and integration branch. Failures are recorded as concerns rather than changing workstream status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workstream_runtime
|
WorkstreamRuntime
|
Workstream runtime to tear down. |
required |
Source code in src/agentrelay/workstream/core/runner.py
132 133 134 135 136 137 138 139 140 141 142 143 144 | |
WorkstreamRunner
Bases: Protocol
Protocol for the workstream runner boundary used by Orchestrator.
Different lifecycle variants (standard, dry-run) are different classes satisfying this protocol. The orchestrator does not know or care about internal step structure.
Source code in src/agentrelay/workstream/core/runner.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
prepare(workstream_runtime)
Provision workspace infrastructure for a workstream.
Source code in src/agentrelay/workstream/core/runner.py
66 67 68 | |
integrate(workstream_runtime)
Create the integration PR for the workstream.
Source code in src/agentrelay/workstream/core/runner.py
70 71 72 | |
teardown(workstream_runtime)
Clean up workstream workspace infrastructure.
Source code in src/agentrelay/workstream/core/runner.py
74 75 76 | |
WorkstreamRunResult
dataclass
Snapshot of workstream state after a lifecycle operation.
Attributes:
| Name | Type | Description |
|---|---|---|
workstream_id |
str
|
Workstream identifier. |
status |
WorkstreamStatus
|
Current workstream status after the operation. |
error |
Optional[str]
|
Error message if the operation failed, or |
Source code in src/agentrelay/workstream/core/runner.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
from_runtime(runtime)
classmethod
Build a result snapshot from the current workstream runtime state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
WorkstreamRuntime
|
Workstream runtime to snapshot. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
WorkstreamRunResult |
WorkstreamRunResult
|
Snapshot of workstream ID, status, and error. |
Source code in src/agentrelay/workstream/core/runner.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
TaskSummary
dataclass
Per-task summary included in integration PR body.
Attributes:
| Name | Type | Description |
|---|---|---|
task_id |
str
|
Unique task identifier. |
description |
Optional[str]
|
Human-readable task description, or |
pr_url |
Optional[str]
|
URL of the task's pull request, or |
concerns |
tuple[str, ...]
|
Design concerns recorded by the agent. |
Source code in src/agentrelay/workstream/core/runtime.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
WorkstreamArtifacts
dataclass
Outputs and observations produced while advancing a workstream.
Attributes:
| Name | Type | Description |
|---|---|---|
merge_pr_url |
Optional[str]
|
URL of the workstream integration PR, or |
concerns |
list[str]
|
List of notable observations or concerns for this lane. |
task_summaries |
list[TaskSummary]
|
Per-task summaries for integration PR body. |
Source code in src/agentrelay/workstream/core/runtime.py
114 115 116 117 118 119 120 121 122 123 124 125 126 | |
WorkstreamRuntime
dataclass
Mutable runtime envelope for a :class:WorkstreamSpec.
Attributes:
| Name | Type | Description |
|---|---|---|
spec |
WorkstreamSpec
|
Immutable workstream specification for this lane. |
state |
WorkstreamState
|
Mutable lane operational state. |
artifacts |
WorkstreamArtifacts
|
Mutable lane output artifacts. |
Source code in src/agentrelay/workstream/core/runtime.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
status
property
Current workstream status, derived from signal files on disk.
Falls back to PENDING if no signal directory has been set,
unless an error has been recorded (indicating failure before
provisioning), in which case FAILED is returned.
mark_pending()
Write the pending signal file.
Source code in src/agentrelay/workstream/core/runtime.py
163 164 165 | |
mark_active()
Write the active signal file.
Source code in src/agentrelay/workstream/core/runtime.py
167 168 169 | |
mark_merge_ready()
Write the merge_ready signal file.
Source code in src/agentrelay/workstream/core/runtime.py
171 172 173 | |
mark_pr_created(pr_url)
Write the pr_created signal file with the PR URL.
Source code in src/agentrelay/workstream/core/runtime.py
175 176 177 178 | |
mark_merged()
Write the merged signal file.
Source code in src/agentrelay/workstream/core/runtime.py
180 181 182 | |
mark_failed(error)
Write the failed signal file with the error message.
If signal_dir is not set (workstream was never prepared),
only the in-memory error is recorded without writing to disk.
Source code in src/agentrelay/workstream/core/runtime.py
184 185 186 187 188 189 190 191 192 | |
WorkstreamState
dataclass
Mutable operational state of a workstream lane.
Attributes:
| Name | Type | Description |
|---|---|---|
signal_dir |
Optional[Path]
|
Path to the workstream signal directory for status files,
or |
worktree_path |
Optional[Path]
|
Filesystem path to the worktree used for this lane, or
|
branch_name |
Optional[str]
|
Primary branch name used for this lane, or |
error |
Optional[str]
|
Error message if lane execution failed, else |
Source code in src/agentrelay/workstream/core/runtime.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
WorkstreamStatus
Bases: str, Enum
Execution state of a workstream during orchestration.
Attributes:
| Name | Type | Description |
|---|---|---|
PENDING |
Workstream has not started provisioning/execution. |
|
ACTIVE |
Workstream is currently active (for example has running tasks). |
|
MERGE_READY |
All tasks completed; workstream is ready for integration. |
|
PR_CREATED |
Integration PR has been created, awaiting merge. |
|
MERGED |
Integration PR has been merged into the target branch. |
|
FAILED |
Workstream execution failed. |
Source code in src/agentrelay/workstream/core/runtime.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
WorkstreamSpec
dataclass
Immutable specification for a task workstream.
A workstream models a branch/worktree execution lane that one or more tasks can target. Parent/child workstream relationships are defined at the spec level and validated by graph-building layers.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique workstream identifier within a task graph. |
parent_workstream_id |
Optional[str]
|
Optional parent workstream ID for hierarchical
stream topologies (for example |
base_branch |
str
|
Branch name used as the base when creating workstream
integration branches or worktrees. Defaults to |
merge_target_branch |
str
|
Branch name the workstream ultimately merges into.
Defaults to |
Source code in src/agentrelay/workstream/core/workstream.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
GhWorkstreamIntegrator
dataclass
Create the workstream integration PR via GitHub CLI.
Creates a pull request from the workstream's integration branch into
its merge_target_branch. Does NOT merge the PR — that is left
for human review (or a future agent-merge step).
Source code in src/agentrelay/workstream/implementations/workstream_integrator.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
create_integration_pr(workstream_runtime)
Create a PR from the integration branch to the merge target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workstream_runtime
|
WorkstreamRuntime
|
Workstream runtime whose integration branch should be submitted as a PR. |
required |
Source code in src/agentrelay/workstream/implementations/workstream_integrator.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
GitWorkstreamPreparer
dataclass
Provision a worktree and integration branch for a workstream lane.
Creates a git worktree rooted at
<repo_path>/.worktrees/<graph_name>/<workstream_id> with a new
integration branch
agentrelay/<graph_name>/<workstream_id>/integration off the
workstream's base_branch. Pushes the integration branch to origin
so that task PRs can target it.
Source code in src/agentrelay/workstream/implementations/workstream_preparer.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
prepare_workstream(workstream_runtime)
Provision worktree and integration branch for this workstream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workstream_runtime
|
WorkstreamRuntime
|
Workstream runtime to provision. |
required |
Source code in src/agentrelay/workstream/implementations/workstream_preparer.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
GitWorkstreamTeardown
dataclass
Clean up workstream worktree and integration branch.
Performs best-effort cleanup: removes the worktree directory, deletes the local integration branch, and deletes the remote integration branch. Errors during any step are silently caught so that subsequent cleanup steps still execute.
Source code in src/agentrelay/workstream/implementations/workstream_teardown.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
teardown_workstream(workstream_runtime)
Delete worktree and integration branch for this workstream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workstream_runtime
|
WorkstreamRuntime
|
Workstream runtime whose resources should be cleaned up. |
required |
Source code in src/agentrelay/workstream/implementations/workstream_teardown.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |