relay-flow 0.2.1-alpha → 0.2.2-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +155 -22
- package/cmd/relay-flow/beads_composition_test.go +451 -0
- package/cmd/relay-flow/commands_test.go +74 -0
- package/cmd/relay-flow/main.go +25 -0
- package/cmd/relay-flow/scenario_test.go +48 -12
- package/cmd/relay-flow/serve.go +4 -2
- package/examples/beads-workflow.yaml +74 -0
- package/examples/default-story-workflow.yaml +6 -6
- package/go.mod +2 -1
- package/go.sum +2 -0
- package/internal/config/config.go +13 -2
- package/internal/config/merge_test.go +18 -0
- package/internal/execution/goworkflows/activities.go +105 -56
- package/internal/execution/goworkflows/end_feedback_test.go +124 -0
- package/internal/execution/goworkflows/engine_test.go +33 -15
- package/internal/execution/goworkflows/fakes_test.go +50 -4
- package/internal/execution/goworkflows/interpreter.go +36 -29
- package/internal/execution/goworkflows/mailbox_test.go +85 -0
- package/internal/execution/goworkflows/node_runtime_test.go +30 -5
- package/internal/execution/goworkflows/recovery_test.go +2 -2
- package/internal/execution/goworkflows/report_contract_fixture_test.go +31 -0
- package/internal/harness/contract_test.go +10 -0
- package/internal/harness/factory.go +25 -3
- package/internal/harness/harness.go +30 -4
- package/internal/harness/opencode/opencode.go +125 -10
- package/internal/harness/opencode/opencode_test.go +183 -0
- package/internal/harness/opencode/repo_setup.go +361 -0
- package/internal/harness/plugin_selection_test.go +5 -5
- package/internal/recover/recover.go +11 -6
- package/internal/repo/service.go +10 -0
- package/internal/repo/service_test.go +51 -2
- package/internal/run/run.go +6 -4
- package/internal/task/beads/bdcli/bdcli.go +323 -0
- package/internal/task/beads/bdcli/bdcli_test.go +297 -0
- package/internal/task/beads/bdcli/testdata/array.json +1 -0
- package/internal/task/beads/bdcli/testdata/children.json +1 -0
- package/internal/task/beads/bdcli/testdata/claimed.json +1 -0
- package/internal/task/beads/bdcli/testdata/commented.json +1 -0
- package/internal/task/beads/bdcli/testdata/comments.json +1 -0
- package/internal/task/beads/bdcli/testdata/created.json +1 -0
- package/internal/task/beads/bdcli/testdata/empty.json +1 -0
- package/internal/task/beads/bdcli/testdata/object.json +1 -0
- package/internal/task/beads/bdcli/testdata/ready.json +1 -0
- package/internal/task/beads/bdcli/testdata/show.json +1 -0
- package/internal/task/beads/bdcli/testdata/strict-bd.sh +149 -0
- package/internal/task/beads/bdcli/testdata/updated.json +1 -0
- package/internal/task/beads/beads.go +840 -0
- package/internal/task/beads/beads_test.go +609 -0
- package/internal/task/beads/comments_test.go +242 -0
- package/internal/task/beads/config_compatibility_test.go +163 -0
- package/internal/task/beads/lifecycle_inheritance_test.go +168 -0
- package/internal/task/beads/repo_composition_test.go +232 -0
- package/internal/task/beads/runtime_config_test.go +81 -0
- package/internal/task/beads/status_compatibility_test.go +233 -0
- package/internal/task/beads/status_test.go +257 -0
- package/internal/task/beads/testdata/strict-bd-repo.sh +27 -0
- package/internal/task/beads/validation_test.go +110 -0
- package/internal/task/contract_test.go +10 -0
- package/internal/task/factory.go +37 -4
- package/internal/task/jira/auth.go +27 -1
- package/internal/task/jira/auth_test.go +54 -1
- package/internal/task/jira/filters_test.go +60 -0
- package/internal/task/jira/jira.go +171 -29
- package/internal/task/jira/lifecycle_inheritance_test.go +172 -0
- package/internal/task/jira/rest/adf.go +119 -82
- package/internal/task/jira/rest/adf_test.go +60 -0
- package/internal/task/jira/rest/client_test.go +1 -1
- package/internal/task/jira/templates_test.go +118 -0
- package/internal/task/jira/transition_defaults_test.go +4 -2
- package/internal/task/task.go +32 -0
- package/internal/workflow/report_test.go +45 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# relay-flow
|
|
2
2
|
|
|
3
|
-
Durable, graph-based agent workflow runner. A ticket is the unit of work; a workflow YAML declares nodes and routes; a durable engine (go-workflows + SQLite) drives progression, waits, retries, and recovery. The task system (Jira built-
|
|
3
|
+
Durable, graph-based agent workflow runner. A ticket is the unit of work; a workflow YAML declares nodes and routes; a durable engine (go-workflows + SQLite) drives progression, waits, retries, and recovery. The task system (Jira and Beads built-ins) supplies parent tickets and mailbox subtasks; the runner (Orca built-in) owns worktrees and terminals; the harness (OpenCode built-in) owns agent sessions and report semantics. All three are pluggable.
|
|
4
4
|
|
|
5
5
|
This is a ground-up rewrite. The previous per-workflow, in-memory daemon is gone. There is no migration path and no compatibility layer.
|
|
6
6
|
|
|
@@ -14,7 +14,9 @@ This is a ground-up rewrite. The previous per-workflow, in-memory daemon is gone
|
|
|
14
14
|
|---|---|
|
|
15
15
|
| [opencode](https://opencode.ai) | Agents run in opencode sessions (harness) |
|
|
16
16
|
| [Orca](https://github.com/Necmttn/orca) CLI + app | Worktrees + terminals (runner) |
|
|
17
|
-
|
|
|
17
|
+
| `bd` CLI | Beads task-system access (required when `taskPlugin: beads`) |
|
|
18
|
+
| Dolt | External/server-backed Beads only |
|
|
19
|
+
| Jira API token | Jira REST API v3 access (required when `taskPlugin: jira`) |
|
|
18
20
|
| Go 1.24+ | Build the CLI |
|
|
19
21
|
|
|
20
22
|
### Install
|
|
@@ -43,6 +45,14 @@ relay-flow task auth
|
|
|
43
45
|
|
|
44
46
|
`init` only selects the task system, runner, and harness (singleton options are automatic), writes machine config, and initializes SQLite. `task auth` delegates authentication to that selected task plug-in. Jira prompts for its site, email, and masked API token, validates `/myself`, and owns the system-wide `credentials.yaml`; for scripts, pass `task auth --site`, `--email`, and `--token`. A normal init rerun refuses existing state. `relay-flow init --force` updates safe stopped instances while preserving durable and repo state.
|
|
45
47
|
|
|
48
|
+
For Beads, select the plugin explicitly when scripting setup:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
relay-flow init --task-plugin beads --runner-plugin orca --harness-plugin opencode
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Beads authentication is owned by the Beads workspace and its `bd`/Dolt configuration. `relay-flow task auth` is a no-op for Beads and does not create relay-flow credentials; do not add a Jira token to a Beads-only installation.
|
|
55
|
+
|
|
46
56
|
The full machine layout is fixed under `~/.relay-flow` (0700):
|
|
47
57
|
|
|
48
58
|
```
|
|
@@ -58,6 +68,23 @@ workflows/<name>.yaml 0644 submitted workflow definitions
|
|
|
58
68
|
|
|
59
69
|
### Register a repo
|
|
60
70
|
|
|
71
|
+
`repo register` and `workflow submit` are server-backed commands: start the
|
|
72
|
+
server first, otherwise they fail with `dial unix ~/.relay-flow/server.sock:
|
|
73
|
+
connect: no such file or directory`.
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
relay-flow serve --background
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The repo must already exist in the runner. For the Orca runner, add it first
|
|
80
|
+
and keep the names aligned — the runner resolves a repo by path **and** display
|
|
81
|
+
name, so `--name` must equal the Orca display name (Orca derives it from the
|
|
82
|
+
directory name):
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
orca repo add --path /work/payments # displayName becomes "payments"
|
|
86
|
+
```
|
|
87
|
+
|
|
61
88
|
```sh
|
|
62
89
|
relay-flow repo register
|
|
63
90
|
```
|
|
@@ -68,6 +95,78 @@ Each Jira poll uses REST v3 enhanced search and requests linked-issue status wit
|
|
|
68
95
|
|
|
69
96
|
For scripts, use `relay-flow repo register --name <name> --path <path> --set project=<project>`. Component is always derived from `--name` and cannot be overridden. Registration is rejected while another repo already holds the same canonical task scope.
|
|
70
97
|
|
|
98
|
+
### Beads task system
|
|
99
|
+
|
|
100
|
+
Beads uses the local `bd` CLI and supports both an embedded workspace and a workspace backed by an externally managed Dolt server. Install and verify the tools before registering a Beads repo:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
bd --version
|
|
104
|
+
# Required only for server-backed workspaces:
|
|
105
|
+
dolt version
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Initialize the Beads workspace before `repo register`; relay-flow never initializes a workspace, runs migrations, or starts `bd serve`.
|
|
109
|
+
|
|
110
|
+
For a local workspace, keep the workspace beside the code repository and use its `.beads` directory as `beadsDir`:
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
cd /work/payments
|
|
114
|
+
bd init --prefix payments
|
|
115
|
+
# code repository: /work/payments
|
|
116
|
+
# Beads workspace: /work/payments/.beads
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
For a server-backed workspace, an operator starts and manages Dolt separately, then initializes Beads with external-server metadata. The exact server host, port, credentials, and data directory belong to that Beads/Dolt deployment; relay-flow does not manage their lifecycle:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
# Run this from the externally managed Beads/Dolt environment, not from relay-flow.
|
|
123
|
+
BEADS_DOLT_SERVER_TLS=0 \
|
|
124
|
+
BEADS_DOLT_PASSWORD= \
|
|
125
|
+
bd init \
|
|
126
|
+
--server \
|
|
127
|
+
--external \
|
|
128
|
+
--server-host 127.0.0.1 \
|
|
129
|
+
--server-port 13307 \
|
|
130
|
+
--server-user root \
|
|
131
|
+
--prefix payments \
|
|
132
|
+
--non-interactive \
|
|
133
|
+
--skip-hooks \
|
|
134
|
+
--skip-agents
|
|
135
|
+
# Example external workspace: /var/lib/beads/payments/.beads
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Register the code repository and its Beads workspace separately. `beadsDir` is required for every Beads repo, must name an existing directory, and is the task scope used to reject duplicate workspace registration:
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
# Local/embedded workspace
|
|
142
|
+
relay-flow repo register \
|
|
143
|
+
--name payments \
|
|
144
|
+
--path /work/payments \
|
|
145
|
+
--set beadsDir=/work/payments/.beads
|
|
146
|
+
|
|
147
|
+
# External/server-backed workspace
|
|
148
|
+
relay-flow repo register \
|
|
149
|
+
--name payments \
|
|
150
|
+
--path /work/payments \
|
|
151
|
+
--set beadsDir=/var/lib/beads/payments/.beads
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The registered `--path` remains the code/runner repository. Every `bd` command runs with that path as its working directory and the configured `beadsDir` as `BEADS_DIR`, even when unrelated Beads selector variables exist in the relay-flow environment. Two repos may register different canonical `beadsDir` values; a second repo pointing at the same workspace is rejected. A Beads prefix such as `payments-...` is optional and only makes issue IDs recognizable—it is not a component, workspace selector, poller selector, or database isolation mechanism.
|
|
155
|
+
|
|
156
|
+
Beads workflow filters are structured and evaluated in relay-flow. For example, `examples/beads-workflow.yaml` uses the Beads status and issue-type fields:
|
|
157
|
+
|
|
158
|
+
```yaml
|
|
159
|
+
taskConfig:
|
|
160
|
+
filters:
|
|
161
|
+
parentStatuses: [open]
|
|
162
|
+
issueTypes: [epic]
|
|
163
|
+
labels: [relay-ready]
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The supported Beads status names are `open`, `in_progress`, `blocked`, `deferred`, `hooked`, and `closed`. The claimed-parent poll uses the canonical active set `open,in_progress,blocked,deferred`; it intentionally does not substitute `hooked` for `deferred`. Omitted lifecycle settings move the parent to `in_progress` at `start`, a work-node mailbox to `in_progress`, and the parent to `closed` at `end` — the same shape as Jira, with Beads-native values. Relay-flow creates one Repo Poller per registered repo, not one poller per workflow. Each poll reads ready top-level parents and relay-owned active parents, deduplicates them, and never routes mailbox children. Claims are permanent `wf:<workflow>` labels.
|
|
167
|
+
|
|
168
|
+
Beads does not need relay-flow credentials or a Beads-specific poller. In server mode, leave Dolt and Beads server setup running outside relay-flow and point each repo at its own `beadsDir`.
|
|
169
|
+
|
|
71
170
|
### Submit a workflow
|
|
72
171
|
|
|
73
172
|
```sh
|
|
@@ -76,10 +175,13 @@ relay-flow workflow submit --file <path>
|
|
|
76
175
|
|
|
77
176
|
Workflows live at `~/.relay-flow/workflows/<name>.yaml` after submit. Replacement and removal are rejected while any run of that workflow is active.
|
|
78
177
|
|
|
79
|
-
Use [`examples/default-story-workflow.yaml`](examples/default-story-workflow.yaml) as a fully annotated starting point. Replace
|
|
178
|
+
Use [`examples/default-story-workflow.yaml`](examples/default-story-workflow.yaml) as a fully annotated Jira-oriented starting point, or [`examples/beads-workflow.yaml`](examples/beads-workflow.yaml) for the Beads filter and lifecycle shape. Replace the repo name and uncomment only the optional fields you need.
|
|
80
179
|
|
|
81
180
|
### Run
|
|
82
181
|
|
|
182
|
+
The server must already be running for `repo register` and `workflow submit`;
|
|
183
|
+
the same process polls repos and drives runs.
|
|
184
|
+
|
|
83
185
|
```sh
|
|
84
186
|
relay-flow serve # normal start; requires an initialized database
|
|
85
187
|
relay-flow serve --background # detached; returns after the server is ready
|
|
@@ -101,13 +203,14 @@ repos: [payments] # one or more registered repos, unique
|
|
|
101
203
|
cleanupRunnerOnEnd: false # optional; when true the runner tears down at end
|
|
102
204
|
|
|
103
205
|
taskConfig: # optional; adapter-owned; merged root → repo → workflow → node
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
work: { mailbox: "In Progress" }
|
|
107
|
-
end: { parent: "Done" }
|
|
206
|
+
filters:
|
|
207
|
+
parentStatuses: [To Do]
|
|
108
208
|
|
|
109
209
|
nodes:
|
|
110
210
|
start:
|
|
211
|
+
taskConfig: # transitionTo belongs on a node: it applies to
|
|
212
|
+
transitionTo: # the lifecycle point the node represents
|
|
213
|
+
parentStatus: In Progress
|
|
111
214
|
onSuccess: [{ target: coding }]
|
|
112
215
|
|
|
113
216
|
coding:
|
|
@@ -140,7 +243,9 @@ Rules enforced at submit:
|
|
|
140
243
|
|
|
141
244
|
### Task-config merge
|
|
142
245
|
|
|
143
|
-
`taskConfig` may appear at root, repo, workflow, and node scopes. The adapter merges in that order: maps merge recursively, later scalar/list replaces, omitted keys inherit, explicit YAML `null` is rejected. The merged values decode against one adapter-owned typed config at use time.
|
|
246
|
+
`taskConfig` may appear at root, repo, workflow, and node scopes. The adapter merges in that order: maps merge recursively, later scalar/list replaces, omitted keys inherit, explicit YAML `null` is rejected. The merged values decode against one adapter-owned typed config at use time. Adapter lifecycle defaults sit underneath all four scopes, so the effective precedence is `adapter default < root < repo < workflow < node`.
|
|
247
|
+
|
|
248
|
+
`transitionTo` describes one lifecycle point, so configure it on a node. A `transitionTo` set at root, repo, or workflow scope applies to **every** lifecycle point that reads it — including `end`, where a `parentStatus` other than the closing status stops the parent from being closed.
|
|
144
249
|
|
|
145
250
|
### Jira transition defaults
|
|
146
251
|
|
|
@@ -150,31 +255,59 @@ Omitted transitions default to:
|
|
|
150
255
|
- work node: mailbox → `In Progress` (parent unchanged)
|
|
151
256
|
- `end`: parent → `Done`
|
|
152
257
|
|
|
258
|
+
### Beads transition defaults
|
|
259
|
+
|
|
260
|
+
Beads follows the same lifecycle shape with Beads-native values:
|
|
261
|
+
|
|
262
|
+
- `start`: parent → `in_progress`
|
|
263
|
+
- work node: mailbox → `in_progress` (parent unchanged)
|
|
264
|
+
- `end`: parent → `closed`
|
|
265
|
+
|
|
266
|
+
A parent moved to `in_progress` stays visible to the claimed-parent poll, which reads `open,in_progress,blocked,deferred`. Entering a node reuses that node's mailbox: a fresh mailbox moves `open → in_progress` and a revisited one moves `closed → in_progress`. Beads reads the issue before every status write, so an already-applied status is a no-op and a status relay-flow did not set (for example a human marking an issue `blocked`) blocks the transition and retries instead of being overwritten.
|
|
267
|
+
|
|
268
|
+
### Shared task configuration and provider status values
|
|
269
|
+
|
|
270
|
+
Beads and Jira use the shared `filters`, `templates`, optional top-level
|
|
271
|
+
`assignee`, and `transitionTo` field names. `transitionTo` uses
|
|
272
|
+
`parentStatus` for the parent issue and `taskStatus` for a mailbox. In both
|
|
273
|
+
adapters `assignee` is the default assignee filter when `filters.assignees` is
|
|
274
|
+
absent, and an `assignee` in effect for a node also assigns that node's
|
|
275
|
+
mailbox. Beads requires the repo-only `taskConfig.beadsDir` shown above; Jira
|
|
276
|
+
instead uses its repo `project` and `component` keys. `project` and
|
|
277
|
+
`component` are not Beads fields, and a Beads issue prefix is not a component
|
|
278
|
+
or workspace selector. Beads status values remain native (`open`,
|
|
279
|
+
`in_progress`, `blocked`, `deferred`, `hooked`, `closed`), while Jira values
|
|
280
|
+
remain native (`In Progress`, `Done`, and so on); relay-flow does not
|
|
281
|
+
translate arbitrary values between providers. Beads rejects workflow/node-level
|
|
282
|
+
template overrides because the fixed task text rendering contract has no
|
|
283
|
+
lower-scope input.
|
|
284
|
+
|
|
153
285
|
---
|
|
154
286
|
|
|
155
287
|
## Structured node report
|
|
156
288
|
|
|
157
|
-
Every visit (agent or HITL)
|
|
289
|
+
Every visit (agent or HITL) submits one report with the same fixed labels:
|
|
158
290
|
|
|
159
291
|
```
|
|
160
292
|
STATUS: success | failure
|
|
161
293
|
NEXT STEP: <one configured route for that status>
|
|
162
294
|
|
|
163
|
-
SUMMARY
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
295
|
+
SUMMARY:
|
|
296
|
+
COMPLETED: ...
|
|
297
|
+
COMMITS: <commit IDs or None>
|
|
298
|
+
NOT COMPLETED: ... | None
|
|
299
|
+
ISSUES DISCOVERED: ... | None
|
|
300
|
+
VERIFICATION: ...
|
|
301
|
+
NOTES: ... | None
|
|
302
|
+
|
|
303
|
+
FEEDBACK:
|
|
304
|
+
REASON FOR NEXT STEP: ...
|
|
305
|
+
REQUIRED ACTIONS: ...
|
|
306
|
+
RELEVANT CONTEXT: ...
|
|
307
|
+
EXPECTED RESULT: ...
|
|
175
308
|
```
|
|
176
309
|
|
|
177
|
-
`None` is the literal marker for an intentionally empty section. When `NEXT STEP` is `end`, every FEEDBACK field must be `None` and no feedback comment is written.
|
|
310
|
+
The labels above are fixed; configurable templates do not change the parsed report contract. The plugin submits one `report` object containing both lower-camel `summary` and `feedback` objects. Relay-flow validates that complete shape once, renders `summaryReport` through the task system's summary-comment template on the current mailbox, and renders `feedbackReport` through its feedback-comment template on only the selected next mailbox. `None` is the literal marker for an intentionally empty section. When `NEXT STEP` is `end`, every FEEDBACK field must be `None` and no feedback comment is written.
|
|
178
311
|
|
|
179
312
|
The plugin delivers `{runId, node, reportId, report}` as one JSON object via `relay-flow report` stdin with the shared backoff (initial 2s, factor 2, jitter 0.2, max 5m) until acknowledged. It derives `reportId` from the harness session/message identity. Duplicate/stale reports are acked safely with no repeated graph effects. Invalid agent output is nudged; invalid HITL output stays silent.
|
|
180
313
|
|