relay-flow 0.2.4-alpha → 0.2.6-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 +29 -18
- package/cmd/relay-flow/backend_selection_test.go +149 -0
- package/cmd/relay-flow/beads_composition_test.go +3 -3
- package/cmd/relay-flow/main.go +94 -13
- package/cmd/relay-flow/scenario_test.go +19 -2
- package/cmd/relay-flow/serve.go +98 -19
- package/cmd/relay-flow/serve_recovery_test.go +100 -0
- package/cmd/relay-flow/temporal_init.go +170 -0
- package/cmd/relay-flow/temporal_init_test.go +217 -0
- package/cmd/relay-flow/temporal_report_test.go +733 -0
- package/examples/beads-workflow.yaml +3 -0
- package/examples/config-reference.yaml +7 -3
- package/examples/minimal-beads-task-workflow.yaml +2 -1
- package/examples/workflow-reference.yaml +2 -1
- package/go.mod +37 -16
- package/go.sum +129 -61
- package/internal/config/machine.go +33 -1
- package/internal/config/machine_test.go +76 -0
- package/internal/execution/goworkflows/activities.go +19 -0
- package/internal/execution/goworkflows/engine.go +13 -38
- package/internal/execution/goworkflows/engine_test.go +1 -1
- package/internal/execution/goworkflows/node_runtime_test.go +113 -4
- package/internal/execution/goworkflows/projection.go +47 -464
- package/internal/execution/projection/projection.go +867 -0
- package/internal/execution/projection/projection_test.go +347 -0
- package/internal/execution/temporal/activities.go +586 -0
- package/internal/execution/temporal/engine.go +384 -0
- package/internal/execution/temporal/engine_test.go +277 -0
- package/internal/execution/temporal/interpreter.go +736 -0
- package/internal/execution/temporal/operations.go +455 -0
- package/internal/execution/temporal/operations_test.go +101 -0
- package/internal/execution/temporal/recovery.go +194 -0
- package/internal/execution/temporal/recovery_runtime.go +41 -0
- package/internal/execution/temporal/recovery_test.go +102 -0
- package/internal/execution/temporal/snapshot_restart_test.go +72 -0
- package/internal/execution/temporal/spike_test.go +934 -0
- package/internal/execution/temporal/visibility_lag_test.go +415 -0
- package/internal/harness/harness.go +5 -0
- package/internal/harness/opencode/opencode.go +14 -3
- package/internal/harness/opencode/opencode_test.go +1 -1
- package/internal/harness/opencode/repo_setup.go +1 -1
- package/internal/harness/opencode/task_env_test.go +57 -0
- package/internal/harness/pi/pi.go +58 -47
- package/internal/harness/pi/pi_test.go +26 -10
- package/internal/harness/pi/prompt_test.go +30 -1
- package/internal/harness/pi/task_env_test.go +51 -0
- package/internal/harness/pi/validation_test.go +27 -51
- package/internal/repo/service.go +18 -8
- package/internal/runner/herdr/herdr.go +14 -0
- package/internal/runner/herdr/herdr_test.go +20 -0
- package/internal/runner/orca/orca.go +33 -0
- package/internal/runner/orca/orca_test.go +33 -4
- package/internal/runner/runner.go +8 -0
- package/internal/task/beads/agent_env_test.go +52 -0
- package/internal/task/beads/beads.go +87 -7
- package/internal/task/beads/beads_test.go +78 -9
- package/internal/task/beads/repo_composition_test.go +47 -3
- package/internal/task/factory.go +31 -2
- package/internal/task/task.go +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -177,7 +177,13 @@ bd init \
|
|
|
177
177
|
# Example external workspace: /var/lib/beads/payments/.beads
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
For the relay-flow installation used by this repository, the configured Beads workspace is:
|
|
181
|
+
|
|
182
|
+
```text
|
|
183
|
+
/home/raj/.beads/relay-flow/.beads
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Register the code repository and its Beads workspace separately. `beadsDir` is required for every Beads repo and must name an existing directory. It selects the Beads workspace/database; it is not the code repository path or a workflow filter:
|
|
181
187
|
|
|
182
188
|
```sh
|
|
183
189
|
# Local/embedded workspace
|
|
@@ -193,7 +199,7 @@ relay-flow repo register \
|
|
|
193
199
|
--set beadsDir=/var/lib/beads/payments/.beads
|
|
194
200
|
```
|
|
195
201
|
|
|
196
|
-
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.
|
|
202
|
+
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. Multiple code repositories may share one Beads/Dolt workspace when their derived repository labels differ. Relay-flow derives one reserved label, `repo:<lowercase-registered-name>`, for each repository; names must use letters, numbers, `.`, `_`, or `-`, and be at most 250 characters so the derived label stays within Beads' 255-character limit. The label is not entered in workflow configuration. A parent must carry exactly one such repository label to be eligible for that repo's poller: missing or ambiguous `repo:` labels are ignored before workflow filters and routing. Workflow ownership labels remain independent `wf:<workflow>` labels. A collision between derived labels in the same workspace is rejected before the second repository is registered. 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.
|
|
197
203
|
|
|
198
204
|
Beads workflow filters are structured and evaluated in relay-flow. For example, `examples/beads-workflow.yaml` uses the Beads status and issue-type fields:
|
|
199
205
|
|
|
@@ -211,7 +217,7 @@ Filter values are exact and are not translated between providers.
|
|
|
211
217
|
|
|
212
218
|
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.
|
|
213
219
|
|
|
214
|
-
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
|
|
220
|
+
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; each registered code repository still supplies its `beadsDir`, and repositories that share that workspace are isolated by their derived `repo:` labels.
|
|
215
221
|
|
|
216
222
|
### Submit a workflow
|
|
217
223
|
|
|
@@ -354,37 +360,42 @@ lower-scope input.
|
|
|
354
360
|
|
|
355
361
|
Pi has one built-in coding agent. Relay-flow keeps Pi's configured model,
|
|
356
362
|
provider, tools, extensions, and settings, while allowing a workflow node to
|
|
357
|
-
select a
|
|
358
|
-
coding agent without an additional
|
|
359
|
-
`coder` or `reviewer`
|
|
360
|
-
`.pi/
|
|
361
|
-
|
|
363
|
+
select a project-owned prompt template. `agent: default` uses Pi's built-in
|
|
364
|
+
coding agent without an additional prompt template. A non-default value such as
|
|
365
|
+
`coder` or `reviewer` selects Pi's native project template
|
|
366
|
+
`.pi/prompts/<agent>.md` and submits the rendered task text as the template's
|
|
367
|
+
arguments with `/<agent> ...`.
|
|
362
368
|
|
|
363
|
-
Pi
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
369
|
+
Pi owns prompt-template discovery and expansion. Relay-flow does not maintain a
|
|
370
|
+
named-agent registry or inspect template files; it only validates the safe
|
|
371
|
+
template command name and passes Pi the corresponding
|
|
372
|
+
`--prompt-template .pi/prompts/<agent>.md` resource. The workflow agent value is
|
|
373
|
+
never treated as a model ID and relay-flow never passes an OpenCode-style
|
|
374
|
+
`--agent` option.
|
|
367
375
|
|
|
368
|
-
For example, a Pi workflow with
|
|
376
|
+
For example, a Pi workflow with project prompt templates uses:
|
|
369
377
|
|
|
370
378
|
```yaml
|
|
371
379
|
type: agent
|
|
372
380
|
agent: coder
|
|
373
381
|
```
|
|
374
382
|
|
|
375
|
-
with:
|
|
383
|
+
with project templates:
|
|
376
384
|
|
|
377
385
|
```text
|
|
378
|
-
.pi/
|
|
379
|
-
.pi/
|
|
386
|
+
.pi/prompts/coder.md
|
|
387
|
+
.pi/prompts/reviewer.md
|
|
380
388
|
```
|
|
381
389
|
|
|
382
|
-
Pi node launches use the installed Pi
|
|
390
|
+
Pi node launches use the installed Pi interactive command contract:
|
|
383
391
|
|
|
384
392
|
```text
|
|
385
|
-
pi --name <ticket>:<node> [--
|
|
393
|
+
pi --name <ticket>:<node> [--prompt-template .pi/prompts/<agent>.md] [--session-id <persisted-session-id>] <prompt>
|
|
386
394
|
```
|
|
387
395
|
|
|
396
|
+
For a named agent, `<prompt>` is `/agent <rendered relay-flow task or
|
|
397
|
+
feedback prompt>`; `default` keeps the rendered prompt unchanged.
|
|
398
|
+
|
|
388
399
|
The prompt is one positional argument. Pi 0.84.1 rejects a bare `--`, so the
|
|
389
400
|
launch command does not include one. A persisted session uses
|
|
390
401
|
`--session-id`; print mode, JSON/RPC mode, and extension-install flags are not
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"database/sql"
|
|
6
|
+
"fmt"
|
|
7
|
+
"os"
|
|
8
|
+
"path/filepath"
|
|
9
|
+
"testing"
|
|
10
|
+
"time"
|
|
11
|
+
|
|
12
|
+
"github.com/rajpopat27/relay-flow/internal/config"
|
|
13
|
+
"github.com/rajpopat27/relay-flow/internal/execution/projection"
|
|
14
|
+
"github.com/rajpopat27/relay-flow/internal/paths"
|
|
15
|
+
"github.com/rajpopat27/relay-flow/internal/server"
|
|
16
|
+
_ "modernc.org/sqlite"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
// These integration tests are deliberately live-gated because they exercise
|
|
20
|
+
// the selected durable backend and the local Temporal service. They use the
|
|
21
|
+
// same fake task/runner/harness factories as the composition scenario, but no
|
|
22
|
+
// task-system state or workflow is needed to prove worker selection.
|
|
23
|
+
func TestServeSelectsConfiguredTemporalExecutor(t *testing.T) {
|
|
24
|
+
if os.Getenv("RELAY_FLOW_TEMPORAL_LIVE") != "1" {
|
|
25
|
+
t.Skip("set RELAY_FLOW_TEMPORAL_LIVE=1 to run backend selection against Temporal")
|
|
26
|
+
}
|
|
27
|
+
assertServeUsesTemporal(t, false)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func TestServeRecoverSelectsConfiguredTemporalExecutor(t *testing.T) {
|
|
31
|
+
if os.Getenv("RELAY_FLOW_TEMPORAL_LIVE") != "1" {
|
|
32
|
+
t.Skip("set RELAY_FLOW_TEMPORAL_LIVE=1 to run backend recovery against Temporal")
|
|
33
|
+
}
|
|
34
|
+
assertServeUsesTemporal(t, true)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func assertServeUsesTemporal(t *testing.T, recover bool) {
|
|
38
|
+
t.Helper()
|
|
39
|
+
log := newScenarioLog()
|
|
40
|
+
setScenarioFactoryAdapters(newScenarioTaskSystem(log), newScenarioRunner(log), newScenarioHarness(log))
|
|
41
|
+
|
|
42
|
+
root := filepath.Join(t.TempDir(), ".relay-flow")
|
|
43
|
+
t.Setenv("RELAY_FLOW_HOME", root)
|
|
44
|
+
p := pathsForRoot(root)
|
|
45
|
+
if err := paths.Ensure(p); err != nil {
|
|
46
|
+
t.Fatal(err)
|
|
47
|
+
}
|
|
48
|
+
namespace := fmt.Sprintf("relay-flow-serve-%d", time.Now().UnixNano())
|
|
49
|
+
if err := ensureTemporalNamespace(context.Background(), "localhost:7233", namespace, 30); err != nil {
|
|
50
|
+
t.Fatal(err)
|
|
51
|
+
}
|
|
52
|
+
// Namespace registration is acknowledged before every frontend worker
|
|
53
|
+
// necessarily observes it.
|
|
54
|
+
time.Sleep(5 * time.Second)
|
|
55
|
+
if err := config.SaveMachine(p.Config, &config.Machine{
|
|
56
|
+
TaskPlugin: scenarioTaskPlugin,
|
|
57
|
+
RunnerPlugin: scenarioRunnerPlugin,
|
|
58
|
+
HarnessPlugin: scenarioHarnessPlugin,
|
|
59
|
+
ExecutorPlugin: "temporal",
|
|
60
|
+
TemporalAddress: "localhost:7233",
|
|
61
|
+
TemporalNamespace: namespace,
|
|
62
|
+
CompletedRunRetentionDays: 30,
|
|
63
|
+
}); err != nil {
|
|
64
|
+
t.Fatal(err)
|
|
65
|
+
}
|
|
66
|
+
if err := projection.InitDatabaseWithIdentity(p.Database, projection.ExecutorIdentity{
|
|
67
|
+
ExecutorPlugin: "temporal", TemporalAddress: "localhost:7233", TemporalNamespace: namespace,
|
|
68
|
+
}); err != nil {
|
|
69
|
+
t.Fatal(err)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ctx, cancel := context.WithCancel(context.Background())
|
|
73
|
+
defer cancel()
|
|
74
|
+
done := make(chan error, 1)
|
|
75
|
+
go func() { done <- serveRoot(ctx, p, recover) }()
|
|
76
|
+
client := server.NewClient(p.Socket)
|
|
77
|
+
waitForServerOrError(t, client, done)
|
|
78
|
+
|
|
79
|
+
assertNoEmbeddedExecutionTables(t, p.Database)
|
|
80
|
+
if err := client.Stop(context.Background()); err != nil {
|
|
81
|
+
t.Fatal(err)
|
|
82
|
+
}
|
|
83
|
+
select {
|
|
84
|
+
case err := <-done:
|
|
85
|
+
if err != nil {
|
|
86
|
+
t.Fatalf("serveRoot(%v): %v", recover, err)
|
|
87
|
+
}
|
|
88
|
+
case <-time.After(15 * time.Second):
|
|
89
|
+
t.Fatalf("serveRoot(%v) did not stop", recover)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
func waitForServerOrError(t *testing.T, client *server.Client, done <-chan error) {
|
|
94
|
+
t.Helper()
|
|
95
|
+
deadline := time.Now().Add(20 * time.Second)
|
|
96
|
+
for time.Now().Before(deadline) {
|
|
97
|
+
select {
|
|
98
|
+
case err := <-done:
|
|
99
|
+
t.Fatalf("serveRoot exited before socket became ready: %v", err)
|
|
100
|
+
default:
|
|
101
|
+
}
|
|
102
|
+
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
|
103
|
+
_, err := client.ListRepos(ctx)
|
|
104
|
+
cancel()
|
|
105
|
+
if err == nil {
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
time.Sleep(20 * time.Millisecond)
|
|
109
|
+
}
|
|
110
|
+
select {
|
|
111
|
+
case err := <-done:
|
|
112
|
+
t.Fatalf("serveRoot exited before socket became ready: %v", err)
|
|
113
|
+
default:
|
|
114
|
+
t.Fatal("server did not become ready")
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
func assertNoEmbeddedExecutionTables(t *testing.T, databasePath string) {
|
|
119
|
+
t.Helper()
|
|
120
|
+
db, err := sql.Open("sqlite", databasePath)
|
|
121
|
+
if err != nil {
|
|
122
|
+
t.Fatal(err)
|
|
123
|
+
}
|
|
124
|
+
defer db.Close()
|
|
125
|
+
var count int
|
|
126
|
+
if err := db.QueryRow(`SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name IN ('instances', 'history_events', 'activity_tasks')`).Scan(&count); err != nil {
|
|
127
|
+
t.Fatal(err)
|
|
128
|
+
}
|
|
129
|
+
if count != 0 {
|
|
130
|
+
t.Fatalf("Temporal projection contains embedded go-workflows tables: %d", count)
|
|
131
|
+
}
|
|
132
|
+
var plugin, address, namespace string
|
|
133
|
+
if err := db.QueryRow(`SELECT executor_plugin, temporal_address, temporal_namespace FROM relay_executor_identity WHERE singleton = 1`).Scan(&plugin, &address, &namespace); err != nil {
|
|
134
|
+
t.Fatal(err)
|
|
135
|
+
}
|
|
136
|
+
if plugin != "temporal" || address != "localhost:7233" || namespace == "" {
|
|
137
|
+
t.Fatalf("executor identity = %q/%q/%q", plugin, address, namespace)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
func pathsForRoot(root string) paths.Paths {
|
|
142
|
+
return paths.Paths{
|
|
143
|
+
Root: root, Config: filepath.Join(root, "config.yaml"),
|
|
144
|
+
Credentials: filepath.Join(root, "credentials.yaml"), Workflows: filepath.Join(root, "workflows"),
|
|
145
|
+
Database: filepath.Join(root, "state.db"), Socket: filepath.Join(root, "server.sock"),
|
|
146
|
+
Lock: filepath.Join(root, "server.lock"), ServerLog: filepath.Join(root, "server.log"),
|
|
147
|
+
PluginLog: filepath.Join(root, "plugin.log"),
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -361,9 +361,9 @@ issue_json() {
|
|
|
361
361
|
case "$issue" in
|
|
362
362
|
demo-parent)
|
|
363
363
|
if [ -f "$BD_STATE/claimed" ]; then
|
|
364
|
-
labels='["wf:beadsComposition"]'
|
|
364
|
+
labels='["repo:payments","wf:beadsComposition"]'
|
|
365
365
|
else
|
|
366
|
-
labels='[]'
|
|
366
|
+
labels='["repo:payments"]'
|
|
367
367
|
fi
|
|
368
368
|
printf '[{"id":"demo-parent","title":"Composition parent","status":"%s","issue_type":"epic","priority":1,"labels":%s}]\n' "$status" "$labels"
|
|
369
369
|
;;
|
|
@@ -385,7 +385,7 @@ if [ "$#" -eq 6 ] && [ "$1" = list ] && [ "$2" = --ready ] && [ "$3" = --no-pare
|
|
|
385
385
|
if [ -f "$BD_STATE/claimed" ]; then
|
|
386
386
|
printf '[]\n'
|
|
387
387
|
else
|
|
388
|
-
printf '[{"id":"demo-parent","title":"Composition parent","status":"open","issue_type":"epic","priority":1,"labels":[]}]\n'
|
|
388
|
+
printf '[{"id":"demo-parent","title":"Composition parent","status":"open","issue_type":"epic","priority":1,"labels":["repo:payments"]}]\n'
|
|
389
389
|
fi
|
|
390
390
|
exit 0
|
|
391
391
|
fi
|
package/cmd/relay-flow/main.go
CHANGED
|
@@ -24,7 +24,7 @@ import (
|
|
|
24
24
|
"github.com/charmbracelet/huh"
|
|
25
25
|
"github.com/mattn/go-isatty"
|
|
26
26
|
"github.com/rajpopat27/relay-flow/internal/config"
|
|
27
|
-
"github.com/rajpopat27/relay-flow/internal/execution/
|
|
27
|
+
"github.com/rajpopat27/relay-flow/internal/execution/projection"
|
|
28
28
|
"github.com/rajpopat27/relay-flow/internal/harness"
|
|
29
29
|
"github.com/rajpopat27/relay-flow/internal/logging"
|
|
30
30
|
"github.com/rajpopat27/relay-flow/internal/paths"
|
|
@@ -134,6 +134,8 @@ func usage(w io.Writer) {
|
|
|
134
134
|
|
|
135
135
|
Usage:
|
|
136
136
|
relay-flow init [--force] [--task-plugin <name> --runner-plugin <name> --harness-plugin <name>]
|
|
137
|
+
[--executor-plugin <goworkflows|temporal>]
|
|
138
|
+
[--temporal-address <host:port>] [--temporal-namespace <name>]
|
|
137
139
|
relay-flow task auth [task-plugin options]
|
|
138
140
|
relay-flow serve [--recover] [--debug] [--background]
|
|
139
141
|
relay-flow stop
|
|
@@ -170,6 +172,9 @@ func cmdInit(p paths.Paths, args []string, stdin io.Reader) int {
|
|
|
170
172
|
taskName := fs.String("task-plugin", "", "task plugin name (non-interactive)")
|
|
171
173
|
runnerName := fs.String("runner-plugin", "", "runner plugin name (non-interactive)")
|
|
172
174
|
harnessName := fs.String("harness-plugin", "", "harness plugin name (non-interactive)")
|
|
175
|
+
executorName := fs.String("executor-plugin", "", "durable executor name (goworkflows or temporal)")
|
|
176
|
+
temporalAddress := fs.String("temporal-address", "", "Temporal server address")
|
|
177
|
+
temporalNamespace := fs.String("temporal-namespace", "", "Temporal namespace/team name")
|
|
173
178
|
force := fs.Bool("force", false, "update plugin selections while preserving existing state")
|
|
174
179
|
if err := fs.Parse(args); err != nil {
|
|
175
180
|
return exitUsage
|
|
@@ -215,7 +220,7 @@ func cmdInit(p paths.Paths, args []string, stdin io.Reader) int {
|
|
|
215
220
|
}
|
|
216
221
|
defer unlock()
|
|
217
222
|
if databaseExists {
|
|
218
|
-
active, err :=
|
|
223
|
+
active, err := projection.HasNonterminalRuns(p.Database)
|
|
219
224
|
if err != nil {
|
|
220
225
|
fmt.Fprintln(os.Stderr, "init: "+err.Error())
|
|
221
226
|
return exitFail
|
|
@@ -227,9 +232,11 @@ func cmdInit(p paths.Paths, args []string, stdin io.Reader) int {
|
|
|
227
232
|
}
|
|
228
233
|
}
|
|
229
234
|
|
|
230
|
-
// Selection precedence: flags → TTY form → stdin lines. The
|
|
231
|
-
//
|
|
235
|
+
// Selection precedence: flags → TTY form → legacy stdin lines. The
|
|
236
|
+
// three-line stdin path remains embedded-mode input and never consumes
|
|
237
|
+
// Temporal answers.
|
|
232
238
|
var names []string
|
|
239
|
+
executor := strings.TrimSpace(*executorName)
|
|
233
240
|
switch {
|
|
234
241
|
case flagged:
|
|
235
242
|
names = []string{*taskName, *runnerName, *harnessName}
|
|
@@ -240,6 +247,10 @@ func cmdInit(p paths.Paths, args []string, stdin io.Reader) int {
|
|
|
240
247
|
fmt.Fprintln(os.Stderr, "init: "+err.Error())
|
|
241
248
|
return exitFail
|
|
242
249
|
}
|
|
250
|
+
if len(names) == 4 {
|
|
251
|
+
executor = names[3]
|
|
252
|
+
names = names[:3]
|
|
253
|
+
}
|
|
243
254
|
default:
|
|
244
255
|
names = readInitLines(stdin)
|
|
245
256
|
if names == nil {
|
|
@@ -247,6 +258,22 @@ func cmdInit(p paths.Paths, args []string, stdin io.Reader) int {
|
|
|
247
258
|
return exitFail
|
|
248
259
|
}
|
|
249
260
|
}
|
|
261
|
+
if executor == executorTemporal && isTTY(stdin) {
|
|
262
|
+
address, namespace, err := promptTemporalSettings(*temporalAddress, *temporalNamespace)
|
|
263
|
+
if err != nil {
|
|
264
|
+
fmt.Fprintln(os.Stderr, "init: "+err.Error())
|
|
265
|
+
return exitFail
|
|
266
|
+
}
|
|
267
|
+
*temporalAddress = address
|
|
268
|
+
*temporalNamespace = namespace
|
|
269
|
+
}
|
|
270
|
+
if executor == "" {
|
|
271
|
+
executor = executorGoworkflows
|
|
272
|
+
}
|
|
273
|
+
if executor != executorGoworkflows && executor != executorTemporal {
|
|
274
|
+
fmt.Fprintln(os.Stderr, "init: unknown executor plugin "+executor)
|
|
275
|
+
return exitUsage
|
|
276
|
+
}
|
|
250
277
|
// Validate against the registered factories; unknown names list the
|
|
251
278
|
// registered set per design (no silent acceptance).
|
|
252
279
|
if err := task.ValidateName(names[0]); err != nil {
|
|
@@ -262,13 +289,42 @@ func cmdInit(p paths.Paths, args []string, stdin io.Reader) int {
|
|
|
262
289
|
return exitFail
|
|
263
290
|
}
|
|
264
291
|
|
|
265
|
-
cfg := &config.Machine{
|
|
292
|
+
cfg := &config.Machine{
|
|
293
|
+
PollIntervalSeconds: 15, CompletedRunRetentionDays: 30,
|
|
294
|
+
KeepTerminalsAlive: true, KeepSessionsAlive: true,
|
|
295
|
+
ExecutorPlugin: executor,
|
|
296
|
+
}
|
|
266
297
|
if *force && configExists {
|
|
267
298
|
cfg, err = config.LoadMachine(p.Config)
|
|
268
299
|
if err != nil {
|
|
269
300
|
fmt.Fprintln(os.Stderr, err)
|
|
270
301
|
return exitFail
|
|
271
302
|
}
|
|
303
|
+
if strings.TrimSpace(*executorName) == "" {
|
|
304
|
+
executor = cfg.ExecutorPlugin
|
|
305
|
+
}
|
|
306
|
+
cfg.ExecutorPlugin = executor
|
|
307
|
+
}
|
|
308
|
+
if executor == executorTemporal {
|
|
309
|
+
if strings.TrimSpace(*temporalAddress) != "" {
|
|
310
|
+
cfg.TemporalAddress = strings.TrimSpace(*temporalAddress)
|
|
311
|
+
} else if cfg.TemporalAddress == "" {
|
|
312
|
+
cfg.TemporalAddress = defaultTemporalAddr
|
|
313
|
+
}
|
|
314
|
+
if strings.TrimSpace(*temporalNamespace) != "" {
|
|
315
|
+
cfg.TemporalNamespace = strings.TrimSpace(*temporalNamespace)
|
|
316
|
+
}
|
|
317
|
+
if cfg.TemporalNamespace == "" {
|
|
318
|
+
fmt.Fprintln(os.Stderr, "init: --temporal-namespace is required for executor-plugin temporal")
|
|
319
|
+
return exitUsage
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
if strings.TrimSpace(*temporalAddress) != "" || strings.TrimSpace(*temporalNamespace) != "" {
|
|
323
|
+
fmt.Fprintln(os.Stderr, "init: Temporal address/namespace require executor-plugin temporal")
|
|
324
|
+
return exitUsage
|
|
325
|
+
}
|
|
326
|
+
cfg.TemporalAddress = ""
|
|
327
|
+
cfg.TemporalNamespace = ""
|
|
272
328
|
}
|
|
273
329
|
cfg.TaskPlugin = names[0]
|
|
274
330
|
cfg.RunnerPlugin = names[1]
|
|
@@ -297,17 +353,37 @@ func cmdInit(p paths.Paths, args []string, stdin io.Reader) int {
|
|
|
297
353
|
} else {
|
|
298
354
|
cfg.HarnessConfig = config.Merge(harnessDefaults, cfg.HarnessConfig)
|
|
299
355
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
356
|
+
identity := projection.ExecutorIdentity{
|
|
357
|
+
ExecutorPlugin: executor,
|
|
358
|
+
TemporalAddress: cfg.TemporalAddress,
|
|
359
|
+
TemporalNamespace: cfg.TemporalNamespace,
|
|
360
|
+
}
|
|
361
|
+
// Force mode verifies the immutable durable identity before contacting
|
|
362
|
+
// Temporal or replacing configuration. Legacy marker-less homes may only
|
|
363
|
+
// be adopted by goworkflows.
|
|
364
|
+
if databaseExists {
|
|
365
|
+
if err := verifyExecutorIdentity(p.Database, identity); err != nil {
|
|
366
|
+
fmt.Fprintln(os.Stderr, "init: "+err.Error())
|
|
367
|
+
return exitFail
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if executor == executorTemporal {
|
|
371
|
+
if err := ensureTemporalNamespace(context.Background(), cfg.TemporalAddress, cfg.TemporalNamespace, cfg.CompletedRunRetentionDays); err != nil {
|
|
372
|
+
fmt.Fprintln(os.Stderr, "init: "+err.Error())
|
|
373
|
+
return exitFail
|
|
374
|
+
}
|
|
303
375
|
}
|
|
304
376
|
if !databaseExists {
|
|
305
|
-
if err :=
|
|
306
|
-
fmt.Fprintln(os.Stderr, err)
|
|
377
|
+
if err := projection.InitDatabaseWithIdentity(p.Database, identity); err != nil {
|
|
378
|
+
fmt.Fprintln(os.Stderr, "init: "+err.Error())
|
|
307
379
|
return exitFail
|
|
308
380
|
}
|
|
309
381
|
}
|
|
310
|
-
|
|
382
|
+
if err := config.SaveMachine(p.Config, cfg); err != nil {
|
|
383
|
+
fmt.Fprintln(os.Stderr, err)
|
|
384
|
+
return exitFail
|
|
385
|
+
}
|
|
386
|
+
fmt.Printf("Task system: %s\nRunner: %s\nHarness: %s\nExecutor: %s\nRelay-flow initialized\n", names[0], names[1], names[2], executor)
|
|
311
387
|
return exitOK
|
|
312
388
|
}
|
|
313
389
|
|
|
@@ -345,8 +421,8 @@ func isTTY(stdin io.Reader) bool {
|
|
|
345
421
|
|
|
346
422
|
// pickPluginsInteractive runs one searchable select per plugin type.
|
|
347
423
|
func pickPluginsInteractive() ([]string, error) {
|
|
348
|
-
names := make([]string,
|
|
349
|
-
groups := make([]*huh.Group, 0,
|
|
424
|
+
names := make([]string, 4)
|
|
425
|
+
groups := make([]*huh.Group, 0, 4)
|
|
350
426
|
for _, selection := range []struct {
|
|
351
427
|
title string
|
|
352
428
|
options []string
|
|
@@ -364,6 +440,11 @@ func pickPluginsInteractive() ([]string, error) {
|
|
|
364
440
|
groups = append(groups, huh.NewGroup(field))
|
|
365
441
|
}
|
|
366
442
|
}
|
|
443
|
+
executorField, err := executorSelectField(&names[3])
|
|
444
|
+
if err != nil {
|
|
445
|
+
return nil, err
|
|
446
|
+
}
|
|
447
|
+
groups = append(groups, huh.NewGroup(executorField))
|
|
367
448
|
if len(groups) == 0 {
|
|
368
449
|
return names, nil
|
|
369
450
|
}
|
|
@@ -801,6 +801,8 @@ type scenarioTaskSystem struct {
|
|
|
801
801
|
creates map[string]int
|
|
802
802
|
completions map[string]int
|
|
803
803
|
completeFailures int
|
|
804
|
+
recoveryTickets []task.Ticket
|
|
805
|
+
recoveryPolls int
|
|
804
806
|
}
|
|
805
807
|
|
|
806
808
|
var _ task.System = (*scenarioTaskSystem)(nil)
|
|
@@ -816,11 +818,19 @@ func newScenarioTaskSystem(log *scenarioLog) *scenarioTaskSystem {
|
|
|
816
818
|
func (s *scenarioTaskSystem) Poll(context.Context) ([]task.Ticket, error) {
|
|
817
819
|
s.log.add("poll")
|
|
818
820
|
s.mu.Lock()
|
|
819
|
-
defer s.mu.Unlock()
|
|
820
821
|
if s.claimed {
|
|
822
|
+
if s.recoveryPolls > 0 {
|
|
823
|
+
s.recoveryPolls--
|
|
824
|
+
tickets := append([]task.Ticket(nil), s.recoveryTickets...)
|
|
825
|
+
s.mu.Unlock()
|
|
826
|
+
return tickets, nil
|
|
827
|
+
}
|
|
828
|
+
s.mu.Unlock()
|
|
821
829
|
return nil, nil
|
|
822
830
|
}
|
|
823
|
-
|
|
831
|
+
tickets := []task.Ticket{{ID: "ticket-1", Key: scenarioTicket, Title: "Scenario ticket"}}
|
|
832
|
+
s.mu.Unlock()
|
|
833
|
+
return tickets, nil
|
|
824
834
|
}
|
|
825
835
|
|
|
826
836
|
func (s *scenarioTaskSystem) CompileFilter(config.RawValues) (func(task.Ticket) bool, error) {
|
|
@@ -958,6 +968,13 @@ func (s *scenarioTaskSystem) setCompleteFailures(n int) {
|
|
|
958
968
|
s.mu.Unlock()
|
|
959
969
|
}
|
|
960
970
|
|
|
971
|
+
func (s *scenarioTaskSystem) setRecoveryTickets(tickets []task.Ticket, polls int) {
|
|
972
|
+
s.mu.Lock()
|
|
973
|
+
s.recoveryTickets = append([]task.Ticket(nil), tickets...)
|
|
974
|
+
s.recoveryPolls = polls
|
|
975
|
+
s.mu.Unlock()
|
|
976
|
+
}
|
|
977
|
+
|
|
961
978
|
func (s *scenarioTaskSystem) mailboxCreateCount(node string) int {
|
|
962
979
|
s.mu.Lock()
|
|
963
980
|
defer s.mu.Unlock()
|