@ligeti/shell 1.2.0 → 1.4.0
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 +58 -0
- package/dist/bin-resolve.d.ts +5 -0
- package/dist/bin-resolve.d.ts.map +1 -1
- package/dist/bin-resolve.js +12 -3
- package/dist/bin-resolve.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +2 -3
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/installed-versions.d.ts +9 -0
- package/dist/cli/installed-versions.d.ts.map +1 -0
- package/dist/cli/installed-versions.js +50 -0
- package/dist/cli/installed-versions.js.map +1 -0
- package/dist/cli/plugin.d.ts +13 -0
- package/dist/cli/plugin.d.ts.map +1 -0
- package/dist/cli/plugin.js +188 -0
- package/dist/cli/plugin.js.map +1 -0
- package/dist/cli/pre-push.d.ts +12 -0
- package/dist/cli/pre-push.d.ts.map +1 -0
- package/dist/cli/pre-push.js +56 -0
- package/dist/cli/pre-push.js.map +1 -0
- package/dist/cli/share-dir.d.ts +3 -0
- package/dist/cli/share-dir.d.ts.map +1 -0
- package/dist/cli/share-dir.js +13 -0
- package/dist/cli/share-dir.js.map +1 -0
- package/dist/cli/steps.d.ts +16 -0
- package/dist/cli/steps.d.ts.map +1 -0
- package/dist/cli/steps.js +102 -0
- package/dist/cli/steps.js.map +1 -0
- package/dist/cli/version.d.ts +6 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +14 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +36 -4
- package/dist/cli.js.map +1 -1
- package/dist/installed-steps.d.ts +8 -0
- package/dist/installed-steps.d.ts.map +1 -0
- package/dist/installed-steps.js +90 -0
- package/dist/installed-steps.js.map +1 -0
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -0
- package/dist/settings.js.map +1 -1
- package/dist/workers.d.ts +4 -1
- package/dist/workers.d.ts.map +1 -1
- package/dist/workers.js +59 -3
- package/dist/workers.js.map +1 -1
- package/package.json +10 -9
- package/share/.claude-plugin/marketplace.json +14 -0
- package/share/plugins/ligeti/.claude-plugin/plugin.json +6 -0
- package/share/plugins/ligeti/README.md +31 -0
- package/share/plugins/ligeti/docs/attestation.md +590 -0
- package/share/plugins/ligeti/docs/shell.md +442 -0
- package/share/plugins/ligeti/docs/troubleshooting.md +28 -0
- package/share/plugins/ligeti/references/rules.md +93 -0
- package/share/plugins/ligeti/skills/authoring-steps/SKILL.md +149 -0
- package/share/plugins/ligeti/skills/authoring-workflows/SKILL.md +146 -0
- package/share/plugins/ligeti/skills/installing-workflows/SKILL.md +121 -0
- package/share/plugins/ligeti/skills/onboard/SKILL.md +290 -0
- package/share/plugins/ligeti/skills/onboard/assets/ligeti-verify-attestation.github.yml +66 -0
- package/share/plugins/ligeti/skills/onboard/assets/ligeti-verify-attestation.yml +69 -0
- package/share/plugins/ligeti/skills/onboard/assets/pre-push.sh +11 -0
- package/share/plugins/ligeti/skills/scheduling-workflows/SKILL.md +102 -0
- package/share/plugins/ligeti/skills/troubleshooting/SKILL.md +94 -0
- package/share/plugins/ligeti/templates/step/.prettierignore +3 -0
- package/share/plugins/ligeti/templates/step/README.md +52 -0
- package/share/plugins/ligeti/templates/step/eslint.config.js +105 -0
- package/share/plugins/ligeti/templates/step/package.json +52 -0
- package/share/plugins/ligeti/templates/step/src/index.ts +3 -0
- package/share/plugins/ligeti/templates/step/src/settings.ts +27 -0
- package/share/plugins/ligeti/templates/step/src/tool-version.ts +61 -0
- package/share/plugins/ligeti/templates/step/test/rules.test.ts +144 -0
- package/share/plugins/ligeti/templates/step/test/settings.test.ts +30 -0
- package/share/plugins/ligeti/templates/step/test/tool-version.feature +32 -0
- package/share/plugins/ligeti/templates/step/tsconfig.build.json +26 -0
- package/share/plugins/ligeti/templates/step/tsconfig.json +21 -0
- package/share/plugins/ligeti/templates/workflow/.prettierignore +3 -0
- package/share/plugins/ligeti/templates/workflow/README.md +56 -0
- package/share/plugins/ligeti/templates/workflow/eslint.config.js +99 -0
- package/share/plugins/ligeti/templates/workflow/package.json +46 -0
- package/share/plugins/ligeti/templates/workflow/src/workflow.ts +72 -0
- package/share/plugins/ligeti/templates/workflow/test/__snapshots__/workflow.test.ts.snap +132 -0
- package/share/plugins/ligeti/templates/workflow/test/rules.test.ts +160 -0
- package/share/plugins/ligeti/templates/workflow/test/template-workflow.feature +31 -0
- package/share/plugins/ligeti/templates/workflow/test/workflow.test.ts +64 -0
- package/share/plugins/ligeti/templates/workflow/tsconfig.build.json +26 -0
- package/share/plugins/ligeti/templates/workflow/tsconfig.json +21 -0
- package/share/scripts/pre-push-gate.sh +308 -0
- package/share/scripts/pre-push-lib.sh +64 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
# @ligeti/shell
|
|
2
|
+
|
|
3
|
+
The control plane: web UI, callback endpoint, worker supervisor, registry, and the `ligeti` CLI. It
|
|
4
|
+
never calls `DBOS.launch()`, `registerWorkflow` or `registerStep` — enforced by its own ESLint
|
|
5
|
+
preset ([`packages/eslint-plugin`](../eslint-plugin/README.md)) — and talks to workers only through
|
|
6
|
+
`DBOSClient`, never by holding workflow or step code itself.
|
|
7
|
+
|
|
8
|
+
See [ADR-0012](../../adr/0012-a-workflow-package-is-its-own-dbos-application.md) for why each
|
|
9
|
+
configured workflow runs as its own DBOS application, spawned as a separate worker process by the
|
|
10
|
+
Supervisor rather than sharing this process, and [`docs/trust-model.md`](../../docs/trust-model.md)
|
|
11
|
+
for the security posture this control plane sits inside.
|
|
12
|
+
|
|
13
|
+
## What it exposes
|
|
14
|
+
|
|
15
|
+
- **`ligeti` CLI**:
|
|
16
|
+
- `ligeti serve` — loads `.env` if present, describes every configured workflow, starts the
|
|
17
|
+
Supervisor and the HTTP server, and shuts down cleanly on `SIGTERM`/`SIGINT`.
|
|
18
|
+
- `ligeti run <workflow>` — enqueues one run over this shell's own HTTP API and returns once
|
|
19
|
+
it has started; `--wait` polls it to completion. Documented in full under
|
|
20
|
+
[`ligeti run`](#ligeti-run) below.
|
|
21
|
+
- `ligeti runs`, `ligeti trace <runId|latest-failed>`, `ligeti transcript <runId>` — read-only
|
|
22
|
+
troubleshooting over the same HTTP API. Documented under
|
|
23
|
+
[`ligeti runs / trace / transcript`](#ligeti-runs--trace--transcript) below.
|
|
24
|
+
- `ligeti workflows`, `ligeti schema <workflow>` — list the workflows and print one's input
|
|
25
|
+
fields. Documented under [`ligeti workflows / schema`](#ligeti-workflows--schema) below.
|
|
26
|
+
- `ligeti steps`, `ligeti steps describe <dir>` — list the installed step packages and print one's
|
|
27
|
+
steps. Documented under [`ligeti steps`](#ligeti-steps) below.
|
|
28
|
+
- `ligeti cron check [<file>]` — validate a cron file without serving. Documented under
|
|
29
|
+
[Cron entries](#cron-entries) below.
|
|
30
|
+
- **`Supervisor`** (`src/supervisor.ts`) — spawns one `ligeti-worker run <dir>` child process per
|
|
31
|
+
configured workflow, restarts it on crash with backoff, and reports each worker's status. It
|
|
32
|
+
manages OS processes only, never DBOS state.
|
|
33
|
+
- **`Registry`** (`src/registry.ts`) — the shell's view of configured workflows: describes each
|
|
34
|
+
configured package directory once at boot (refusing duplicate workflow names), then serves
|
|
35
|
+
manifests from `ligeti.workflow_registrations`, written by each worker.
|
|
36
|
+
- **HTTP routes** (`src/web/routes.tsx`): `GET /healthz`, `GET /` (redirects to `/runs`;
|
|
37
|
+
an old `/?workflow=` bookmark to `/runs/new` with the same query), `GET /runs/new` (the launch page, reached
|
|
38
|
+
from the Runs tab: workflow picker and start form; `?workflow=` selects a workflow), `GET /runs`
|
|
39
|
+
(the Runs tab: recent launched root runs, 50 per page; `?page=` picks a
|
|
40
|
+
1-based page, clamped to 1 for anything that isn't a positive safe integer and capped at the
|
|
41
|
+
largest page a safe offset can reach for very large values, with "← Newer"/"Older →" links below
|
|
42
|
+
the table; `?workflow=`, repeatable `?status=`, `?createdFrom=` and `?createdTo=` (inclusive
|
|
43
|
+
`YYYY-MM-DD` UTC days) filter the list, a malformed value answers 400), `GET /cron-runs` (the
|
|
44
|
+
Cron runs tab: see [Cron entries](#cron-entries)), `GET /workers` (the Workers tab: each
|
|
45
|
+
configured worker's supervisor status), `GET /config` (the Configuration tab: the configuration the
|
|
46
|
+
running shell loaded at startup, grouped by owner, secrets only as `set`/`unset`; a later `.env`
|
|
47
|
+
edit shows after a restart), `POST /runs` (see
|
|
48
|
+
[Starting a run over HTTP](#starting-a-run-over-http)), `GET /runs/:id`,
|
|
49
|
+
`POST /runs/:id/cancel`, `GET /workflows`, `GET /workflows/:name`, `POST /attest`, `POST /callbacks/:token`,
|
|
50
|
+
`GET /approvals/:token`, `POST /approvals/:token`. Every page shares a tab bar
|
|
51
|
+
(`Runs`/`Cron runs`/`Workers`/`Configuration`, marking the current one active) except the
|
|
52
|
+
token-authenticated approval pages, which a human
|
|
53
|
+
reaches from outside the shell's own UI; the Workers tab carries a warning mark whenever
|
|
54
|
+
any configured worker isn't in the `"running"` status. `GET /workflows` (with
|
|
55
|
+
`Accept: application/json`: `{ workflows: [{ name, description, registered }] }`; otherwise it
|
|
56
|
+
redirects to `/runs/new`) and `GET /workflows/:name` with `Accept: application/json` (the manifest; 404 for
|
|
57
|
+
an unknown name, 503 before the worker has registered) serve `ligeti workflows` and
|
|
58
|
+
`ligeti schema`. `GET /workers` with `Accept: application/json` answers
|
|
59
|
+
`{ workers: [{ name, status, reason? }] }`: the workflow name, its worker's supervisor status
|
|
60
|
+
(`starting`, `running`, `backoff`, `blocked` or `stopped`) and, when there is one, why. Otherwise `GET /workflows/:name` renders the
|
|
61
|
+
manifest's optional `workflow.diagram` (and, for a child whose parent has no diagram, the child's own) as a Mermaid flowchart, rendered
|
|
62
|
+
client-side by `mermaid/dist/mermaid.min.js`, vendored and served locally at a version-tagged
|
|
63
|
+
`GET /assets/mermaid.min.js?v=<version>` (`src/web/mermaid-asset.ts`) rather than loaded from a
|
|
64
|
+
CDN. The console's own assets are served the same way and never leave the host (`src/web/assets/`):
|
|
65
|
+
the stylesheet at `GET /assets/ligeti.css?v=<content hash>` (tokens, components and the `kit-`
|
|
66
|
+
layout, built from `src/web/styles/`); the Saira, Barlow and IBM Plex Mono `woff2` files at
|
|
67
|
+
`GET /assets/fonts/<family>-<subset>-<weight>-<style>.woff2` (from the `@fontsource/*` packages);
|
|
68
|
+
the allowlisted Lucide icons at `GET /assets/icons/<name>.svg` (from `lucide-static`, drawn through
|
|
69
|
+
a CSS mask; an icon outside `ICON_NAMES` answers 404); the per-status favicons at
|
|
70
|
+
`GET /assets/favicons/<status>[-updated].svg?v=<content hash>` (plus a neutral one, and an
|
|
71
|
+
`-updated` twin with a corner dot); the run page's background-refresh script at
|
|
72
|
+
`GET /assets/run-refresh.js?v=<content hash>`; and the licence of each vendored package at
|
|
73
|
+
`GET /assets/licenses/{saira,barlow,ibm-plex-mono,lucide-static}.txt` (SIL OFL 1.1 for the fonts,
|
|
74
|
+
ISC for the icons). `POST /attest` takes `{ app, repository, commit, configPath? }`, runs the local-verification
|
|
75
|
+
gate in a fresh gate checkout of that commit (`src/gate-checkout.ts`, under
|
|
76
|
+
`$LIGETI_STATE_DIR/gate-checkouts/`) and signs the resulting attestation via `@ligeti/attest`; it
|
|
77
|
+
answers `503` when `LIGETI_ATTEST_SECRET`/`LIGETI_ATTEST_KEY_FILE` are not configured, since
|
|
78
|
+
attestation is optional. `POST /callbacks/:token` is where a spawned agent's `wrapper.sh` delivers
|
|
79
|
+
its result
|
|
80
|
+
back to the shell. The JSON read API (`src/web/read-api.ts`; `Accept: application/json`, behind the
|
|
81
|
+
Host allow-list only) serves troubleshooting: `GET /runs` filters by `status`, `workflow` (each
|
|
82
|
+
repeatable or comma-separated), `since` (ISO time), `limit` (1-500, default 50), `children=true`
|
|
83
|
+
and `scope=launched|cron` (default `launched`; `cron` lists the root runs a schedule started and
|
|
84
|
+
cannot be combined with `children=true`) and answers `400 {error}` to a malformed query; `GET /cron-entries` returns `{ entries: [{ name, workflow, schedule, timezone, lastFiredAt }] }`, the configured cron entries in file order (`lastFiredAt` is `null` until one fires); `GET /runs/:id/trace` returns the run's steps (an
|
|
85
|
+
output over 2000 characters is replaced by its size and a preview), `status` event, agent attempts
|
|
86
|
+
and child runs recursively; `GET /runs/:id/steps/:functionId` returns one step in full;
|
|
87
|
+
`GET /runs/:id/attempts/:attemptId/transcript` digests a Claude `transcript.jsonl` or OpenCode
|
|
88
|
+
`opencode-raw-output.json` (`?raw=1` returns the file); `GET /runs/:id/attempts/:attemptId/files/:name`
|
|
89
|
+
returns one attempt file as text. An attempt is recognised from a step's checkpointed output, and
|
|
90
|
+
its files are read only from inside `$LIGETI_STATE_DIR/runs/` -- a path resolving outside is
|
|
91
|
+
treated as absent.
|
|
92
|
+
|
|
93
|
+
## Starting a run over HTTP
|
|
94
|
+
|
|
95
|
+
`POST /runs` with `Content-Type: application/json` takes `{ "workflow": "<name>", "input": {...} }`
|
|
96
|
+
and answers `201` with `{ "id": "<run id>" }`. An input property the workflow does not declare is
|
|
97
|
+
rejected by name. The body may also carry `"id"`, which becomes the run's id: 1-256 characters of
|
|
98
|
+
letters, digits, `.`, `_`, `:` and `-`, starting with a letter or digit. A repeated id never starts a
|
|
99
|
+
second run: a request sent after the first was answered finds the run, starts nothing and answers
|
|
100
|
+
`200` with the same `{ "id" }`, ignoring the repeat's input; two requests racing before either is
|
|
101
|
+
answered may both answer `201`, still for the one run. An id that names a run of another workflow is
|
|
102
|
+
a `409`. An id starting with `sched-` is a `400`, because the shell reserves that prefix for cron
|
|
103
|
+
runs, and so is the id `new`, because `/runs/new` is the launch page.
|
|
104
|
+
|
|
105
|
+
Every run started this way -- from the launch page, over JSON, or by `ligeti run` -- carries the DBOS
|
|
106
|
+
attribute `launched: true`, and its child runs inherit it. The Runs tab, `GET /runs` and `ligeti runs`
|
|
107
|
+
list only runs carrying it, so a cron run appears on the Cron runs tab alone. Launched runs created
|
|
108
|
+
before the attribute existed are no longer listed but stay reachable at `/runs/<id>`.
|
|
109
|
+
|
|
110
|
+
## `ligeti run`
|
|
111
|
+
|
|
112
|
+
`ligeti run <workflow>` enqueues a run against a **running `ligeti serve`** over HTTP -- it
|
|
113
|
+
requires the shell to already be up; unlike `serve`, it needs no `.env` and no environment variable
|
|
114
|
+
at all, since it holds no secret and opens no database connection of its own. That statelessness is the point: it works from a git worktree, from a subdirectory of the
|
|
115
|
+
repo, or from a bare checkout with no `.env` in sight, as long as it can reach a shell. It is
|
|
116
|
+
deliberately not a second control plane -- see
|
|
117
|
+
[ADR-0012](../../adr/0012-a-workflow-package-is-its-own-dbos-application.md).
|
|
118
|
+
|
|
119
|
+
It finds the shell by trying, in order, the first one present: `--url <base>`, then
|
|
120
|
+
`$LIGETI_PUBLIC_BASE_URL`, then `http://<LIGETI_HOST>:<LIGETI_PORT>` (`127.0.0.1:8100` by default).
|
|
121
|
+
|
|
122
|
+
Input is a JSON object on stdin:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
echo '{"field": "value"}' | ligeti run <workflow-name>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Before enqueuing anything, `ligeti run` validates that input against the workflow's manifest
|
|
129
|
+
schema, so a misspelled field fails in milliseconds with the manifest's own error message instead
|
|
130
|
+
of surfacing as a `zod` failure inside a started run minutes later. A field the manifest does not
|
|
131
|
+
declare is rejected by name rather than ignored, since a JSON caller sends only what it meant to
|
|
132
|
+
send: a typo there is a mistake, not a field to drop.
|
|
133
|
+
|
|
134
|
+
Once the run is accepted, `ligeti run` prints `started <workflow> as <id>` to stderr and exits `0`
|
|
135
|
+
at once, with nothing on stdout; follow the run with `ligeti trace <id>` or the Runs tab. With
|
|
136
|
+
`--wait` it instead polls the run to a terminal status, then prints the run's output as one JSON
|
|
137
|
+
line on stdout on success, or a one-line failure summary on stderr if it fails.
|
|
138
|
+
|
|
139
|
+
Exit codes: `0` the run was started (with `--wait`: it succeeded), `1` the workflow has not
|
|
140
|
+
registered yet or the shell speaks a different protocol (with `--wait`, also: the run failed, timed
|
|
141
|
+
out or no worker claimed it), `2` usage or bad stdin, `3` the shell could not be reached (with
|
|
142
|
+
`--wait`, also: contact with it was lost mid-run) -- so a script can tell "my workflow failed" from
|
|
143
|
+
"my control plane is down". A script that needs the result or the verdict passes `--wait`.
|
|
144
|
+
|
|
145
|
+
## `ligeti runs / trace / transcript`
|
|
146
|
+
|
|
147
|
+
Three read-only commands for finding out why a run went wrong. Like `ligeti run` they need a
|
|
148
|
+
running `ligeti serve`, hold no secret, and find it by `--url <base>`, then
|
|
149
|
+
`$LIGETI_PUBLIC_BASE_URL`, then `http://<LIGETI_HOST>:<LIGETI_PORT>` (`127.0.0.1:8100` by default). They are thin clients of the shell's JSON
|
|
150
|
+
read API (`GET /runs`, `/runs/:id/trace`, `/runs/:id/steps/:functionId`,
|
|
151
|
+
`/runs/:id/attempts/:attemptId/transcript`).
|
|
152
|
+
|
|
153
|
+
| Command | Prints |
|
|
154
|
+
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
155
|
+
| `ligeti runs [--status S] [--workflow W] [--since ISO] [--limit N] [--children] [--cron]` | One line per run, newest first: id, workflow, status, creation time, its parent when it is a child run, and the first line of its error. `--status` and `--workflow` repeat; only root runs unless `--children`; launched runs unless `--cron`, which lists cron runs and first one line per cron entry (name, workflow, schedule, time zone, when it last fired). With `--json`, `--cron` prints `{ entries, runs }`. |
|
|
156
|
+
| `ligeti trace <runId\|latest-failed>` | The run header, its status event, numbered steps (`#<functionId> <name> <status> <duration>`, with `→ child <id>`, the error and an output preview), its agent attempts and its child runs indented, then one `agent failed:` line (with its `ligeti transcript` command) for every agent attempt whose result is an error — a workflow may handle an agent failure and still finish `SUCCESS` — and last `failed at:` for the deepest failed step. `latest-failed` is the newest root run in `ERROR`, launched or cron. A truncated output names the `GET /runs/<id>/steps/<functionId>` route that returns all of it. |
|
|
157
|
+
| `ligeti transcript <runId> [--attempt <attemptId>] [--raw]` | One agent attempt as `user:` / `assistant:` / `tool <name>(<input>)` / `→ result:` / `→ error:` lines, then the final `result:` and `error:`. Without `--attempt` it takes the newest attempt anywhere in the run's tree and asks the run that owns it. `--raw` prints the transcript file's bytes instead. |
|
|
158
|
+
|
|
159
|
+
`latest-failed` matches only status `ERROR`. For a run that ended `CANCELLED` or
|
|
160
|
+
`MAX_RECOVERY_ATTEMPTS_EXCEEDED`, find it with `ligeti runs --status <status>` and trace its id.
|
|
161
|
+
`GET /runs` lists only the runs of registered applications, whereas `GET /runs/:id/trace` serves any
|
|
162
|
+
run id.
|
|
163
|
+
|
|
164
|
+
Each takes `--json`, which prints the shell's response (pretty-printed) instead of text; `--json`
|
|
165
|
+
and `--raw` cannot be combined.
|
|
166
|
+
|
|
167
|
+
Exit codes: `0` success, `1` any other failure, `2` usage error, a bad query, or a run, attempt or
|
|
168
|
+
failed run that does not exist, `3` the shell could not be reached.
|
|
169
|
+
|
|
170
|
+
## `ligeti workflows / schema`
|
|
171
|
+
|
|
172
|
+
Two read-only commands that tell you what can be run and with which input. They find the shell the
|
|
173
|
+
same way as the commands above, and take `--json`.
|
|
174
|
+
|
|
175
|
+
| Command | Prints |
|
|
176
|
+
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
177
|
+
| `ligeti workflows` | One line per workflow: name, `registered` or `not registered`, and the first line of its description. `--json` prints the response of `GET /workflows`. |
|
|
178
|
+
| `ligeti schema <workflow>` | The workflow's name and description, then one line per input field: name, type, `required` or `optional`, `default: …` and description, with nested object fields indented under their parent. `--json` prints only the input JSON Schema (draft 2020-12) with `additionalProperties: false` added at the top level, so it rejects undeclared keys as `POST /runs` does. |
|
|
179
|
+
|
|
180
|
+
Exit codes are those of `ligeti runs`: an unknown workflow is `2`, one that has not registered yet is `1`.
|
|
181
|
+
|
|
182
|
+
## `ligeti steps`
|
|
183
|
+
|
|
184
|
+
Two commands that tell you which steps you can build a workflow from. They read files and run the
|
|
185
|
+
installed `ligeti-worker`; they need no running shell, no database and no `.env`. In a checkout
|
|
186
|
+
run them as `pnpm ligeti steps …`.
|
|
187
|
+
|
|
188
|
+
| Command | Prints |
|
|
189
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
190
|
+
| `ligeti steps` | One line per step package installed with your workflows: name, version, the first line of its description and its directory. `--json` prints an array of `{name, version, description, dir}` with the full description. |
|
|
191
|
+
| `ligeti steps describe <dir>` | The package's steps as a JSON array of manifest steps: name, `step` or `resource`, package, version, description, input and output JSON Schema, a resource step's `callbackPayload`, and the `envVars` each step declares. Run by the `ligeti-worker` of the SDK the package resolves as its peer dependency. |
|
|
192
|
+
|
|
193
|
+
`ligeti steps` takes the effective `LIGETI_WORKFLOWS` as `ligeti config` does (`.env` merged with the
|
|
194
|
+
process environment, the default workflows when unset). For each workflow directory it walks up
|
|
195
|
+
through the `node_modules` directories Node would resolve, reads `*/package.json` and
|
|
196
|
+
`@scope/*/package.json` (skipping `.pnpm`), and keeps the packages whose `ligeti.kind` is `step`. A
|
|
197
|
+
name and version found more than once is listed once, under the real path of its first directory.
|
|
198
|
+
Under a pnpm install the listing can include step packages from pnpm's hoisted
|
|
199
|
+
`node_modules/.pnpm/node_modules`, because Node resolves from there too.
|
|
200
|
+
|
|
201
|
+
`ligeti steps describe` exits `1` with the worker's message on stderr when `<dir>` is not a step
|
|
202
|
+
package or its `ligeti.sdk` range excludes the resolved SDK, and when the SDK's major differs from
|
|
203
|
+
the shell's. A usage error exits `2`.
|
|
204
|
+
|
|
205
|
+
## `ligeti config`
|
|
206
|
+
|
|
207
|
+
Lists and edits the variables in `.env`, so an operator or an agent never has to open that file:
|
|
208
|
+
`.env` holds credentials, and an agent that greps it prints them into a transcript that outlives the
|
|
209
|
+
session. Agents use `ligeti config` instead of reading `.env` ([ADR-0028](../../adr/0028-env-vars-are-secret-or-public-and-ligeti-config-never-shows-a-secret.md)).
|
|
210
|
+
In a checkout of this repository `ligeti` is not on `PATH`: run it as `pnpm ligeti config …`.
|
|
211
|
+
|
|
212
|
+
| Command | Does |
|
|
213
|
+
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
214
|
+
| `ligeti config` | One line per known variable: name, source and value. A secret shows only `set`, or nothing when it is unset. |
|
|
215
|
+
| `ligeti config get <NAME>` | A public variable's value; for a secret or an unknown name only `set`. Exits `1` when the variable is unset. |
|
|
216
|
+
| `ligeti config set <NAME> <VALUE>` | Writes a public variable to `.env` after validating it against its settings schema. |
|
|
217
|
+
| `ligeti config set <NAME>` | For a secret: prompts on the terminal with echo off, or reads stdin when it is not a terminal (one trailing newline is stripped). |
|
|
218
|
+
| `ligeti config set --force <NAME>` | Sets a name `ligeti config` does not know, as a secret. |
|
|
219
|
+
| `ligeti config unset <NAME>` | Removes the variable's line from `.env`. |
|
|
220
|
+
|
|
221
|
+
A variable is _secret_ or _public_; one whose sensitivity is unknown is a secret. A secret's value is
|
|
222
|
+
never printed and never accepted on the command line, so it cannot land in shell history or a process
|
|
223
|
+
listing. The known variables are the shell's own and those declared in the manifest of every workflow
|
|
224
|
+
in `LIGETI_WORKFLOWS` with their `configuredBy` settings, which are public; a variable the shell
|
|
225
|
+
derives for each worker, such as `LIGETI_CALLBACK_KEY`, is not known. A workflow that cannot be
|
|
226
|
+
described is reported on stderr and skipped. `LIGETI_CONFIG_DIR` is listed as the process environment
|
|
227
|
+
has it and cannot be set: it locates `.env`, so a `LIGETI_CONFIG_DIR` line in `.env` is reported as
|
|
228
|
+
having no effect.
|
|
229
|
+
|
|
230
|
+
The source column is `process env`, `.env`, `default` or `unset`. The process environment wins over
|
|
231
|
+
`.env`, as it does when the shell starts, and a variable set in both says
|
|
232
|
+
`process env (overrides .env)`; `set` and `unset` warn in that case. `ligeti config` parses `.env`
|
|
233
|
+
itself and never loads it into the process environment.
|
|
234
|
+
|
|
235
|
+
`set` and `unset` rewrite `.env` atomically: every other line and comment stays, a value that needs
|
|
236
|
+
quoting is quoted, and the file keeps its mode (a new file gets `0600`, in a config directory that `set`
|
|
237
|
+
creates with `0700`). They take effect on the next
|
|
238
|
+
shell restart. Exit codes: `0` success, `1` a value that does not validate or a variable that is
|
|
239
|
+
unset, `2` a usage error, an unknown name without `--force`, or a secret given on the command line.
|
|
240
|
+
|
|
241
|
+
```sh
|
|
242
|
+
ligeti config set LIGETI_PORT 8200
|
|
243
|
+
printf '%s' "$TOKEN" | ligeti config set GITLAB_TOKEN
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
`.env` is `$LIGETI_CONFIG_DIR/.env` when `LIGETI_CONFIG_DIR` is set in the process environment,
|
|
247
|
+
otherwise `.env` in the per-user config directory (the `LIGETI_CONFIG_DIR` row below); a `.env` in the
|
|
248
|
+
working directory is never read. A missing default config directory means no `.env`; `ligeti serve`
|
|
249
|
+
and `ligeti config set` create it with mode `0700`. Every `ligeti` command that loads `.env`
|
|
250
|
+
resolves it the same way, and relative paths in the shell's settings, whether set in `.env` or in
|
|
251
|
+
the process environment, resolve against the directory holding it.
|
|
252
|
+
|
|
253
|
+
## `ligeti --version / plugin install / pre-push`
|
|
254
|
+
|
|
255
|
+
`ligeti --version` prints one line per installed package, read from its `package.json`, and exits `0`:
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
@ligeti/shell 1.2.0
|
|
259
|
+
@ligeti/sdk 2.3.0 (major 2)
|
|
260
|
+
@ligeti/attest 2.0.3
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
`ligeti plugin install [--yes]` registers the share directory as the `ligeti` Claude Code
|
|
264
|
+
marketplace with the `claude` CLI and installs the `ligeti` plugin for the user; the plugin is active
|
|
265
|
+
in the next Claude Code session. It fails when `claude` is not on `PATH`. Running it again is the
|
|
266
|
+
fix for a stale path. When a `ligeti` marketplace is already registered somewhere else, it prints both
|
|
267
|
+
locations, warns that replacing it uninstalls the `ligeti` plugin with its saved options and data, and
|
|
268
|
+
asks `Replace it? [y/N]`: anything but `y` exits `1` and changes nothing. Without a terminal it fails
|
|
269
|
+
the same way unless `--yes` is given.
|
|
270
|
+
|
|
271
|
+
`ligeti pre-push [<remote> <url>]` runs the share directory's `scripts/pre-push-gate.sh` through `bash`
|
|
272
|
+
with git's arguments and standard input, and exits with its status. It runs in the caller's
|
|
273
|
+
environment, with `LIGETI_GATE_ATTEST_CLI` and `LIGETI_GATE_LIGETI_CLI` set to the installed
|
|
274
|
+
`ligeti-attest` and `ligeti` CLIs, `LIGETI_GATE_NODE` to the node running `ligeti`, and
|
|
275
|
+
`LIGETI_GATE_BASE_URL` to the shell's base URL, resolved as for the other HTTP commands from the
|
|
276
|
+
caller's environment and then `.env`. Nothing else from `.env` reaches the gate. A SIGINT or SIGTERM
|
|
277
|
+
is forwarded to the gate, and a gate killed by a signal makes `ligeti pre-push` exit with 128 plus
|
|
278
|
+
the signal number. A target repository's `pre-push` hook is
|
|
279
|
+
`exec ligeti pre-push "$@"` (see [`docs/attestation.md`](../../docs/attestation.md)).
|
|
280
|
+
|
|
281
|
+
The **share directory** is the repository root in a checkout (the directory two levels above this
|
|
282
|
+
package holds `.claude-plugin/marketplace.json`), and the package's own `share/` folder when
|
|
283
|
+
installed. `share/` is built by the package's `prepack` script, and holds the marketplace file, the
|
|
284
|
+
`plugins/ligeti` plugin with its symlinks resolved, and the two gate scripts.
|
|
285
|
+
|
|
286
|
+
## Cron entries
|
|
287
|
+
|
|
288
|
+
`ligeti serve` reads the cron file (`LIGETI_CRON_FILE`, default `cron.yaml` in the config directory) and applies
|
|
289
|
+
each entry as a DBOS schedule, so any configured workflow can run on a cron. The default path may be
|
|
290
|
+
absent, which means no cron entries; a file named explicitly by `LIGETI_CRON_FILE` that is absent,
|
|
291
|
+
or a file that is present but invalid, fails startup, naming the file or the entry at fault. The file
|
|
292
|
+
is a map from a free-text entry name to its entry:
|
|
293
|
+
|
|
294
|
+
```yaml
|
|
295
|
+
<entry name>:
|
|
296
|
+
workflow: <name of a configured workflow>
|
|
297
|
+
schedule: "<cron expression>"
|
|
298
|
+
timezone: <IANA time zone name> # optional, defaults to the shell's time zone
|
|
299
|
+
input: # optional, defaults to {}
|
|
300
|
+
<field>: <value>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Entries are strict: an unknown key, a blank name or one longer than 100 characters, a workflow that is not configured, an input that
|
|
304
|
+
does not match that workflow's input schema, or an invalid cron expression is rejected at startup.
|
|
305
|
+
An entry's cron expression is read in its `timezone` when it sets one, otherwise in the shell's own time
|
|
306
|
+
zone, which is `TZ` normalised to an IANA name: a leading `:` is dropped, a `.../zoneinfo/[posix/|right/]X` path
|
|
307
|
+
becomes `X`, and the case is canonicalised. `TZ` unset, or naming the host's zone file (`:/etc/localtime`),
|
|
308
|
+
means the zone the shell process itself resolves. Any other `TZ` that is not an IANA name (`CET-1CEST`, an
|
|
309
|
+
offset like `+01:00`, empty) never stops the shell from starting; startup fails only when an entry has no
|
|
310
|
+
`timezone`, and the error names `TZ`. The normalised name is also the `TZ` every worker and gate child gets
|
|
311
|
+
(an unnormalisable `TZ` is passed on unchanged). An entry's own `timezone` must be an IANA name too; an offset
|
|
312
|
+
is rejected. The stored schedule names its zone explicitly, and the shell logs it with each applied entry;
|
|
313
|
+
changing a zone changes the stored schedule the next time the file is applied.
|
|
314
|
+
A local time that does not exist on a daylight-saving change day is skipped, and one that occurs twice runs
|
|
315
|
+
twice, as with ordinary cron. An entry in a zone other than the shell's can also miss or repeat a run on
|
|
316
|
+
the days either zone changes its clocks.
|
|
317
|
+
Each schedule enqueues onto the `runs` queue of the workflow's own application with the entry's
|
|
318
|
+
`input` as the run's input, and does not backfill runs missed while the shell was down.
|
|
319
|
+
|
|
320
|
+
`ligeti cron check [<file>]` runs the same validation without serving, and prints one line per
|
|
321
|
+
problem, each starting with the file's path. Without `<file>` it checks the file the cron file
|
|
322
|
+
settings name; with it, that file, and a file that cannot be read is a problem, except the default
|
|
323
|
+
`cron.yaml`, which may be absent. The file's structure -- its shape, each entry's keys and name, and
|
|
324
|
+
the cron expression -- is checked offline. That each workflow is configured and not `blocked`, and
|
|
325
|
+
that each input matches the workflow's input schema (the one the running worker registered, which can differ from what the next `serve` reads from disk if the workflow changed since), come from the running shell (`--url`, as for the
|
|
326
|
+
other commands); a workflow that has not registered yet has its input left unchecked, with a notice
|
|
327
|
+
on stderr, and a shell that cannot be reached skips these checks with a notice. The exit code is `0`
|
|
328
|
+
when there is no problem, `1` when there is any, and `2` for a usage error.
|
|
329
|
+
|
|
330
|
+
Startup validates every entry, cron expression included, before it changes any schedule, and applies
|
|
331
|
+
all entries in one transaction, so an invalid entry leaves the stored schedules as they were.
|
|
332
|
+
Applying is idempotent: restarting re-applies every entry, updating a changed one in place. An entry
|
|
333
|
+
moved to another workflow replaces the schedule its old workflow owned. An entry removed from the
|
|
334
|
+
file has its schedule deleted at the next startup, so it stops firing -- and so does every schedule
|
|
335
|
+
of a configured workflow when the file is empty. Only schedules owned by a Ligeti
|
|
336
|
+
application (`wf:<workflow>`) are deleted or moved; another application's, and unclaimed ones, are
|
|
337
|
+
left alone, so an entry named like a schedule that belongs to another application fails startup,
|
|
338
|
+
naming the entry and the application that owns it.
|
|
339
|
+
|
|
340
|
+
The Cron runs tab (`GET /cron-runs`) lists the configured entries with the time zone each is read in and when each last fired, then the
|
|
341
|
+
runs the schedules started -- the root runs whose id starts with `sched-` -- in the Runs tab's table,
|
|
342
|
+
with the same `?page=` pagination. They do not appear on the Runs tab.
|
|
343
|
+
|
|
344
|
+
## Environment variables
|
|
345
|
+
|
|
346
|
+
Parsed by `src/settings.ts` through Zod, per
|
|
347
|
+
[ADR-0003](../../adr/0003-configuration-is-a-settings-module.md).
|
|
348
|
+
|
|
349
|
+
| Variable | Required | Default | Purpose |
|
|
350
|
+
| -------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
351
|
+
| `LIGETI_CONFIG_DIR` | no | unset (`~/Library/Application Support/ligeti` on macOS, else `$XDG_CONFIG_HOME/ligeti` or `~/.config/ligeti`) | Config directory: holds `.env`, `cron.yaml`, the attest key. Process env only, never `.env`; a relative path resolves against the cwd. |
|
|
352
|
+
| `LIGETI_DATABASE_URL` | yes | — | Postgres connection URL shared with every worker. |
|
|
353
|
+
| `LIGETI_CALLBACK_SECRET` | yes | — | At least 32 characters. Verifies callback tokens delivered to `POST /callbacks/:token`. |
|
|
354
|
+
| `LIGETI_PUBLIC_BASE_URL` | no | `http://<LIGETI_HOST>:<LIGETI_PORT>`, with `127.0.0.1` for a wildcard or unusable host | The shell's own externally reachable base URL, embedded in callback/approval URLs. Set it behind a proxy. |
|
|
355
|
+
| `LIGETI_HOST` | no | `127.0.0.1` | Interface the HTTP server binds to. |
|
|
356
|
+
| `LIGETI_PORT` | no | `8100` | Port the HTTP server listens on. |
|
|
357
|
+
| `LIGETI_WORKFLOWS` | no | default workflows (`attest-and-publish`, `small-factory`, `launch-small-factory`, `github-small-factory`, `launch-github-small-factory`), dependencies of the shell. | Comma-separated workflow package directories; replaces the default list. Relative paths resolve against the directory holding `.env`. |
|
|
358
|
+
| `LIGETI_ARGUS_URL` | no | unset | Optional dbos-argus URL, surfaced to the UI. |
|
|
359
|
+
| `LIGETI_STATE_DIR` | no | `<config directory>/state` with `LIGETI_CONFIG_DIR`; else `~/Library/Application Support/ligeti/state` (macOS) or `${XDG_STATE_HOME:-~/.local/state}/ligeti` | State directory, shared with every worker; created with mode `0700`. Relative paths resolve against the directory holding `.env`. |
|
|
360
|
+
| `XDG_CONFIG_HOME` / `XDG_STATE_HOME` | no | unset | On Linux, the base of the default config / state directory. Ignored on macOS and when not absolute; process env only, never `.env`. |
|
|
361
|
+
| `LIGETI_CRON_FILE` | no | `cron.yaml` in the config directory | Cron entries applied at `serve` startup; the default may be absent, a named file may not (see Cron entries). A relative path resolves against `.env`'s dir. |
|
|
362
|
+
| `TZ` | no | the system time zone | The time zone cron entries are read in unless they set their own `timezone` (see Cron entries). Normalised to an IANA name (see Cron entries); also forwarded to workers in that form. |
|
|
363
|
+
| `LIGETI_SUPERVISOR_INITIAL_BACKOFF_MS` | no | unset (Supervisor's own default) | Test-only escape hatch (see below); not meant for production tuning. |
|
|
364
|
+
| `LIGETI_ATTEST_SECRET` | no* | unset | At least 32 characters. Signing secret for `POST /attest`. |
|
|
365
|
+
| `LIGETI_ATTEST_KEY_FILE` | no* | unset | Path to the attestation signing key file. |
|
|
366
|
+
| `LIGETI_STEP_<NAME>_ENV` | no | unset | A step's own setting, e.g. `LIGETI_STEP_UAT_ENV`: comma-separated env var names the shell also forwards (see below). |
|
|
367
|
+
|
|
368
|
+
`*` `LIGETI_ATTEST_SECRET` and `LIGETI_ATTEST_KEY_FILE` must be set together or not at all —
|
|
369
|
+
setting only one fails startup, since attestation is either fully configured or fully disabled,
|
|
370
|
+
never half-configured.
|
|
371
|
+
|
|
372
|
+
`LIGETI_SUPERVISOR_INITIAL_BACKOFF_MS` is passed straight through to the Supervisor's own
|
|
373
|
+
`timings.initialBackoffMs`; unset keeps the Supervisor's default. It exists for tests that need a
|
|
374
|
+
worker _not_ to respawn within some observation window — for example an acceptance test proving that
|
|
375
|
+
cleanup came from the reaper, not from a just-restarted worker. That is why `.env.example` does not
|
|
376
|
+
list it.
|
|
377
|
+
|
|
378
|
+
`LIGETI_CALLBACK_SECRET` stays in the shell's own process and is never placed in a spawned worker's
|
|
379
|
+
environment. Each worker instead receives `LIGETI_CALLBACK_KEY`, derived from it per worker, so a
|
|
380
|
+
worker can mint and verify its own callback tokens without holding the secret they are derived
|
|
381
|
+
from. `src/child-env.ts` derives it; `packages/sdk`'s `settings.ts` is what reads it back.
|
|
382
|
+
|
|
383
|
+
## Installing a third-party workflow package
|
|
384
|
+
|
|
385
|
+
A workflow package published to an npm registry is installed outside the Ligeti repository and
|
|
386
|
+
added to `LIGETI_WORKFLOWS`.
|
|
387
|
+
|
|
388
|
+
1. Pick an install directory outside the repository, e.g. `~/.ligeti/workflows/`. Put a
|
|
389
|
+
`package.json` in it that pins the workflow package at an exact version (`"1.2.3"`, not a range):
|
|
390
|
+
|
|
391
|
+
```json
|
|
392
|
+
{
|
|
393
|
+
"private": true,
|
|
394
|
+
"dependencies": { "@acme/workflow-example": "1.2.3" }
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
2. If your own scopes live on a private registry, put an `.npmrc` next to it that maps each scope
|
|
399
|
+
to its registry, with the token given as an `${ENV_VAR}` reference and never as a literal.
|
|
400
|
+
`@ligeti/*` packages come from npmjs.org and need no mapping:
|
|
401
|
+
|
|
402
|
+
```text
|
|
403
|
+
@acme:registry=https://registry.example.com/npm/
|
|
404
|
+
//registry.example.com/npm/:_authToken=${ACME_REGISTRY_TOKEN}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
3. Run `npm install` there, with any token variables your own scopes need set.
|
|
408
|
+
4. Add the installed package directory, `<install dir>/node_modules/<package name>`, to
|
|
409
|
+
`LIGETI_WORKFLOWS` with `ligeti config set LIGETI_WORKFLOWS <list>`, as absolute paths: `~` is
|
|
410
|
+
not expanded, so write out the home directory. Setting it replaces the default list, so list
|
|
411
|
+
every workflow package you want the shell to run. Run `ligeti config get LIGETI_WORKFLOWS` first
|
|
412
|
+
to see the current list.
|
|
413
|
+
5. Restart the shell.
|
|
414
|
+
|
|
415
|
+
The workflow package's installed `@ligeti/sdk` major version must equal the shell's, or the shell
|
|
416
|
+
fails at startup. A Ligeti upgrade that bumps the SDK major version therefore requires reinstalling
|
|
417
|
+
a matching workflow package version.
|
|
418
|
+
|
|
419
|
+
To upgrade, run `npm install --save-exact <package>@<version>` in the install directory and restart
|
|
420
|
+
the shell.
|
|
421
|
+
Per [ADR-0016](../../adr/0016-the-dbos-sdk-version-is-pinned.md), the version
|
|
422
|
+
guard refuses to start a worker over parked runs of a different code hash, so drain or cancel
|
|
423
|
+
those runs first.
|
|
424
|
+
|
|
425
|
+
## What reaches a worker
|
|
426
|
+
|
|
427
|
+
`src/child-env.ts` builds every child's environment from an explicit list, per
|
|
428
|
+
[ADR-0027](../../adr/0027-steps-declare-env-var-requirements.md). A worker and the reaper that
|
|
429
|
+
cleans up its runs get the SDK's base list, every `LIGETI_*` variable and the env vars the workflow
|
|
430
|
+
declares, computed from the manifest: its own declaration, its steps' and its child workflows'. A
|
|
431
|
+
step's `configuredBy` setting, a `LIGETI_STEP_<NAME>_ENV` variable in the shell's environment,
|
|
432
|
+
adds the names it lists as optional; a value that is not a comma-separated list of env var names
|
|
433
|
+
fails startup. `ligeti-worker describe` gets the base list only.
|
|
434
|
+
|
|
435
|
+
The shell's own `LIGETI_ATTEST_SECRET`, `LIGETI_ATTEST_KEY_FILE`, `LIGETI_CALLBACK_SECRET`,
|
|
436
|
+
`LIGETI_DATABASE_URL` and the keys derived from them are never forwarded, whatever a workflow
|
|
437
|
+
declares (`SHELL_ENV_DENYLIST`), nor is `LIGETI_TEST_DATABASE_URL`; the shell sets each worker's
|
|
438
|
+
database URL and derived keys itself.
|
|
439
|
+
|
|
440
|
+
A required env var that is unset or empty in the shell's environment, or on the denylist, blocks the
|
|
441
|
+
worker: it is not spawned and not retried, and `/workers` shows it as `blocked` with the missing
|
|
442
|
+
names. Fix the environment and restart the shell.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!-- ABOUTME: Operator-facing recovery procedures for problems that show up while running Ligeti, -->
|
|
2
|
+
<!-- ABOUTME: as opposed to design rationale, which lives in adr/ and the rest of docs/. -->
|
|
3
|
+
|
|
4
|
+
# Troubleshooting
|
|
5
|
+
|
|
6
|
+
## Blocked worker (version guard)
|
|
7
|
+
|
|
8
|
+
A worker refuses to start (`state: blocked`, exit code 78) if its `codeHash` (source, non-`dist/`
|
|
9
|
+
published files, and dependency versions -- see `computeCodeHash`) has changed while a run for
|
|
10
|
+
that workflow is still parked mid-flight: resuming it under different code could replay a step
|
|
11
|
+
non-deterministically. `ligeti serve`'s own stderr names the parked run ids; the Workers tab
|
|
12
|
+
(at `/workers`) also shows `blocked` for that workflow. See
|
|
13
|
+
[ADR-0016](../adr/0016-the-dbos-sdk-version-is-pinned.md) for why the guard exists.
|
|
14
|
+
|
|
15
|
+
**A blocked worker only ever retries on a `ligeti serve` restart** -- it never polls or
|
|
16
|
+
self-heals in the background, so leaving it blocked and waiting accomplishes nothing.
|
|
17
|
+
|
|
18
|
+
To recover:
|
|
19
|
+
|
|
20
|
+
1. Inspect the parked run ids listed in `ligeti serve`'s stderr (or on the Workers tab).
|
|
21
|
+
2. Either:
|
|
22
|
+
- **Revert the code change** and restart `ligeti serve` (`Ctrl-C`, then `pnpm serve` again)
|
|
23
|
+
-- the parked runs resume where they left off, or
|
|
24
|
+
- **Cancel those runs** from each run's page (accepting that they will not resume) and restart
|
|
25
|
+
`ligeti serve` -- the worker starts cleanly against the new code.
|
|
26
|
+
|
|
27
|
+
There is currently no good way out of a version-guard block beyond one of those two options; GitLab
|
|
28
|
+
issue [#21](https://gitlab.com/nagyv-projects/ligeti/-/issues/21) tracks that gap.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Rules for a Ligeti workflow or step package
|
|
2
|
+
|
|
3
|
+
The rules an outside author most often breaks, condensed from Ligeti's own `CLAUDE.md`. Each links
|
|
4
|
+
the architecture decision record that owns it; the record, not this file, is the home of the rule
|
|
5
|
+
and has the argument and the exceptions. `@ligeti/eslint-plugin` enforces most of them: the
|
|
6
|
+
templates' `eslint.config.js` turns the presets on, and `pnpm lint` fails on a breach.
|
|
7
|
+
|
|
8
|
+
ADR links go to `https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/`.
|
|
9
|
+
|
|
10
|
+
## Workflow packages
|
|
11
|
+
|
|
12
|
+
- **A workflow body is deterministic.** Inside `run`, no `fs`, no `child_process`, no
|
|
13
|
+
`process.env`, no `Date.now()` or `Math.random()`, no `fetch`, and no `try`/`catch`. Reach the
|
|
14
|
+
outside world through a step, and the clock and randomness through `ctx.now()` and `ctx.uuid()`.
|
|
15
|
+
Start steps concurrently only where their start order is the same on every replay. To react to a
|
|
16
|
+
failed child workflow use `ctx.child(...).outcome()`, not `catch`.
|
|
17
|
+
[ADR-0002](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0002-workflow-bodies-are-deterministic.md)
|
|
18
|
+
- **A workflow's schema lives in its code.** Input and output are Zod schemas on `defineWorkflow`;
|
|
19
|
+
the manifest is generated from them, never written by hand. Every output carries a `runOutcome`,
|
|
20
|
+
and a run that returns ends with a `done` status carrying the same value.
|
|
21
|
+
[ADR-0013](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0013-a-workflows-schema-lives-in-its-code.md)
|
|
22
|
+
|
|
23
|
+
## Workflow and step packages
|
|
24
|
+
|
|
25
|
+
- **`process.env` is read in `settings.ts` only**, through a Zod schema, behind a
|
|
26
|
+
`load<X>Settings(env: NodeJS.ProcessEnv = process.env)` function. Production never passes `env`;
|
|
27
|
+
tests always do. Every settings field carries a sensitivity (`secret` or `public`), and
|
|
28
|
+
`ligeti config` never shows a secret.
|
|
29
|
+
[ADR-0003](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0003-configuration-is-a-settings-module.md),
|
|
30
|
+
[ADR-0028](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0028-env-vars-are-secret-or-public-and-ligeti-config-never-shows-a-secret.md)
|
|
31
|
+
- **A step declares its env var requirements.** `envVars: { required, optional, public, configuredBy }`
|
|
32
|
+
is mandatory on `defineStep` and `defineResourceStep` (`{}` is a valid declaration). The shell
|
|
33
|
+
forwards a worker exactly the union its steps declare, and a step gives a spawned process only
|
|
34
|
+
what it declared, built with `buildSpawnEnv`. A test with `settingsEnvVarProblems` from
|
|
35
|
+
`@ligeti/sdk/testing` keeps `settings.ts` and `envVars` in step.
|
|
36
|
+
[ADR-0027](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0027-steps-declare-env-var-requirements.md)
|
|
37
|
+
- **Spawn with an argv array and an environment you built.** Never `exec`, never `shell: true`, never
|
|
38
|
+
the parent's environment forwarded wholesale. A bounded `execFile` call passes an explicit
|
|
39
|
+
`timeout`.
|
|
40
|
+
[ADR-0004](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0004-child-processes-take-argv-and-an-explicit-environment.md)
|
|
41
|
+
- **Log through the contextual logger** (`sctx.logger` in a step). Never `console`.
|
|
42
|
+
[ADR-0011](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0011-logging-goes-through-the-contextual-logger.md)
|
|
43
|
+
|
|
44
|
+
## Step packages
|
|
45
|
+
|
|
46
|
+
- **A step throws on failure.** Do not invent a `{ ok: false }` return. Wrap the cause in an
|
|
47
|
+
`Error` with `{ cause }`; a named `Error` subclass is for a caller that must `instanceof` it.
|
|
48
|
+
[ADR-0005](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0005-steps-throw-results-are-for-expected-traffic.md)
|
|
49
|
+
- **Every step declares `retry`, and a step with a side effect makes it safe to repeat.** There is
|
|
50
|
+
no default retry, and a step may be retried or replayed from a checkpoint. A step that only reads
|
|
51
|
+
takes a few attempts. A step that creates something outside Ligeti (a process, a remote job) is a
|
|
52
|
+
`defineResourceStep`, whose reserve, find-or-spawn and finalize sequence the SDK implements once.
|
|
53
|
+
A plain step whose effect would repeat makes the effect idempotent itself or sets
|
|
54
|
+
`retry: { maxAttempts: 1 }`.
|
|
55
|
+
[ADR-0015](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0015-resource-steps-are-idempotent-and-steps-declare-retry.md)
|
|
56
|
+
- **A step package exports through one `src/index.ts` barrel**, with named exports only. A workflow
|
|
57
|
+
package's `src/workflow.ts` is its one entry and the one file with a default export
|
|
58
|
+
(`export default defineWorkflow({...})`). Object shapes are `interface`s; `type` is for
|
|
59
|
+
`z.infer<>` aliases and unions.
|
|
60
|
+
[ADR-0009](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0009-module-and-file-conventions.md)
|
|
61
|
+
|
|
62
|
+
## Tests
|
|
63
|
+
|
|
64
|
+
- **Never `vi.mock`.** A test double is a real executable or a real local server that the code under
|
|
65
|
+
test reaches over its actual interface (argv, exit code, stdout, a socket), redirected through an
|
|
66
|
+
environment variable or an injected URL. `@ligeti/testing` ships real doubles for `claude`, `herdr`,
|
|
67
|
+
GitLab, GitHub, Bitbucket, Jira and Telegram, and a throwaway Postgres.
|
|
68
|
+
[ADR-0007](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0007-test-doubles-are-real-processes.md)
|
|
69
|
+
- **A business rule is a Gherkin `Rule:` with `Example:`s** in a `.feature` file next to the test
|
|
70
|
+
that runs it, through `@amiceli/vitest-cucumber`, not a comment or prose.
|
|
71
|
+
[ADR-0021](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0021-requirements-live-in-feature-files-comments-are-allowlisted.md)
|
|
72
|
+
|
|
73
|
+
## Files and comments
|
|
74
|
+
|
|
75
|
+
- **Every source file starts with two `// ABOUTME:` lines** saying what the file does.
|
|
76
|
+
[ADR-0009](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0009-module-and-file-conventions.md)
|
|
77
|
+
- **A code comment is only ever** the two `ABOUTME:` lines, a tool directive that states its reason
|
|
78
|
+
(`eslint-disable… -- <reason>`, `@ts-expect-error -- <reason>`), or `QUIRK(<tool>): <one sentence> <URL>`
|
|
79
|
+
for behaviour of an external tool that no name, type or test can express. Everything else goes where it belongs:
|
|
80
|
+
what a block does becomes a named function, what a field means becomes a Zod `.describe()`, why a
|
|
81
|
+
step is safe to retry becomes a test named after the reason, a rule becomes a `.feature` file.
|
|
82
|
+
The `ligeti/no-comments` lint rule enforces it.
|
|
83
|
+
[ADR-0021](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0021-requirements-live-in-feature-files-comments-are-allowlisted.md)
|
|
84
|
+
- **Every package has a `README.md`** stating what it is, what it exposes (inputs and output, or
|
|
85
|
+
steps), and its environment variables as a table or "None.".
|
|
86
|
+
[ADR-0021](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0021-requirements-live-in-feature-files-comments-are-allowlisted.md)
|
|
87
|
+
|
|
88
|
+
## Where the package lives
|
|
89
|
+
|
|
90
|
+
- **A workflow made for one product lives in that product's repository** and is installed into
|
|
91
|
+
Ligeti as a third-party workflow package. `@ligeti/*` packages are public contracts, so depend on
|
|
92
|
+
a major you can accept and expect a breaking change only in a major.
|
|
93
|
+
[ADR-0025](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0025-published-packages-are-public-contracts-product-workflows-live-in-their-product.md)
|