About
Engage is a process composer with ordering and parallelism based on directed acyclic graphs.
In other words, given a collection of process definitions which can include ordering dependencies, Engage can run those processes in the order defined, while also running them in parallel to the extent permitted by the ordering. Engage supports both “task” processes, which allow dependents of a task to spawn after the task exits, and “service” processes, which allow dependents of a service to spawn after the service spawns but before it exits, and normally has the dependents exit before the service does.
Some related functionality is also provided, such as the ability to run a subset of the processes rather than all of them and the ability to generate a visualization of processes and the dependencies between them.
Notably, Engage does not make use of any process isolation features and it runs all processes as the current user. This deliberate design decision decreases moving parts between intented behavior and the collective actual behavior of Engage and the processes it runs. As a result, debugging is simpler and the odds of an intermediate part being misconfigured or broken are lower.
External links
Code of conduct
Community standards
Community members must have good vibes. Having bad vibes will result in a warning, temporary removal, or permanent removal from the community, depending on intensity. Behavior both inside and outside of community spaces is taken into consideration when evaluating vibes. Here are some examples of good and bad vibes:
- Good vibes
- Respecting others regardless of such characteristics as gender, sexual orientation, race, and neurodivergence.
- Maintaining a good signal to noise ratio.
- Understanding that there is no such thing as “apolitical”.
- Bad vibes
- Rules lawyering.
- Lacking ethics.
- Supporting fascism.
Generative AI
Those who interact with the project must acknowledge the following and act accordingly:
- Collecting training data for generative AI models without consent is unethical.
- Leveraging exploitative working conditions to label training data for generative AI models is unethical.
- Using, promoting, or otherwise legitimizing generative AI models that were produced unethically or are operated unethically is unethical.
- Generative AI models are unfit for purposes where correctness is a necessity.
Additionally, the contributors do not consent to the use of this project (including its source code, documentation, version control history, official discussion spaces, and so on), in part or in whole, as inference inputs to or as training data for generative AI models. There are many ways to describe those who violate the consent of others, none of which are pleasant.
Failure to abide by these precepts constitutes bad vibes, which will be handled as described in the Community standards section.
Introduction
This page introduces the most important concepts in Engage, but does not cover everything; for the remainder, see the rest of the pages in the “For users” category and the command line help text.
Selecting the Engage file
Engage will search for a file named engage.toml in the current directory and
all of its parent directories, and it will select the one closest to the current
directory, or exit with an error if it can’t find one. Alternatively, the path
to a file can be specified on the command line. The term “Engage file” refers to
the file selected in either of these ways.
Process basics
Processes are Engage’s unit of work. An Engage file can contain zero or more process definitions, even though zero is an unhelpful number of processes. Each process defines a command that can be spawned into an OS process which in turn does the aforementioned work. When the OS process is spawned, its working directory will be set to the parent directory of the Engage file the process is defined in, rather than inheriting the working directory from Engage’s own OS process.
Process dependencies
Processes can depend on one or more other processes. The primary reason to
define dependencies between processes is to control the order in which those
processes spawn and exit. A process x can be made to depend on another process
y either by configuring x to be ordered after y, by configuring y to
be ordered before x, or both. Ordering, and thus dependencies, are configured
per-process with the .processes.*.before and .processes.*.after keys.
It is safe, and often desirable, to have direct or indirect dependencies that appear to be “redundant”. A redundant dependency is one whose addition or removal would have no effect on the order in which processes spawn and exit. A major reason redundant dependencies are desirable is to reduce the likelihood of accidental ordering changes as processes are added, removed, and edited over time.
However, Engage will exit with an error before spawning any processes if it would have to spawn one or more processes that, directly or indirectly, depend on themselves (this is often called a “dependency cycle”).
Engage will run processes in parallel to the extent permitted by their dependencies. For example:
- Three processes with no dependencies will be run in parallel with each other.
- Given the processes
x,y, andzwherezdepends ony,ywill run beforez, andxwill run in parallel withyandz. - Given the processes
x,y, andzwherezdepends onxandy,xandywill run in parallel, andzwill run afterxandy.
This can be a significant performance improvement over running all processes in serial.
Process readiness
Processes have a concept called “readiness” which refers to the point in time
at which a process permits other processes that depend on it to be spawned. A
process “becomes ready” when it reaches that point in time. The point in time is
configured per-process with the .processes.*.ready-when key.
Based on this concept, processes are split into two kinds: “tasks” and “services”. A task is a process that can become ready by exiting successfully. A service is a process that can become ready after it spawns but before it exits. Another major difference between tasks and services is the order in which interdependent processes of each kind can spawn and exit. The behavior of each kind is explained in the following two sections.
Tasks
A task is a process that can become ready by exiting successfully.
Processes that depend on tasks will only be spawned after those tasks have exited successfully.
A task that fails to spawn or exits unsuccessfully will prevent any processes that depend on it from spawning.
For example, given the tasks x, y, and z where z depends on y and y
depends on x, the following will happen when these processes are run:
xspawns, because it has no dependencies.xexits successfully, thus becoming ready.yspawns, because its dependencies are ready.yexits successfully, thus becoming ready.zspawns, because its dependencies are ready.zexits successfully, thus becoming ready, but its readiness isn’t relevant here.
Services
A service is a process that can become ready after it spawns but before it exits.
Processes that depend on services will normally exit before those services exit; consequently, this means that interdependent services will normally exit in the reverse order from which they spawned. Abnormally, a service may exit before processes depending on it exit if the service decides to exit early of its own accord; for example, as a result of a misconfiguration or other runtime error.
A service that fails to spawn will prevent any processes that depend on it from spawning.
For example, given the services x and y and the task z where z depends
on y and y depends on x, the following will happen when these processes
are run:
xspawns, because it has no dependencies, thus becoming ready.yspawns, because its dependencies are ready, thus becoming ready.zspawns, because its dependencies are ready.zexits successfully, thus becoming ready, but its readiness isn’t relevant here.yexits successfully.xexits successfully.
Beginning a run
The engage command (without any subcommand) will attempt to spawn all
processes in the selected Engage file, starting with processes without
dependencies and spawning subsequent processes as their dependencies become
ready. If specified, the -p/--process option will cause Engage to only
attempt to spawn the selected processes and their dependencies.
During a run
While running processes, Engage will forward stdout and stderr of those
processes to Engage’s stdout, alongside an indication of which process emitted
which output and whether the output came from the process’ stdout or stderr. In
the default log format, whether a process’ output came from its stdout or stderr
is indicated by an O or an E in Engage’s stdout, respectively.
Ending a run
If any of the following happen while Engage is running:
- Engage receives
SIGINT. - Any process fails to spawn or exits unsuccessfully.
- All processes without dependents are tasks, and they have exited successfully.
Then Engage will send SIGINT once to each running process that either has no
dependents or whose dependents have already exited, wait for those processes to
exit, then repeat these steps until all processes have exited. For the avoidance
of doubt, this does preserve the behavior of services normally exiting in the
reverse order from which they spawned.
Notably, if any process without dependents is a service and all processes run
successfully, Engage will continue running until it receives SIGINT.
When no more processes are running, Engage will print out whether the run ended in success or failure and then exit with an appropriate exit status.
Engage will also stop running under various other conditions, including but not limited to:
- The laptop it’s running on depletes its battery.
- The desktop it’s running on has a power outage due to inclement weather.
- The gaming desktop it’s running on catches on fire due to 12VHPWR.
- The datacenter it’s running on catches on fire due to a water leak.
- The planet it’s running on gets enveloped by its star(s).
- The inevitable heat death of the universe.
Exit statuses
The following definition list enumerates the exit statuses emitted by Engage and their meanings.
- 0
- The command completed successfully.
- 1
- The command attempted to run processes and at least one process’ exit status indicates an error.
- 2
- The command encountered other errors, such as issues with the Engage file or invalid command line arguments.
API stability
The following sections enumerate which parts of Engage may and may not experience breaking changes between SemVer-compatible versions.
Stable
- The command line arguments’ syntax, structure, and semantics.
- The file format’s syntax, structure, and semantics.
- The semantics of existing exit statuses.
Unstable
- The format of output written to stdout and stderr.
File format
Engage files are in the TOML v1.1.0 format.
The following sections are named after the “path” to the key they document.
Paths are formed by an initial . followed by zero or more key names separated
by ., where subsequent keys belong to the table named by the previous key.
The key name * is a placeholder which indicates that there may be zero or more
keys in its place and that you are supposed to choose the names of those keys.
Key names suffixed with [] indicate that the key’s value is an array of tables
and the key name after the following ., if any, belongs to each table within
the array.
The use of key names not documented here (aside from keys whose names you are supposed to choose) is forbidden and will cause Engage exit with an error.
.processes
- Type
- Table of tables.
- Applicability
- Optional.
- Description
- Defines the set of processes. The keys in this table define the name of each
process, which must match the regex
^[a-z0-9][a-z0-9-]*$. Each key’s value defines the configuration for that process. - Examples
-
- Empty file
-
This Engage file defines no processes.
- Table without keys
-
[processes]This Engage file defines no processes.
- One process
-
[processes.hello-world] command = ["echo", "Hello, world!"] ready-when = "exited"This Engage file defines one process. The process:
- Is named
hello-world. - Defines a command that prints
Hello, world!to its stdout and exits successfully. - Becomes ready when it exits successfully.
When running all processes in this Engage file, the following will happen:
- The
hello-worldprocess spawns, because it has no dependencies. - The
hello-worldprocess printsHello, world!to its stdout. - The
hello-worldprocess exits successfully, thus becoming ready.
- Is named
.processes.*.after
- Type
- Array of strings.
- Applicability
- Optional.
- Description
- Defines that this process must be spawned after processes named in this array become ready. Each process name may appear more than once, though this has no additional effect.
- Examples
-
- One dependency
-
[processes.first] command = ["echo", "Hello"] ready-when = "exited" [processes.second] command = ["echo", "Goodbye"] ready-when = "exited" after = ["first"]This Engage file defines two processes. One process:
- Is named
first. - Defines a command that prints
Helloto its stdout and exits successfully. - Becomes ready when it exits successfully.
The other process:
- Is named
second. - Defines a command that prints
Goodbyeto its stdout and exits successfully. - Becomes ready when it exits successfully.
- Spawns after
firstbecomes ready.
When running all processes in this Engage file, the following will happen:
- The
firstprocess spawns, because it has no dependencies. - The
firstprocess printsHelloto its stdout. - The
firstprocess exits successfully, thus becoming ready. - The
secondprocess spawns, because its dependencies are ready. - The
secondprocess printsGoodbyeto its stdout. - The
secondprocess exits successfully, thus becoming ready.
- Is named
.processes.*.before
- Type
- Array of strings.
- Applicability
- Optional.
- Description
- Defines that this process must become ready before processes named in this array can be spawned. Each process name may appear more than once, though this has no additional effect.
- Examples
-
- One dependency
-
[processes.first] command = ["echo", "Hello"] ready-when = "exited" before = ["second"] [processes.second] command = ["echo", "Goodbye"] ready-when = "exited"This Engage file defines two processes. One process:
- Is named
first. - Defines a command that prints
Helloto its stdout and exits successfully. - Becomes ready when it exits successfully.
- Becomes ready before
secondis spawned.
The other process:
- Is named
second. - Defines a command that prints
Goodbyeto its stdout and exits successfully. - Becomes ready when it exits successfully.
When running all processes in this Engage file, the following will happen:
- The
firstprocess spawns, because it has no dependencies. - The
firstprocess printsHelloto its stdout. - The
firstprocess exits successfully, thus becoming ready. - The
secondprocess spawns, because its dependencies are ready. - The
secondprocess printsGoodbyeto its stdout. - The
secondprocess exits successfully, thus becoming ready.
- Is named
.processes.*.command
- Type
- Array of strings.
- Applicability
- Required.
- Description
- Defines the command used to spawn this process after its dependencies become ready. The array must have at least one value. The first value determines both the program to spawn a process for as well as the first argument to that process.
- Examples
-
- Program with no additional arguments
-
[processes.minimal] command = ["true"] ready-when = "exited"This Engage file defines one process. The process:
- Is named
minimal. - Defines a command that exits successfully.
- Becomes ready when it exits successfully.
When running all processes in this Engage file, the following will happen:
- The
minimalprocess spawns, because it has no dependencies. - The
minimalprocess exits successfully, thus becoming ready.
- Is named
- Program with additional arguments
-
[processes.hello-world] command = ["echo", "Hello, world!"] ready-when = "exited"This Engage file defines one process. The process:
- Is named
hello-world. - Defines a command that prints
Hello, world!to its stdout and exits successfully. - Becomes ready when it exits successfully.
When running all processes in this Engage file, the following will happen:
- The
hello-worldprocess spawns, because it has no dependencies. - The
hello-worldprocess printsHello, world!to its stdout. - The
hello-worldprocess exits successfully, thus becoming ready.
- Is named
.processes.*.environment
- Type
- Table of strings.
- Applicability
- Optional.
- Description
- Defines environment variables to set for this process. Each key-value pair in this table defines the name of an environment variable and its value respectively. Environment variables not defined in this table are left unset or are inherited normally.
- Examples
-
- Set one environment variable
-
[processes.hello-world] environment.NAME = "world" command = ["bash", "-c", "echo Hello, $NAME\!"] ready-when = "exited"This Engage file defines one process. The process:
- Is named
hello-world. - Sets an environment variable named
NAMEtoworld. - Defines a command that prints
Hello, world!to its stdout and exits successfully. - Becomes ready when it exits successfully.
When running all processes in this Engage file, the following will happen:
- The
hello-worldprocess spawns, because it has no dependencies. - The
hello-worldprocess printsHello, world!to its stdout. - The
hello-worldprocess exits successfully, thus becoming ready.
- Is named
.processes.*.ready-when
- Type
-
One of
"exited"and"spawned". - Applicability
-
Required.
- Description
-
Defines the point at which this process is considered ready. In turn, this defines when processes that depend on this one can be spawned, as well as the order in which this process and its dependents exit.
A value of
"exited"causes dependent processes to be started after this process has exited successfully.A value of
"spawned"causes dependent processes to be started after this process has successfully spawned. It also causes this process to exit after its dependents have exited. - Examples
-
- Two tasks
-
[processes.first] command = ["echo", "Hello"] ready-when = "exited" [processes.second] command = ["echo", "Goodbye"] ready-when = "exited" after = ["first"]This Engage file defines two processes. One process:
- Is named
first. - Defines a command that prints
Helloto its stdout and exits successfully. - Becomes ready when it exits successfully.
The other process:
- Is named
second. - Defines a command that prints
Goodbyeto its stdout and exits successfully. - Becomes ready when it exits successfully.
- Spawns after
firstbecomes ready.
When running all processes in this Engage file, the following will happen:
- The
firstprocess spawns, because it has no dependencies. - The
firstprocess printsHelloto its stdout. - The
firstprocess exits successfully, thus becoming ready. - The
secondprocess spawns, because its dependencies are ready. - The
secondprocess printsGoodbyeto its stdout. - The
secondprocess exits successfully, thus becoming ready.
- Is named
- One task and one service
-
[processes.service] command = ["sleep", "infinity"] ready-when = "spawned" [processes.task] command = ["echo", "Hello, world!"] ready-when = "exited" after = ["service"]This Engage file defines two processes. One process:
- Is named
service. - Defines a command that sleeps forever.
- Becomes ready when it spawns.
The other process:
- Is named
task. - Defines a command that prints
Hello, world!to its stdout and exits successfully. - Becomes ready when it exits successfully.
- Spawns after
servicebecomes ready.
When running all processes in this Engage file, the following will happen:
- The
serviceprocess spawns, because it has no dependencies. - The
serviceprocess sleeps forever, in parallel with steps 3 through 5. - The
taskprocess spawns, because its dependencies are ready. - The
taskprocess printsHello, world!to its stdout. - The
taskprocess exits successfully, thus becoming ready. - Engage begins ending the run by sending
SIGINTto theserviceprocess because all processes without dependents are tasks that have exited successfully. - The
serviceprocess exits because of theSIGINTit received from Engage. - Engage exits with an error because
serviceexited due to an unhandled signal.
- Is named
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to SemVer.
Unreleased
Removed
- BREAKING: Remove the concept of groups. (!10)
- BREAKING: Remove the
.task[].ignorekey. It is seldom useful and can be implemented outside of Engage when it’s truly necessary. (!13) - BREAKING: Remove the
.interpreterkey as it is no longer necessary. (!15) - BREAKING: Remove support for non-Unix platforms. Non-Unix platforms may become supported in the future. (!29)
- BREAKING: Remove the
-j/--jobscommand line option. (!33) - BREAKING: Remove the ability to specify the
-f/--fileoption prior to any subcommand. Now it can only be specified after the subset of subcommands that can make use of it. (!33)
Changed
- BREAKING: Replace the
.task[]and.task[].namekeys with the.processesand.processes.*keys respectively. “Tasks” are now called “processes”, because that’s what they ultimately are. (!11, !37) - BREAKING: Rename the
.processes.*.dependskey to.processes.*.after. (!11) - BREAKING: Replace the
.processes.*.scriptkey with the.processes.*.commandkey, which takes an array of strings rather than a string. (!15) - BREAKING: Only permit
^[a-z0-9-]+$in process names, and-cannot appear as the first character. (!18) - BREAKING: Reject unknown keys in Engage files. (!19)
- BREAKING: Replace the positional argument of
engage dotwith a-p/--processoption. (!41) - BREAKING: Replace the
engage justsubcommand with a-p/--processoption for theengagecommand (without any subcommand). (!41) - BREAKING: Make
engage dotandengage listexit with an error without printing the usual output if there are invalid process dependencies. The new-r/--relaxedoption for both commands can be used to approximate the old behavior. (!43, !46) - Deduplicate elements in the array of the
.processes.*.afterkey. Duplicates are not rejected, but they are ignored while constructing the dependency graph, so e.g. they will no longer show up inengage dot. (!11) - Improve error messages when attempting to run processes. (!21)
- Improve the formatting of errors. The new format is much more likely to work well with screen readers, and can include more information than just the error message, such as suggestions for resolving the error. (!21, !43)
- Spawn each process in its own process group. Primarily, this prevents them
from receiving
SIGINTdirectly from the shell whenctrl+cis pressed while running Engage, because shells typically sendSIGINTto the entire process group rather than just the first process spawned. Engage already manages the forwarding and sending of signals to processes it spawns. (!33) - Improve some error messages. (!33, !37, !44)
- Stop canonicalizing the path to the Engage file. Paths involving symlinks will behave more predictably. (!33)
- Support the TOML specification version 1.1.0. (!36)
- Improve the “File format” page of the book by flattening headings, using definition lists, and adding examples. (!38)
- Replace the “Tutorial” page of the book with an “Introduction” page. (!35)
Fixed
- No longer block the spawning of processes on other processes that they do not declare a direct or transitive dependency on. (#9, !24, !26)
Added
- BREAKING: Add the
.processes.*.ready-whenkey, which allows configuring processes to act like tasks (via the"exited"value) or services (via the"spawned"value), essentially allowing Engage to act as a service manager. (!35) - Add the
.processes.*.beforekey, which requires that the process in question exit successfully before spawning processes in the array of process names given to this key. Elements are deduplicated in the same way as the.processes.*.afterkey. (!12) - Add the
.processes.*.environmentkey, which allows configuring environment variables on a per-process basis. (!14, !16) - Add the
-l/--log-formatcommand line option for choosing alternate log formats. (!27, !28, !41) - Add a
ctrl+c/SIGINThandler which prevents new processes from spawning, signals running processes to exit, and waits for them to exit. (!29, !33) - Allow selecting multiple processes for the
engagecommand andengage dotsubcommand. (!41) - Add the
-r/--relaxedoption to theengage dotsubcommand which treats certain kinds of errors (such as dependency cycles) as warnings. (!43)
v0.2.1 - 2025-09-08
Changed
- Greatly improve error messages in some cases, primarily task failures and dependency cycles. (!4)
Fixed
- Only load the Engage file when necessary. (2f394ad)
Added
- Add more thorough documentation in the form of a book. (Too many commits to link.)
- The long help CLI output links to a local copy of the book, if packaged to do so. (!2)
v0.2.0 - 2023-09-19
Changed
- BREAKING: Always exit with a status of
1when a task fails instead of trying to exit with the same status code as the task. (c18357e) - BREAKING: Exit with a status of
2for errors other than tasks failing. (a991d12) - BREAKING: Move subcommands from under
selfto the top level and remove theselfsubcommand. For example, you’d now useengage dotinstead ofengage self dot. (e537e9d) - Remove all restrictions on group names. (0850054)
Fixed
- Report all failed tasks instead of just the first one. (b9fcdcd)
v0.1.3 - 2023-09-10
Removed
- Remove the Nix binary cache. (066e97c)
Fixed
- Wait for all started tasks to complete before terminating. (d98c6cc)
v0.1.2 - 2023-02-10
Changed
- Improve the behavior summary. (7be43e4)
Added
- Add a
--jobs/-joption to limit parallelism. (da1cc61)
v0.1.1 - 2023-01-28
Added
- Add a subcommand to generate shell completions. (48c925b)
v0.1.0 - 2022-11-07
Changed
- BREAKING: Disallow certain group names for forward compatibility. (066b2e3)
- BREAKING: Make
engage just <GROUP> [TASK]run all dependencies. (acda394) - Allow
engage self dotto take<GROUP> [TASK]arguments to show a subgraph for the given target. (acda394) - Make error messages a little prettier. (257e49e)
- Allow
engage self doteven if there are cycles. (f6ffbc2) - Print out the status at the end to make it easier to see. (37a6b9f)
- Print out the group and name of the failing task, if any. (c3df8f6)
- Print errors to
stderrinstead ofstdout. (9c5dfaf) - Rework output while running the graph to be more functional and accessible. (8880003)
Fixed
- BREAKING: Prevent groups from depending on nonexistent groups. (69219ec)
- Fix a deadlock in an unusual situation. (acee5fe)
- Prevent a deadlock in an unusual situation. (295e3b6)
- Improve the graph in unusual self-loop situation. (a9f1a27)
- Improve UX when
interpreteris given an empty list. (72e89a3) - Improve UX of some error messages. (c663bb6)
- Greatly improve error messages for dependency cycle issues. (f6ffbc2)
Added
- Upload build artifacts to Computer Surgery Nix binary cache. (8773d4d)
v0.1.0-alpha.2 - 2022-10-09
Changed
- BREAKING: Rename
task.cmdtotask.scriptinengage.toml. (b403dbe) - Change CLI UX due to a dependency update. (b0f7ac7)
Fixed
- Reset output style at the beginning of each line. (!1)
v0.1.0-alpha.1 - 2022-09-17
Initial release.
Contributing
Recommended development environment
-
Install Lix, direnv, and nix-direnv.
-
Enable Lix’s
nix-commandexperimental feature. -
If using a graphical editor, ensure it has direnv support, e.g. by installing an extension. If no support is available, changing directories into the project and launching the editor from the terminal should cause it to inherit the environment; though the editor will likely need to be restarted to propagate any changes to the direnv setup to the editor if any such changes are made.