relay-flow 0.1.0-alpha.0 → 0.2.1-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 +160 -143
- package/cmd/relay-flow/commands_test.go +968 -0
- package/cmd/relay-flow/main.go +877 -175
- package/cmd/relay-flow/scenario_test.go +1310 -0
- package/cmd/relay-flow/serve.go +610 -0
- package/examples/default-story-workflow.yaml +88 -0
- package/go.mod +69 -2
- package/go.sum +185 -0
- package/internal/config/config.go +88 -0
- package/internal/config/machine.go +99 -48
- package/internal/config/machine_test.go +248 -0
- package/internal/config/merge_test.go +118 -0
- package/internal/config/writeatomic.go +36 -0
- package/internal/config/writeatomic_test.go +98 -0
- package/internal/execution/goworkflows/activities.go +490 -0
- package/internal/execution/goworkflows/engine.go +520 -0
- package/internal/execution/goworkflows/engine_test.go +660 -0
- package/internal/execution/goworkflows/fakes_test.go +509 -0
- package/internal/execution/goworkflows/interpreter.go +613 -0
- package/internal/execution/goworkflows/logging_test.go +154 -0
- package/internal/execution/goworkflows/mailbox_test.go +423 -0
- package/internal/execution/goworkflows/node_runtime_integration_test.go +133 -0
- package/internal/execution/goworkflows/node_runtime_test.go +510 -0
- package/internal/execution/goworkflows/projection.go +504 -0
- package/internal/execution/goworkflows/recovery_test.go +1092 -0
- package/internal/execution/goworkflows/retry_log_test.go +59 -0
- package/internal/execution/goworkflows/retry_projection_test.go +98 -0
- package/internal/harness/contract_test.go +174 -0
- package/internal/harness/factory.go +63 -0
- package/internal/harness/harness.go +41 -0
- package/internal/harness/opencode/opencode.go +166 -0
- package/internal/harness/opencode/opencode_test.go +50 -0
- package/internal/harness/plugin_selection_test.go +126 -0
- package/internal/identity/identity.go +37 -0
- package/internal/logging/logging.go +56 -0
- package/internal/logging/logging_test.go +116 -0
- package/internal/paths/paths.go +69 -0
- package/internal/recover/recover.go +115 -0
- package/internal/repo/poller.go +186 -0
- package/internal/repo/poller_test.go +327 -0
- package/internal/repo/repo.go +132 -0
- package/internal/repo/service.go +216 -0
- package/internal/repo/service_test.go +298 -0
- package/internal/retry/retry.go +118 -0
- package/internal/router/router.go +84 -0
- package/internal/router/router_test.go +231 -0
- package/internal/run/manager.go +121 -0
- package/internal/run/run.go +140 -0
- package/internal/run/run_identity_test.go +52 -0
- package/internal/run/run_manager_test.go +286 -0
- package/internal/runner/contract_test.go +259 -0
- package/internal/runner/factory.go +65 -0
- package/internal/runner/orca/orca.go +341 -172
- package/internal/runner/orca/orca_test.go +256 -143
- package/internal/runner/orca/orcacli/orcacli.go +220 -0
- package/internal/runner/orca/orcacli/orcacli_test.go +157 -0
- package/internal/runner/orca/orcacli/testdata/repo-list.json +18 -0
- package/internal/runner/orca/orcacli/testdata/strict-orca.sh +32 -0
- package/internal/runner/orca/orcacli/testdata/terminal-close.json +12 -0
- package/internal/runner/orca/orcacli/testdata/terminal-create.json +18 -0
- package/internal/runner/orca/orcacli/testdata/terminal-list.json +51 -0
- package/internal/runner/orca/orcacli/testdata/terminal-send.json +1 -0
- package/internal/runner/orca/orcacli/testdata/terminal-show.json +1 -0
- package/internal/runner/orca/orcacli/testdata/worktree-create.json +22 -0
- package/internal/runner/orca/orcacli/testdata/worktree-list.json +31 -0
- package/internal/runner/orca/orcacli/testdata/worktree-remove.json +6 -0
- package/internal/runner/runner.go +54 -64
- package/internal/server/api_test.go +300 -0
- package/internal/server/client.go +192 -74
- package/internal/server/fixture_test.go +248 -0
- package/internal/server/server.go +425 -248
- package/internal/server/shutdown_test.go +116 -0
- package/internal/task/auth_test.go +48 -0
- package/internal/task/contract_test.go +225 -0
- package/internal/task/factory.go +119 -0
- package/internal/task/jira/auth.go +183 -0
- package/internal/task/jira/auth_test.go +107 -0
- package/internal/task/jira/effects_test.go +39 -0
- package/internal/task/jira/filters_test.go +254 -0
- package/internal/task/jira/helpers_test.go +70 -0
- package/internal/task/jira/jira.go +538 -0
- package/internal/task/jira/normalize.go +119 -0
- package/internal/task/jira/rest/adf.go +128 -0
- package/internal/task/jira/rest/client.go +573 -0
- package/internal/task/jira/rest/client_test.go +381 -0
- package/internal/task/jira/testdata/jira_search_issues.json +120 -0
- package/internal/task/jira/transition_defaults_test.go +158 -0
- package/internal/task/jira/validation_test.go +94 -0
- package/internal/task/task.go +84 -0
- package/internal/workflow/report.go +85 -0
- package/internal/workflow/report_test.go +259 -0
- package/internal/workflow/service.go +142 -0
- package/internal/workflow/store.go +136 -0
- package/internal/workflow/store_test.go +282 -0
- package/internal/workflow/workflow.go +345 -0
- package/internal/workflow/workflow_test.go +412 -0
- package/package.json +7 -2
- package/internal/acli/acli.go +0 -229
- package/internal/config/demo_test.go +0 -17
- package/internal/config/schema.go +0 -193
- package/internal/config/schema_test.go +0 -162
- package/internal/daemon/daemon.go +0 -218
- package/internal/daemon/daemon_test.go +0 -204
- package/internal/discovery/discovery.go +0 -122
- package/internal/discovery/discovery_test.go +0 -62
- package/internal/opencode/opencode.go +0 -26
- package/internal/orcacli/orcacli.go +0 -264
- package/internal/runner/orca/README.md +0 -64
- package/internal/runner/runner_test.go +0 -64
- package/internal/server/server_test.go +0 -195
- package/internal/tasks/jira/README.md +0 -69
- package/internal/tasks/jira/component_test.go +0 -16
- package/internal/tasks/jira/decode.go +0 -24
- package/internal/tasks/jira/jira.go +0 -231
- package/internal/tasks/jira/jira_test.go +0 -259
- package/internal/tasks/jira/jql_test.go +0 -16
- package/internal/tasks/tasks.go +0 -90
- package/internal/tasks/tasks_test.go +0 -91
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# relay-flow
|
|
2
2
|
|
|
3
|
-
|
|
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-in) 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
|
+
|
|
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.
|
|
4
6
|
|
|
5
7
|
---
|
|
6
8
|
|
|
@@ -10,190 +12,205 @@ Graph-based agent workflow engine. Tickets are tokens moving across **nodes**; e
|
|
|
10
12
|
|
|
11
13
|
| Tool | Why |
|
|
12
14
|
|---|---|
|
|
13
|
-
| [opencode](https://opencode.ai) | Agents run in opencode sessions |
|
|
14
|
-
| [Orca](https://github.com/Necmttn/orca) CLI + app | Worktrees + terminals (
|
|
15
|
-
|
|
|
16
|
-
| Go 1.
|
|
15
|
+
| [opencode](https://opencode.ai) | Agents run in opencode sessions (harness) |
|
|
16
|
+
| [Orca](https://github.com/Necmttn/orca) CLI + app | Worktrees + terminals (runner) |
|
|
17
|
+
| Jira API token | Jira REST API v3 access (task system) |
|
|
18
|
+
| Go 1.24+ | Build the CLI |
|
|
17
19
|
|
|
18
20
|
### Install
|
|
19
21
|
|
|
20
22
|
```sh
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
go install github.com/rajpopat27/relay-flow/cmd/relay-flow@latest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
OpenCode plugin: add `"relay-flow-plugin"` to the `plugin` array in your repo's `opencode.json`:
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"$schema": "https://opencode.ai/config.json",
|
|
31
|
+
"plugin": ["relay-flow-plugin"]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The plugin is the report-path half of the harness contract: it registers each emitted harness session with `{runId, node, sessionId}`, parses the agent's structured report, applies the agent/HITL nudge policy, and delivers `{runId, node, reportId, report}` via `relay-flow report` with retry. `reportId` comes from the harness session/message identity; `nodeVisitID` is internal and is never part of either plugin payload.
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
go install github.com/rajpopat27/relay-flow/cmd/relay-flow@v0.1.2
|
|
37
|
+
### One-time machine setup
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
```sh
|
|
40
|
+
relay-flow init
|
|
41
|
+
relay-flow task auth
|
|
32
42
|
```
|
|
33
43
|
|
|
34
|
-
|
|
44
|
+
`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.
|
|
35
45
|
|
|
36
|
-
|
|
46
|
+
The full machine layout is fixed under `~/.relay-flow` (0700):
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
```
|
|
49
|
+
config.yaml 0600 machine config
|
|
50
|
+
credentials.yaml 0600 selected task plug-in credentials
|
|
51
|
+
state.db 0600 durable execution (SQLite)
|
|
52
|
+
server.sock 0600 CLI ↔ server
|
|
53
|
+
server.lock 0600 single-process flock
|
|
54
|
+
server.log 0600
|
|
55
|
+
plugin.log 0600
|
|
56
|
+
workflows/<name>.yaml 0644 submitted workflow definitions
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Register a repo
|
|
43
60
|
|
|
44
|
-
|
|
61
|
+
```sh
|
|
62
|
+
relay-flow repo register
|
|
63
|
+
```
|
|
45
64
|
|
|
46
|
-
|
|
65
|
+
Shows a multi-select titled `Select repositories`; use Space to select Orca repos and Enter to confirm. Enter the Jira project once. Each repo is registered sequentially with its Orca name/path and a Jira component derived from that repo name. Earlier registrations remain if a later one fails.
|
|
47
66
|
|
|
48
|
-
|
|
67
|
+
Each Jira poll uses REST v3 enhanced search and requests linked-issue status with the candidate fields. Tickets with any unfinished inward `Blocks` issue are filtered before routing; no per-ticket blocker lookup is made.
|
|
49
68
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
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
|
+
|
|
71
|
+
### Submit a workflow
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
relay-flow workflow submit --file <path>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Workflows live at `~/.relay-flow/workflows/<name>.yaml` after submit. Replacement and removal are rejected while any run of that workflow is active.
|
|
78
|
+
|
|
79
|
+
Use [`examples/default-story-workflow.yaml`](examples/default-story-workflow.yaml) as a fully annotated starting point. Replace its repo name and uncomment only the optional fields you need.
|
|
80
|
+
|
|
81
|
+
### Run
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
relay-flow serve # normal start; requires an initialized database
|
|
85
|
+
relay-flow serve --background # detached; returns after the server is ready
|
|
86
|
+
relay-flow serve --recover # explicit destructive rebuild from the task system
|
|
87
|
+
relay-flow stop
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`--background` preserves `--debug` and `--recover`, logs to `~/.relay-flow/server.log`, and remains stoppable with `relay-flow stop`. Plain `serve` remains foreground and blocking.
|
|
53
91
|
|
|
54
|
-
|
|
55
|
-
type: jira
|
|
56
|
-
config: # opaque to core; strictly validated by the adapter
|
|
57
|
-
query: project = ABCD # JQL fragment (no issuetype/assignee/ORDER BY)
|
|
58
|
-
issueTypes: [Task]
|
|
59
|
-
assigneeIsAgent: true # or omit → assignee comes from `relay-flow init`
|
|
92
|
+
`serve --recover` treats ALL SQLite execution state as gone, closes surviving run-owned terminals (preserving worktrees and code), resets Jira parent+mailbox state, and starts every labeled parent in a fresh deterministic run from `start` with fresh `nodeVisitID`s. Recovery never runs automatically; database loss is never inferred.
|
|
60
93
|
|
|
61
|
-
|
|
62
|
-
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Workflow YAML
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
name: basicFlow # lowerCamel; determines claim label wf:basicFlow
|
|
100
|
+
repos: [payments] # one or more registered repos, unique
|
|
101
|
+
cleanupRunnerOnEnd: false # optional; when true the runner tears down at end
|
|
63
102
|
|
|
64
|
-
|
|
103
|
+
taskConfig: # optional; adapter-owned; merged root → repo → workflow → node
|
|
104
|
+
transitions:
|
|
105
|
+
start: { parent: "In Progress" }
|
|
106
|
+
work: { mailbox: "In Progress" }
|
|
107
|
+
end: { parent: "Done" }
|
|
65
108
|
|
|
66
109
|
nodes:
|
|
110
|
+
start:
|
|
111
|
+
onSuccess: [{ target: coding }]
|
|
112
|
+
|
|
67
113
|
coding:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
114
|
+
type: agent # or hitl
|
|
115
|
+
agent: build # opencode agent
|
|
116
|
+
description: | # becomes the mailbox description and launch prompt
|
|
117
|
+
Implement the ticket.
|
|
118
|
+
onSuccess: [{ target: reviewing, when: "work complete" }]
|
|
119
|
+
onFailure: [{ target: coding, when: "retry" }]
|
|
120
|
+
nudgePrompt: "Check edge cases for {{ticket}} before reporting." # optional custom instructions
|
|
121
|
+
|
|
73
122
|
reviewing:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
123
|
+
type: hitl
|
|
124
|
+
agent: build
|
|
125
|
+
description: Human review.
|
|
126
|
+
onSuccess: [{ target: end }]
|
|
127
|
+
onFailure: [{ target: coding }]
|
|
128
|
+
|
|
129
|
+
end: {}
|
|
80
130
|
```
|
|
81
131
|
|
|
82
|
-
|
|
132
|
+
Rules enforced at submit:
|
|
83
133
|
|
|
84
|
-
|
|
134
|
+
- `start` and `end` are reserved lifecycle nodes. `start` has exactly one success target and no type/agent/description/routes on failure. `end` has no type/agent/description/routes.
|
|
135
|
+
- Every other node is `agent` or `hitl`, has an agent and a description, and declares at least one valid route for every permitted outcome.
|
|
136
|
+
- Routes are single-target; no route may target `start`.
|
|
137
|
+
- The graph must be fully reachable from `start`; unknown fields are rejected; `runnerPlugin`/`harnessPlugin`/`closeOn`/legacy `tasks`/`runner` keys are rejected.
|
|
138
|
+
- Only `agent` and `hitl` nodes receive mailbox subtasks; `start` and `end` never do.
|
|
139
|
+
- `cleanupRunnerOnEnd` is the only workflow cleanup knob and takes priority over terminal retention after `end`; the word `terminal` refers to runner terminals only.
|
|
140
|
+
|
|
141
|
+
### Task-config merge
|
|
142
|
+
|
|
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.
|
|
144
|
+
|
|
145
|
+
### Jira transition defaults
|
|
146
|
+
|
|
147
|
+
Omitted transitions default to:
|
|
148
|
+
|
|
149
|
+
- `start`: parent → `In Progress`
|
|
150
|
+
- work node: mailbox → `In Progress` (parent unchanged)
|
|
151
|
+
- `end`: parent → `Done`
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Structured node report
|
|
156
|
+
|
|
157
|
+
Every visit (agent or HITL) ends with the same contract:
|
|
85
158
|
|
|
86
|
-
```sh
|
|
87
|
-
relay-flow serve # central process (artifacts in ~/.relay-flow/)
|
|
88
|
-
relay-flow submit -f .workflow/workflow.yaml
|
|
89
|
-
relay-flow stop serve
|
|
90
159
|
```
|
|
160
|
+
STATUS: success | failure
|
|
161
|
+
NEXT STEP: <one configured route for that status>
|
|
162
|
+
|
|
163
|
+
SUMMARY
|
|
164
|
+
- Completed: ...
|
|
165
|
+
- Not completed: ... | None
|
|
166
|
+
- Issues discovered: ... | None
|
|
167
|
+
- Verification: ...
|
|
168
|
+
- Notes: ... | None
|
|
169
|
+
|
|
170
|
+
FEEDBACK
|
|
171
|
+
- Reason for next step: ...
|
|
172
|
+
- Required actions: ...
|
|
173
|
+
- Relevant context: ...
|
|
174
|
+
- Expected result: ...
|
|
175
|
+
```
|
|
176
|
+
|
|
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.
|
|
91
178
|
|
|
92
|
-
`relay-flow report`
|
|
179
|
+
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.
|
|
93
180
|
|
|
94
181
|
---
|
|
95
182
|
|
|
96
183
|
## Architecture
|
|
97
184
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
- **
|
|
101
|
-
- **
|
|
102
|
-
- **
|
|
103
|
-
- **
|
|
104
|
-
- The **tracker is the single source of truth**. The server holds no database; restart = resubmit, and claim labels (`wf:<name>`) survive to drive recovery.
|
|
105
|
-
|
|
106
|
-
### End-to-end sequence
|
|
107
|
-
|
|
108
|
-
```mermaid
|
|
109
|
-
sequenceDiagram
|
|
110
|
-
participant J as Tracker (Jira)
|
|
111
|
-
participant S as relay-flow serve
|
|
112
|
-
participant R as Runner (Orca)
|
|
113
|
-
participant O as OpenCode + plugin
|
|
114
|
-
|
|
115
|
-
loop every pollIntervalSeconds
|
|
116
|
-
S->>J: List() — one query (query + issuetype + component + assignee)
|
|
117
|
-
J-->>S: tickets (Node via when-map, ClaimedBy via wf:* labels)
|
|
118
|
-
end
|
|
119
|
-
S->>J: Claim(ticket) — add label wf:xyzTaskFlow
|
|
120
|
-
S->>R: Spawn(ticket, node, agent, env RELAY_*)
|
|
121
|
-
R->>R: ensure worktree → terminal key:agent:node → opencode --prompt
|
|
122
|
-
R->>O: agent session starts
|
|
123
|
-
O->>O: works… ends reply with STATUS/SUMMARY
|
|
124
|
-
O->>S: plugin: relay-flow report --workflow --ticket --node --outcome --summary
|
|
125
|
-
S->>J: Report → transition to target node's state + comment
|
|
126
|
-
S-->>O: {action: transitioned | commented | error}
|
|
127
|
-
Note over O: action=error → plugin retries 3× → nudges the session
|
|
128
|
-
```
|
|
185
|
+
- **Task system** owns parent tickets, mailbox subtasks, task state, labels, comments, and adapter config. The parent ticket is the unit of work.
|
|
186
|
+
- **Durable workflow engine** (go-workflows + SQLite) owns graph progression, waits, reports, retries, and recovery. No custom state machine.
|
|
187
|
+
- **Mailbox subtask** is one agent/HITL node's scratch space; its description defines the node's work and its comments hold the node's summary plus selected incoming feedback.
|
|
188
|
+
- **Harness** owns agent launch, session/report behavior, parsing, nudging, and resume semantics.
|
|
189
|
+
- **Runner** owns ticket worktrees/environments, terminals, liveness, and execution of harness commands.
|
|
190
|
+
- **Compensation/rollback never exists.** Recovery always rolls forward through idempotent activities.
|
|
129
191
|
|
|
130
|
-
###
|
|
131
|
-
|
|
132
|
-
```mermaid
|
|
133
|
-
flowchart TD
|
|
134
|
-
L[tasks.List] --> T{per ticket}
|
|
135
|
-
T -->|ClaimedBy = other workflow| SKIP1[skip — mutex]
|
|
136
|
-
T -->|Node unmapped| SKIP2[log + skip]
|
|
137
|
-
T -->|node in closeOn| CLOSE[runner.Close — tear down terminals]
|
|
138
|
-
T -->|node agentless| GATE[claim if unclaimed, then leave for the human]
|
|
139
|
-
T -->|ClaimedBy = me, unknown in memory| BOUNCE[go bounce]
|
|
140
|
-
T -->|unclaimed| DISP[go dispatch]
|
|
141
|
-
|
|
142
|
-
DISP --> C1[tasks.Claim] --> S1[runner.Spawn fresh session]
|
|
143
|
-
BOUNCE --> F{runner.Find by title}
|
|
144
|
-
F -->|session alive| N1[Nudge once per node visit]
|
|
145
|
-
F -->|gone| S2[Spawn fresh — claim already held]
|
|
146
|
-
```
|
|
192
|
+
### Identity
|
|
147
193
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
flowchart LR
|
|
154
|
-
subgraph CLI[relay-flow CLI]
|
|
155
|
-
M[cmd/relay-flow<br/>serve · submit · report · init]
|
|
156
|
-
end
|
|
157
|
-
subgraph SRV[server — one process, N workflows]
|
|
158
|
-
H[/submit · /report · /shutdown/]
|
|
159
|
-
D1[daemon: poll loop] --> T1[tasks iface]
|
|
160
|
-
D1 --> R1[runner iface]
|
|
161
|
-
end
|
|
162
|
-
subgraph ADAPTERS[adapters — registry pattern]
|
|
163
|
-
J[tasks/jira<br/>acli] -.-> T1
|
|
164
|
-
O[runner/orca<br/>worktrees + terminals] -.-> R1
|
|
165
|
-
end
|
|
166
|
-
M -->|unix socket ~/.relay-flow/server.sock| H
|
|
167
|
-
H --> D1
|
|
168
|
-
```
|
|
194
|
+
- `runID` is deterministic from `repo/workflow/ticket`.
|
|
195
|
+
- `nodeVisitID` is generated once per node entry as a durable replay-safe side effect; it changes on revisit and on fresh runs after `--recover`.
|
|
196
|
+
- Terminal titles are stable `<ticket>:<node>` — they never carry `nodeVisitID`, workflow, or agent.
|
|
197
|
+
- Runtime registration is exactly `{runId, node, sessionId}`; normal execution persists that session ID and uses it to resume the harness session.
|
|
198
|
+
- Reports are exactly `{runId, node, reportId, report}`; `reportId` is derived from harness session/message identity and `nodeVisitID` stays internal.
|
|
169
199
|
|
|
170
|
-
|
|
171
|
-
|---|---|---|
|
|
172
|
-
| opencode plugin | `plugin/report-status.ts` | Parses STATUS/SUMMARY deterministically, calls `relay-flow report` (thin socket client), retries/nudges |
|
|
173
|
-
| CLI | `cmd/relay-flow/` | `serve` hosts workflows; `submit` registers one; `report` is a one-shot client |
|
|
174
|
-
| daemon | `internal/daemon/` | Poll loop, 3-way switch, dispatch/bounce goroutines |
|
|
175
|
-
| server | `internal/server/` | Socket lifecycle, submit validation, report routing |
|
|
176
|
-
| config | `internal/config/` | Workflow YAML schema + graph validation |
|
|
177
|
-
| Jira adapter | `internal/tasks/jira/` | [readme](internal/tasks/jira/README.md) — query/claim/report over acli |
|
|
178
|
-
| Orca adapter | `internal/runner/orca/` | [readme](internal/runner/orca/README.md) — worktrees, terminals, prompts |
|
|
200
|
+
### Poll cycle
|
|
179
201
|
|
|
180
|
-
|
|
202
|
+
One Repo Poller per registered repo (not per workflow) fetches active parent tickets on the configured `pollIntervalSeconds` (default 15). Per ticket, the Ticket Router resolves at most one workflow: multiple `wf:*` claims → `InvalidClaimError`; exactly one claim resolves directly; zero filter matches → `ErrNoMatch`; one match → that workflow; multiple matches → `AmbiguousError` with no mutation. Successful resolution goes to the Run Manager; the run is claimed with `wf:<name>` before `EnsureRun` fires.
|
|
181
203
|
|
|
182
|
-
|
|
183
|
-
- **No fallback paths**: report goes through the server or not at all; server down = system down (the plugin's 3× retry + nudge covers transient gaps).
|
|
184
|
-
- **Labels are never removed**: `wf:<name>` is the crash-recovery anchor.
|
|
185
|
-
- **Terminals outlive their node visit** — a bounce reuses the session; only `closeOn` nodes close them.
|
|
186
|
-
- **Parallelism**: one long-lived poll goroutine per workflow; short-lived dispatch/bounce goroutines per ticket; tickets at the same node run in parallel terminals with isolated worktrees.
|
|
204
|
+
### Shutdown and recovery
|
|
187
205
|
|
|
188
|
-
|
|
206
|
+
- Graceful shutdown stops accepting requests and new polls immediately, cancels worker polling, waits up to 30s for running calls, then closes the socket and database. Durable unfinished work resumes on the next normal start.
|
|
207
|
+
- Completed/canceled runs are removed after `completedRunRetentionDays` (default 30). The retention sweep runs once at startup, never on a ticker.
|
|
189
208
|
|
|
190
|
-
|
|
191
|
-
New execution backend (tmux, …): implement `runner.Runner` + register — see [runner/orca README](internal/runner/orca/README.md#writing-a-new-runner-tmux-).
|
|
209
|
+
---
|
|
192
210
|
|
|
193
211
|
## Development
|
|
194
212
|
|
|
195
213
|
```sh
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
go install ./...
|
|
214
|
+
go test ./...
|
|
215
|
+
cd plugin && bun test
|
|
199
216
|
```
|