Commit Graph
557 Commits
Author SHA1 Message Date
Yota Hamada c225d17b26 Default to an empty default mock in dagu test
A test file without default_mock now behaves as if it had
default_mock: {}. An action with side effects that a case neither
mocks nor lists under real takes the default mock instead of making
the case invalid, so a test file no longer needs a {} line per step,
and adding a step to a DAG no longer invalidates its tests.

The report already lists the steps that took the default mock, so an
unscripted step stays visible, and only a step under real runs an
action with side effects. Sources the default mock cannot handle,
such as a precondition that runs a command, still make the case
invalid. The fix and dagu test --init now hold only what those
sources need.
2026-11-30 13:01:20 +09:00
Yota Hamada 50bd9e72c6 Hide connections behind experimental_connections (#4354) 2026-11-29 13:35:14 +09:00
Yota Hamada 39327e32eb Stop a worker the coordinator removed (#4332)
A worker that a coordinator refuses as removed stops at once: it ends
the context of every run it holds, accepts no new run, and exits with
code 1 and a message saying it was removed. It records the removal, so
a later start with the same certificate exits right away, and in
Kubernetes it writes the reason to the termination log. Given a
different invite after a removal, it enrolls again with a new key.

At start, a worker with a kept certificate first confirms that a
coordinator of the same Dagu accepts it. dagu worker --check reports
the invite pin, the kept certificate, and each coordinator's answer,
and tells the operator what a start would do after a refusal.

Part of #4292 (T15 part 2).
2026-11-29 06:08:06 +09:00
Yota Hamada c1922d7e68 Add the worker invite and removal API (#4327)
An admin can create, list and delete worker invites, ask whether the
coordinators can accept workers from other hosts, and remove a worker
that joined with an invite through the REST API:

- GET and POST /api/v1/workers/invites
- DELETE /api/v1/workers/invites/{inviteId}
- GET /api/v1/workers/join-readiness
- POST /api/v1/workers/removals

Every route needs the admin role, checked before input validation, and
none of them is forwarded to a remote node. An invite address must be
host:port with a hostname or an IP literal as host; dagu worker invite
checks the same rule. A refusal carries a stable reason in
details.reason so a client can explain it without matching messages.
/workers reports each worker's connection, certificate and invite, and
leaves out workers whose certificate is revoked.

Part of #4292 (T16).
2026-11-29 05:20:43 +09:00
Yota Hamada 128e504eb7 Add dagu worker invite (#4323)
dagu worker invite creates an invite on the coordinators and prints
the command that starts a worker with it. Before creating anything it
asks each coordinator whether it can accept workers from other hosts,
and when one cannot it says which setting to change, naming the one
that wins: a flag, a variable, or a config file.

--address must be a host:port that a worker on another host can
reach. When the command cannot print its output, it tries to delete
the invite it created and reports either outcome.

Part of #4292 (T17).
2026-11-29 02:18:55 +09:00
Yota Hamada a2e9e6edd5 Join as a worker with an invite (#4324)
A worker started with --worker.invite (or DAGU_WORKER_INVITE) enrolls
with the coordinator named in the invite, gets a worker certificate,
and calls every coordinator with it. The invite pins the coordinator's
CA, so the worker trusts only the Dagu that issued the invite. A
restart reuses the certificate it enrolled for, and dagu worker --check
reports the invite pin, the kept certificate, and each coordinator's
answer.

The worker serves /health from start and /ready once its first
heartbeat reaches a coordinator, so a probe can tell a live worker
from one that can take runs. The chart keeps its probes on /health
until its default image serves /ready.

Part of #4292 (T15 part 1).
2026-11-29 01:39:22 +09:00
Yota Hamada 8fa42571c5 Revoke removed worker certificates (#4307)
Removing a worker that joined with an invite marks its certificate as
no longer accepted, so every coordinator refuses its calls once it
rereads the revoked set. Removal of a disconnected worker revokes at
once; a connected one is refused until later parts of RFC 029 land.

Decisions two coordinators can race on, such as an enrollment that
overlaps a removal of the same worker ID, go through a compare-and-
swap on one shared record. Each certificate keeps its recent worker
IDs, so a removal still finds a worker that changed its ID. Expired
certificate records are pruned.

Part of #4292 (T13 part A).
2026-11-29 01:24:43 +09:00
Ryo KusnadiandYota Hamada 6c3018fb36 Add a JUnit XML report to dagu test (#4336)
Co-authored-by: Yota Hamada <yohamta@gmail.com>
2026-11-29 01:07:02 +09:00
Yota Hamada b0d0427dd5 Add dagu connection list, show, tools, and apps (C15 part 2) (#4338) 2026-11-29 00:25:02 +09:00
Yota Hamada e2ef0374c0 Add dagu connection add and reconnect (C15 part 1) (#4318) 2026-11-28 21:34:00 +09:00
Yota Hamada 99541bb697 Report a broken connection once (C17 part 1) (#4291) 2026-11-28 21:11:36 +09:00
Yota Hamada ac308d9bbd Accept --peer.ca-cert-file on dagu worker
Spec 108 gives peer.ca_cert_file the flag --peer.ca-cert-file, but
dagu worker refused it as unknown. The worker now takes it beside its
other --peer.* flags, and Spec 108 names the commands that take the
peer flags.

The help of --peer.insecure still described the behavior from before
clients used built-in TLS, and read as a serving setting on a
coordinator. It now describes calls to a coordinator only, in the help,
the config schema, and the README.

A client refused by coordinator.require_tls named steps that did not
apply to most clients. The client log line and the error of the
refused call now name the change for the h2c reason of the connection
that carried the call, and carry the handshake error after a fallback.
The coordinator's refusal message is unchanged.

Part of #4292.
2026-11-28 18:02:17 +09:00
Yota Hamada e5e33b9379 Add dagu worker --check
dagu worker --check dials each coordinator the worker would use and
reports, in plain words, the transport its client picks, whether the
address is reachable, the TLS handshake with the names the certificate
covers and the CA it chains to, the credential the worker sends, and
what the coordinator answered. It exits with code 1 when a coordinator
does not pass, so a worker that cannot join is diagnosed without
reading gRPC errors.

The check picks the transport through the decision the client's
connections make, including built-in TLS, h2c reasons, open h2c
windows, and the fallback after a handshake that fails on the network
path. It registers no worker, takes no task, and opens or ends no h2c
window. Without worker.coordinators it checks the coordinators in the
service registry and still fails, since the worker does not start
without them. dagu worker without --check behaves as before.

Part of #4292 (T4).
2026-11-28 15:52:38 +09:00
Yota Hamada d622d01bfc Show how each process connects
A client on h2c now sends why in the dagu-peer-h2c-reason call
metadata: peer.insecure, no TLS source, or tls failed on the network
path. The reason comes from the same transport choice that picked h2c.

The coordinator records each worker's connection (certificate, tls, or
plaintext with the reason) from the call that carries its heartbeat,
and keeps it in the shared heartbeat record. A plaintext call with no
known reason reads as older version. GET /api/v1/workers returns it,
and the System status workers list shows it as a neutral line with the
one change that moves the worker to TLS.

Each coordinator also keeps, in memory, the hosts other than workers
that called it over h2c in the last 10 minutes, at most 64 and with no
timer. GET /api/v1/services/coordinator returns them and System status
lists them under each coordinator, so admins can see which processes
still use plaintext and why.

Part of #4292 (T9).
2026-11-28 12:58:38 +09:00
Yota Hamada aadc25f64d Bound the wait of an interrupted dispatch (#4272)
A Ctrl+C during a coordinator dispatch hid the interrupt from the
client's retry loop, so the CLI could wait silently through every
retry, coordinator member, and request timeout. The first Ctrl+C now
stops further attempts and fallbacks, lets the call in flight run for
at most one request timeout, and prints a notice. A second Ctrl+C exits
at once, and an interrupt before the dispatch sends nothing.
2026-11-28 12:05:41 +09:00
Yota Hamada d8b6c49d4b Make clients use built-in TLS
Clients that share a coordinator's data directory now pick built-in TLS per connection from the published CA certificate and the registry flag, and fall back to h2c on a path that cannot carry TLS. Coordinators publish their CA certificate and report built-in TLS, and coordinator.require_tls refuses h2c calls. peer.insecure keeps its explicit meanings.

Part of #4292 (T8).
2026-11-28 10:43:35 +09:00
Yota Hamada e95cd7d310 Enroll workers with invites (#4304)
The coordinator creates, lists, and deletes worker invites, and Enroll
issues a worker certificate signed by the peer CA for the key of a CSR
that an invite admits. A single-use invite enrolls one worker. The
invite calls and join readiness take the peer token and refuse worker
certificates; other calls accept a worker certificate as the peer
token, also under coordinator.require_token.

Part of #4292 (T12).
2026-11-28 09:52:10 +09:00
Yota Hamada 6a5258c2b9 Serve built-in TLS and h2c on one coordinator port (#4301)
A coordinator with a peer CA now issues itself an in-memory server
certificate and serves built-in TLS beside h2c on coordinator.port. The
first byte of each connection picks the transport, so every existing
client keeps working over h2c on the same port until clients learn
built-in TLS. Own certificates still serve TLS only, and a coordinator
without a peer CA still serves h2c only. Join readiness now reports
builtinTLS, and the coordinator logs what it serves at start.

coordinator.require_tls lands with T8, once clients can use built-in
TLS.
2026-11-28 05:07:56 +09:00
Yota Hamada 8a237f6391 Generate the peer CA and add dagu peer init (#4296)
Built-in peer TLS needs a CA that signs coordinator and worker
certificates. A coordinator without its own certificates now generates
an ECDSA P-256 CA with no expiry date in its data directory on first
start, and coordinators that share the data directory end with one CA.
peer.ca_cert_file and peer.ca_key_file supply a CA instead. A
coordinator that cannot prepare the generated CA still starts, with a
warning, and join readiness reports caUnavailable. Nothing uses the CA
for TLS yet.

A supplied CA that is not a CA, cannot sign certificates, or does not
match its key stops the coordinator. The CA keys conflict with own
certificates and with peer.skip_tls_verify, and on a coordinator each
CA key needs the other. Each conflict involves a new key, so no
working setup fails.

dagu peer init --out <dir> writes ca.crt, ca.key, and token for setups
that must exist before the coordinator starts, and refuses to overwrite
any of them.

Separately, a download proxied to a remote node now streams its request
body in full duplex. A remote node that started a skill ZIP before
reading the body could get a truncated body, or the proxy and client
waited on each other.

Part of #4292 (T6).
2026-11-28 04:05:57 +09:00
Yota Hamada 22cba31fe8 Report join readiness from the coordinator (#4299)
A new coordinator RPC, GetJoinReadiness, reports from the coordinator's
own host whether a worker on another host can join: the listen host and
port, whether it listens on loopback only, where coordinator.host came
from, the config file, the environment it runs in, the addresses a
worker may dial, and why built-in TLS is off. The Add worker dialog and
dagu worker invite need this, and the API server may run on another
host. The call always takes the peer token. A new client method asks
every coordinator at once, for the REST endpoint and the CLI to call.

Part of #4292 (T14).
2026-11-28 03:42:47 +09:00
Yota Hamada 884922ebca Log the chosen peer transport and ignored TLS files (#4298)
Peer processes now log the transport they use to call the coordinator
and what selected it, and warn for each TLS setting that transport
ignores, as Spec 108 states. peer.insecure has no default; unset keeps
h2c, so no process changes transport, and dagu config --values still
shows true. Config.Sources records where each peer key and
coordinator.host came from, for the built-in TLS and join readiness
work that follows.

Part of #4292 (T2).
2026-11-28 02:51:37 +09:00
Yota Hamada 37069bd3d4 Check own peer certificates at start (#4297)
The coordinator now names both files when its own key does not match
its certificate. It warns when the certificate does not name the
advertised address and when it has expired or expires within 14 days.
start-all warns under mTLS when its certificate lacks client
authentication, since its own dial to the coordinator would fail.
No setup that starts today stops starting. Spec 108 marks these checks
implemented, and conformance tests cover them.

Part of #4292 (T3).
2026-11-28 02:20:04 +09:00
Yota Hamada fbe52295e4 Back off coordinator status polls while idle (#4282) 2026-11-27 22:17:25 +09:00
Yota Hamada 69c165a746 Target step retries at the step's session owner (#4274) 2026-11-27 22:11:18 +09:00
Yota Hamada f8e4ce8e7e Use connections in mcp.call (C14) (#4271) 2026-11-27 19:41:19 +09:00
Yota Hamada ca06d214f8 Compress reports with gzip (#4261)
Send server reports and job reports gzip-compressed, as audit uploads
already are, which cuts a report on the wire by over 90%. Move the
server heartbeat secret from the report body to the Authorization
header so it stays outside the compressed data. Requires Dagu Console
v0.22.415 or later.
2026-11-27 18:21:08 +09:00
Yota Hamada bea2352ad3 Route CLI runs per API and scheduler rules (#4266)
Apply the same placement rules to top-level CLI runs so worker
selectors and distributed mode reach the coordinator. Preserve local
placement for runs already placed by Dagu and check coordinator
reachability before stopping a run for restart.
2026-11-27 18:02:57 +09:00
Yota Hamada 3086b46226 Resolve connection tokens for workers through the coordinator (C10) (#4265) 2026-11-27 17:20:43 +09:00
Yota Hamada 05541e55ac Start node-bound DAGs on their worker (#4252)
Allow node: required workflows to start directly on a selected worker
through CLI, API, and queued execution paths.

Keep retries and resumes bound to that worker, fail unreachable targets,
and preserve node limits in worker-bound child runs.
2026-11-27 15:56:07 +09:00
Yota Hamada b3b4b79e70 Check declared connections at run admission (C8) (#4248) 2026-11-27 15:19:12 +09:00
Yota Hamada 59ba3a5709 Match short plain host values only as a whole (#4259)
#4244 matched a plain host value shorter than four characters as a
substring, so with HOST_REGION=us --update kept any value that
contains us, the report masked --zone us-east-1 as
--zone *******-east-1, and the kept line named every call variable
that contains us, PATH included. Spec 101 says a value that short
counts only where a value equals it.

The short-value rule now covers plain host values too, in the guard,
in report masking, and in the variable list. A variable that Dagu
forwards by default, such as PATH, is named under "set ... under env"
only when its own value is the host value.

It also gives each cloudreport test reporter its own HTTP transport.
The shared default pool could keep a connection to a fake console
that an earlier test closed, and a later fake console on the same
port made a report fail on it.
2026-11-27 15:01:03 +09:00
lsmlhi_25 9c10e671ea Run a test file once across case-only aliases (#4246)
On a case-insensitive filesystem, dagu test ran a test file twice when
a directory selected it and another argument named it with different
letter case, inflating the suite totals. Paths that differ only in case
now count as one selection when they resolve to the same file.
2026-11-27 13:57:49 +09:00
Yota Hamada 0451e6e611 Keep host values out of dagu test --update (#4244)
dagu test --update wrote values that a step got from the host
environment into the test file, such as a DAG env entry
TOKEN: ${HOST_TOKEN} under called_with.env, and a failing called_with
line printed them into CI logs. Committed test files must hold no
credentials.

Each case now tracks the host variables that its DAG load and run read,
plus the ones env_passthrough forwards, except Dagu's fixed allowlist.
--update keeps an output, run text, with input, variable, or
notification list as written when the run's value holds one of their
values, and keeps a called_with variable taken straight from the host.
Strings and numbers inside a JSON host value count too. A part shorter
than four characters counts only as a whole value, and an object is
guarded key by key. Each kept assertion gets a report line naming the
env entries to set in the case, and update_kept in JSON. The text and
JSON reports mask the same host values in failed values.

Spec 101 gains a Host Values section and fixes three sentences:
called_with.env holds only forwarded host variables, run leaves $NAME
for the shell, and only secrets are host independent.

Closes #4237
2026-11-27 12:59:25 +09:00
Yota HamadaandSCcagg5 158b6d910e Guard egress destinations with a credential (#4213)
Co-authored-by: SCcagg5 <sccagg5@gmail.com>
2026-11-27 12:48:21 +09:00
Yota Hamada 78f65e11c1 Migrate state on the first v3.0 start (P20 part 2) (#4236)
With projects on, the default project kept its state in the v2
directories, since part 1 (#4177) planned no moves. The first start
with projects on now cancels live runs, waits for them to exit, and
moves the default project's state into <data_dir>/projects/default/,
where its stores then open. Server-wide state stays where it is, and a
linked v2 directory moves as a link so its state stays on its disk.

The API, scheduler, and coordinator write new default-project runs'
logs and artifacts to the project's directories. The embedded engine
refuses projects, and a process with projects off warns on a migrated
data directory. With projects off, nothing changes.
2026-11-27 12:21:12 +09:00
Yota Hamada 095758dc5c Run bound children on worker nodes (N27 part 2) (#4210) 2026-11-27 12:03:34 +09:00
Yota Hamada a959551648 Serve webhooks per project (P17) (#4233)
With projects on, every webhook lived in one server-wide store and
every webhook URL reached the default project, so a project's DAG had
no webhook of its own and a library DAG still answered its v2 URL.

Each project now keeps its webhooks in its own settings, and
/webhooks/{project}/{name} authenticates against that project's
webhook and runs its DAG. Neither URL reaches a library DAG. A project
other than the default one refuses the run until the scheduler reads
its queues. With projects off, nothing changes.
2026-11-27 11:43:31 +09:00
Yota Hamada a4c2a3c613 Resolve routes, policies, and base config per project (P13 part 2) (#4232)
With projects on, a DAG's workspace label still added the workspace's
route set, policy set, and base config, a project other than the
default one had no base config, and any developer could change
notification channels and incident providers and read their previews.

A run now reads its routes, policies, and base config in its project
alone: base.yaml in a project's DAG directory, paths.base_config for
the default project, and no workspace layer. Channels, providers, and
SMTP settings change only through admins, and other users see only
their names and types. With projects off, nothing changes.
2026-11-27 11:14:55 +09:00
Yota Hamada c1f7063b1d Keep library DAG runs apart in each project (P9 part 2) (#4227)
With projects on, a library DAG that ran in a project kept its runs
and DAG state under its name in the project's stores, so a project DAG
of the same name listed its runs and read its scope dag state. Each
project now opens a library store set of its own, in library/ of its
state directory or .projects/<name>.library/ under a path set apart.

A command given a library DAG file reads and records its runs there.
A dag.run child stays under its caller's run and keeps the state that
a library DAG's name namespaces in the library. Queueing a library DAG
and sending its runs to workers are refused, since no scheduler reads
library queues and a dispatch task does not carry the library. With
projects off, nothing changes.
2026-11-27 10:45:42 +09:00
Yota Hamada dc9f9f95fd Resolve the project in the CLI (P8) (#4209)
With projects on, the CLI acted only on the default project, and
same-named DAGs in the default and a migrated project shared one
control socket. Each command now addresses one project, from
--project, DAGU_PROJECT, the current directory, or the default, and
opens its stores, DAG directory, base config, logs, and artifacts. Its
runs, child processes, steps, and sockets are bound to that project,
and a DAG file of another project is refused.

Hidden dagu project create and list commands manage projects. Runs of
a project other than the default one are refused on workers and
queues, which serve only the default project. With projects off,
nothing changes.
2026-11-27 00:11:24 +09:00
Yota Hamada ff26c85cba Run a DAG's test files from dagu test (#4186) 2026-11-26 23:49:44 +09:00
Yota Hamada 5f5fe1d048 Wait on events in TestStopHandlers (#4226) 2026-11-26 23:48:48 +09:00
Yota Hamada 42a2a865ec Open the server and scheduler stores from the bundle (P5 part 2) (#4207)
The server and the scheduler wired their stores by hand from one v2
backend and config paths, a copy of the wiring the CLI, the runtime,
and the coordinator already take from the store bundle. Both now build
from ServerStores and the default project's ProjectSettings, and run
events, monitor state, and the DAG change marker open on the project's
paths. One constant decides that the default project keeps the v2
directories, so migration flips one place. While projects are on, the
server, the scheduler, and start-all follow the project registry as
the coordinator does. Every path is unchanged with projects off.
2026-11-26 23:47:06 +09:00
Yota Hamada 5a00fcb06f Run node steps and bound runs on workers (N27 part 1) (#4211)
Runs on workers failed before any step when they were bound to a node
or had a step with nodes, and a narrowed run was forced onto the Dagu
host. Workers now read nodes, node secrets, and trusted host keys from
the coordinator through ResolveNodes and check host keys themselves. A
narrowed run carries its node list to a worker in Task.target_nodes.
2026-11-26 18:05:47 +09:00
Tom Brandenburg 8fd6c0203b Show the retry-disabled reason on every control (#4212)
A finished run that refuses retries hid its Retry where unavailable
actions are hidden, and a disabled step retry showed its reason only on
hover. Both controls now keep the reason readable by keyboard and touch,
and the running-state step retry reasons are translated.
2026-11-26 17:38:39 +09:00
Yota Hamada d97c4c43b6 Resolve dag.run and the library per project (P9 part 1) (#4208) 2026-11-26 16:44:50 +09:00
Yota HamadaandSCcagg5 8a348e6f22 Inject the model key on an egress upstream (#4202)
Some CLI agents need a model API key, and the agent must never hold
the real key. The hidden egress-proxy serve command gains --upstream
and its key options. A request in origin form goes to one upstream
that --allow lists, with the client credentials replaced by the key
read at start from a variable or a file. Logs show digests only, and
TRACE and TRACK get 405 so that an echoing upstream cannot return the
key.

Carved from #3721.

Co-authored-by: SCcagg5 <sccagg5@gmail.com>
2026-11-26 16:24:27 +09:00
Yota Hamada 1ff0a123a9 Resolve secrets and profiles in the run's project (P13 part 1) (#4206)
With projects on, a run reads its secrets and profile defaults in its
own project. A DAG's workspace label no longer adds a workspace layer
or chooses a default profile, since a migrated workspace is another
project's settings (Spec 102). Local runs, the embedded engine, and the
coordinator's answers to workers all follow this rule. With projects
off, nothing changes.

Part of #4128.
2026-11-26 16:04:55 +09:00
Tom Brandenburg 22edbad0a4 feat: add run ownership and terminal-state retry safeguards (RFC 023, step 3) (#4200)
Runs that represent A2A tasks must not become active again once
terminal. Add optional triggerSubject and retryDisabled run
attributes, refuse terminal retries of retry-disabled runs on every
retry path, and keep a dequeued retry-disabled run as a readable
aborted run.
2026-11-26 14:42:27 +09:00
Yota Hamada 68fb3eac40 Open every project's stores from one bundle (P5 part 1) (#4178) 2026-11-26 14:10:59 +09:00