@sjawhar/claude-envoy 4.11.0 → 4.11.2

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.
Files changed (69) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.omp-plugin/plugin.json +1 -1
  3. package/AGENTS.md +43 -497
  4. package/dist/codex-hook.js +2076 -2042
  5. package/dist/dispatch.js +2106 -2050
  6. package/dist/envoy-channel.js +2077 -2043
  7. package/dist/session-hook.js +2076 -2042
  8. package/legion/skills/legion-architect/SKILL.md +88 -66
  9. package/legion/skills/legion-architect/references/acceptance.md +89 -258
  10. package/legion/skills/legion-architect/references/decomposition.md +94 -213
  11. package/legion/skills/legion-architect/references/design-gate.md +88 -353
  12. package/legion/skills/legion-architect/references/wake-routing.md +51 -43
  13. package/legion/skills/legion-controller/SKILL.md +50 -181
  14. package/legion/skills/legion-controller/references/admission.md +25 -54
  15. package/legion/skills/legion-controller/references/backlog-stewardship.md +23 -119
  16. package/legion/skills/legion-controller/references/consolidation.md +9 -93
  17. package/legion/skills/legion-controller/references/daily-report.md +21 -99
  18. package/legion/skills/legion-controller/references/escalation.md +16 -118
  19. package/legion/skills/legion-controller/references/finding-asks.md +31 -162
  20. package/legion/skills/legion-controller/references/park-asks.md +33 -0
  21. package/legion/skills/legion-controller/references/parked-decisions.md +20 -264
  22. package/legion/skills/legion-controller/references/session.md +26 -84
  23. package/legion/skills/legion-controller/references/slack-mentions.md +18 -134
  24. package/legion/skills/legion-controller/references/triage.md +18 -89
  25. package/legion/skills/legion-controller/references/wakes.md +22 -549
  26. package/legion/skills/legion-controller/references/weekly-audit.md +9 -90
  27. package/legion/skills/legion-oracle/SKILL.md +19 -28
  28. package/legion/skills/legion-retro/SKILL.md +54 -93
  29. package/legion/skills/legion-retro/references/learnings.md +21 -33
  30. package/legion/skills/legion-retro/references/pr-body-content.md +21 -37
  31. package/legion/skills/legion-worker/SKILL.md +50 -64
  32. package/legion/skills/legion-worker/references/ci-checks.md +16 -84
  33. package/legion/skills/legion-worker/references/conflicts-and-rewrites.md +34 -93
  34. package/legion/skills/legion-worker/references/default-branch-check.md +22 -60
  35. package/legion/skills/legion-worker/references/findings.md +25 -180
  36. package/legion/skills/legion-worker/references/foreign-path.md +14 -22
  37. package/legion/skills/legion-worker/references/gvisor.md +20 -0
  38. package/legion/skills/legion-worker/references/merge-gate.md +43 -419
  39. package/legion/skills/legion-worker/references/plan-tests.md +8 -28
  40. package/legion/skills/legion-worker/references/pr-body.md +19 -218
  41. package/legion/skills/legion-worker/references/review-threads.md +16 -70
  42. package/legion/skills/legion-worker/references/tools.md +31 -578
  43. package/legion/skills/legion-worker/references/withheld-capability.md +12 -163
  44. package/legion/skills/simplify-settled-diff/SKILL.md +23 -41
  45. package/legion/skills/simplify-settled-diff/references/personas/code-quality-reviewer.md +14 -14
  46. package/legion/skills/simplify-settled-diff/references/personas/code-reuse-reviewer.md +4 -4
  47. package/legion/skills/simplify-settled-diff/references/personas/efficiency-reviewer.md +8 -8
  48. package/package.json +1 -1
  49. package/skills/agent-secrets/SKILL.md +46 -312
  50. package/skills/agent-secrets/references/store-a-secret.md +9 -0
  51. package/skills/approval-review/SKILL.md +20 -76
  52. package/skills/asd-ste100/SKILL.md +43 -85
  53. package/skills/asd-ste100/examples/before-after.md +18 -53
  54. package/skills/dispatch/SKILL.md +1 -1
  55. package/skills/dispatch-writing-specs/SKILL.md +1 -1
  56. package/skills/envoy/SKILL.md +56 -126
  57. package/skills/envoy/references/check-settlement.md +26 -43
  58. package/skills/envoy/references/deliveries.md +26 -144
  59. package/skills/envoy/references/legion.md +12 -45
  60. package/skills/envoy/references/roles.md +11 -9
  61. package/skills/envoy/references/sources.md +13 -25
  62. package/skills/outside-message/SKILL.md +24 -81
  63. package/skills/plain-words/SKILL.md +24 -55
  64. package/skills/thermonuclear-code-quality/SKILL.md +16 -26
  65. package/skills/thermonuclear-deep-review/SKILL.md +22 -31
  66. package/legion/skills/legion-worker/references/cleanup-deletion.md +0 -22
  67. package/legion/skills/legion-worker/references/systematic-rename.md +0 -19
  68. package/skills/asd-ste100/references/writing-rules.md +0 -59
  69. package/skills/plain-words/references/mechanics.md +0 -49
@@ -1,608 +1,61 @@
1
1
  # Getting the tool your work needs
2
2
 
3
- Part of `skill://legion-worker`. Read it before you read a shared database, a session store or
4
- another role's transcript among them; before you run a build or a test suite in your pod; the
5
- moment your phase needs a tool the worker image may not carry — a database client, a linter, a
6
- one-off CLI — before you install, download, or vendor anything; before you measure Oh My Pi's
7
- binary; and when a test fails in your pod. Every path it cites is in cybermonklabs/legion.
3
+ Read it before you run a build or tests in your pod, read a shared database, reach for a tool the image may not carry, or measure Oh My Pi's binary, and when a test fails in your pod.
8
4
 
9
5
  ## What runs in your pod, and what runs on the pull request
10
6
 
11
- An issue pod runs no heavy build and no whole test suite. The pod's six roles share one memory
12
- limit. Near that limit the launcher's memory guard, where the deployment runs it (it is on by
13
- default), stops, with SIGKILL, the largest process that is neither Legion's own nor an agent's own,
14
- which in practice is a command an agent ran: a build, a test binary, a Python or JavaScript kernel.
15
- It then tells that process's role why, in a message on the role's topic. In a pod that runs in a
16
- microVM, the pod's own kernel stops such a command in place of the guard where each of the pod's
17
- requests equals its limit, and the role is told the same way; in a pod that requests less, it can
18
- stop an agent instead. The command fails and the turn goes on. In a gVisor pod, a command that
19
- fills the memory faster than the guard can stop it still takes the pod past its limit, and that
20
- ends every role's turn, not only yours.
7
+ - The issue's roles share one pod memory limit. In a gVisor pod, where the deployment runs the launcher's memory guard (it is on by default), the guard SIGKILLs near that limit the largest process that is not Legion's or an agent's, usually your command, and tells your role why; a faster fill ends every role's turn. In a microVM pod the pod's own kernel stops such a command instead (an agent too, where the pod requests less than its limit), and your role is told the same way.
8
+ - In the pod: compile what you touched, run the tests you added or changed by name (`go test -run '<TestName>' ./internal/<package>/`, `bun test <files>`), build the program a check drives, and `go vet -tags e2e ./...`. For the race detector prefix `CGO_ENABLED=1`; the image sets it to 0.
9
+ - A whole module's test run (`go test ./...`), a whole Postgres-backed package, a browser suite run whole, and `make -j` or `lake build` go to CI on the pull request. Every other heavy run goes where your deployment's instructions say.
21
10
 
22
- In the pod you compile the packages your change touches, run by name the tests you added or
23
- changed (`go test -run '<TestName>' ./internal/<package>/`, or `bun test` with their files), build
24
- the program a check of your issue drives (`go build ./cmd/legion`), and vet the module you changed
25
- (`go vet -tags e2e ./...`, which compiles and runs no test). To run Go's race detector, prefix the command with
26
- `CGO_ENABLED=1`: `CGO_ENABLED=1 go test -race -count=1 -run '<TestName>' ./internal/<package>/`.
27
- The worker image sets `CGO_ENABLED=0` and carries gcc (both in
28
- `packages/daemon/docker/worker.Dockerfile`), and Go refuses `-race` without cgo.
11
+ ## The disk your pod works on
29
12
 
30
- A whole module's or whole package's test run goes to CI on the pull request, where a job of that
31
- pull request runs it: `go test ./...`, a whole Postgres-backed package such as
32
- `packages/envoy/internal/dispatch/docs` or `packages/envoy/internal/dispatch/api`, a browser suite
33
- run whole, and `make -j` or `lake build` in a repository your deployment sends you to. Every other
34
- heavy run goes where your deployment's instructions say.
13
+ - One volume at `/legion` holds the clone, every workspace, `$TMPDIR` and the caches, shared by the issue's roles. Your home and `/tmp` are on the node's small disk, whose limit evicts the pod. Read free space with `df -h /legion`.
14
+ - A cache trimmer sweeps at 85 per cent used toward 70 (the defaults), oldest first. It deletes only `$TMPDIR/go-build<digits>` directories, `-a` and `-d` entries of `/legion/go/build`, directories directly under `/legion/scratch/cache` but `ms-playwright` and `legion-claude-code`, and directories directly under `/legion/scratch/bun/install/cache`. It skips anything open or changed in the last fifteen minutes, and deletes nothing a role put anywhere else.
15
+ - `$TMPDIR` is yours to clean: nothing else deletes what you leave there, and it fills the volume for every role. Delete the paths you made, each by its exact path.
16
+ - Chain a command that enters a scratch directory with `&&` (`cd -- "$TMPDIR/probe" && ./run.sh`): after a failed `cd`, `;` runs the command where the shell last stood, often the shared workspace.
35
17
 
36
18
  ## The database your tests use
37
19
 
38
- - Never give a test, a migration or anything that creates or drops a database the URL in the
39
- file `OMP_SESSION_SQL_DSN_FILE`: that is the live sessions database every pod shares, and it
40
- holds every role's transcript.
41
- - Give every Postgres variable a test reads `$LEGION_TEST_PG_DSN`, your pod's own server:
42
- `LEGION_TEST_PG_DSN`, `DISPATCH_TEST_DATABASE_URL` and `BROKER_TEST_DATABASE_URL`. Most suites
43
- make and drop one of their own per test on that server — a database through `internal/testpg`,
44
- a schema through `internal/broker/store/storetest`'s `URL` — so your pod's roles can share the
45
- server. Four write the database the URL itself names instead, and take a database of their own
46
- from the next bullet's `createdb` line: `packages/envoy/internal/broker/store`, whose
47
- `store_test.go` helpers call `Open(ctx, testDatabaseURL(t))` and then `Migrate` on the database
48
- `BROKER_TEST_DATABASE_URL` names; and three that open the database `DISPATCH_TEST_DATABASE_URL`
49
- names and migrate it, `packages/envoy/internal/dispatch/store` (`openTestStore`, in its
50
- `store_test.go`), `packages/envoy/internal/dispatch/delivery` (`deliveryTestPool`, which also
51
- deletes every delivery table's rows) and `packages/envoy/internal/dispatch/redeliver`
52
- (`redeliverTestLeases`).
53
- - Anything that migrates into the database its DSN names, rather than making one per test, needs
54
- a database of your own, because a sibling role writing the same one collides with you: the
55
- Dispatch browser suite's `DATABASE_URL`, which resets what it is given, and the stage scripts'
56
- `LEGION_E2E_PG_DSN`, which a daemon's `postgres_dsn` becomes and migrates Legion's schema into.
57
- Make one and point the variable at it:
58
- `createdb -h 127.0.0.1 -p 5433 -U legion_test "e2e_$(date +%s)"`.
59
- The DSN's own database is owned by your login and writable, so what keeps two roles out of it is
60
- this rule rather than the server. `packages/daemon/internal/daemon` is the third case, whose
61
- `TestMain` takes one database for the package's run through `internal/testpg/testdb`.
62
- Empty the served database by dropping your own suite's schemas and your own objects in `public`,
63
- never `public` itself: `vector` goes with it, your login may not create it again, and
64
- `ensure` only ever installs it at a database's creation.
65
- - The server is empty in every new pod and dies with it. Every database made from `template1`
66
- has pgvector.
67
- - `LEGION_TEST_PG_DSN` set and the connection refused: that is not yours to repair. Starting the
68
- server is the roles container's launcher's job — it runs `legion-testpg ensure` before any role
69
- starts and again every 15 seconds — so wait about that interval and try again. Never start a
70
- server of your own beside it, and never reach for another DSN. Still refused after that wait:
71
- report it, with the error you got, the port you used and the server's log lines from the minute
72
- it failed (next bullet), as a fault of the pod rather than of your change.
73
- - The server's log is the read-only file `$LEGION_TEST_PG_LOG` names
74
- (`tail -n 200 "$LEGION_TEST_PG_LOG"`). For every connect the server takes, the process it starts
75
- for it writes a `connection received: host=127.0.0.1 port=<client port>` line, then
76
- `connection ready` with the setup and fork times, and a `disconnection` line at the end. A
77
- connect that failed with lines of its own failed in the server, and the log says why; one the
78
- server could not start a process for leaves `could not fork new process for connection`
79
- instead. A connect with neither line at the time it failed never reached the server: a burst of
80
- more connects at once than the server's listen queue (about 940) is dropped before the server
81
- sees it, and libpq reports such a connect as `server closed the connection unexpectedly` or
82
- waits until its own timeout. Open the connections in smaller steps, or retry them. Your login
83
- holds `pg_monitor`, so `pg_stat_activity` also shows the detail of connections under the other
84
- logins of the server, such as the ones a suite creates. `LEGION_TEST_PG_LOG` unset: a server
85
- you started yourself (next bullet) logs to `$LEGION_TESTPG_DIR/server.log`; with the DSN your
86
- pod set and no such variable, your pod's image predates the log, so report without it.
87
- - `LEGION_TEST_PG_DSN` unset: your deployment has not turned the pod's server on, so no launcher
88
- is starting one and nothing will appear while you wait. With `legion-testpg` on `PATH`, start
89
- one yourself on the issue's volume: the directory it defaults to is a 1 MiB filesystem your
90
- role's own mounts cover, so `export LEGION_TESTPG_DIR=$XDG_DATA_HOME/testpg` first, then
91
- `export LEGION_TEST_PG_DSN=postgres://legion_test@127.0.0.1:5433/legion_test?sslmode=disable`
92
- and `legion-testpg ensure`, which makes the cluster, the role, `vector` in `template1` and the
93
- database the DSN names, owned by that role. That
94
- server lives in your generation: it dies when your generation ends, which takes a sibling
95
- role's connections and databases with it mid-test, and the next `ensure` of either role finds
96
- the same cluster on disk and serves it again. With no `legion-testpg` either, stand up one with
97
- the harness of `skill://legion-worker/references/withheld-capability.md` (**The worked case**)
98
- and set the DSN.
20
+ - Never give a test, a migration or anything that creates or drops a database the URL in `OMP_SESSION_SQL_DSN_FILE`: it is the live sessions database every pod shares.
21
+ - Give `LEGION_TEST_PG_DSN`, `DISPATCH_TEST_DATABASE_URL` and `BROKER_TEST_DATABASE_URL` the value of `$LEGION_TEST_PG_DSN`, your pod's own server. Most suites make their own database per test. These migrate the database the URL names, so give each a database of your own: `packages/envoy/internal/broker/store` and `packages/envoy/internal/dispatch/{store,delivery,redeliver}`, the Dispatch browser suite's `DATABASE_URL` and the stage scripts' `LEGION_E2E_PG_DSN`. Make one with `createdb -h 127.0.0.1 -p 5433 -U legion_test "e2e_$(date +%s)"`.
22
+ - Empty a database by dropping your own schemas and objects, never `public`, which takes `vector` with it.
23
+ - Connection refused: the launcher runs `legion-testpg ensure` every 15 seconds, so wait and retry, and never start a second server. Still refused: report the error, the port and `tail -n 200 "$LEGION_TEST_PG_LOG"` as a fault of the pod. A connect with no `connection received` log line never reached the server: open fewer connections at once.
24
+ - `LEGION_TEST_PG_DSN` unset, with `legion-testpg` on `PATH`: `export LEGION_TESTPG_DIR=$XDG_DATA_HOME/testpg LEGION_TEST_PG_DSN='postgres://legion_test@127.0.0.1:5433/legion_test?sslmode=disable'`, then `legion-testpg ensure`.
99
25
 
100
26
  ## Reading a shared database
101
27
 
102
- A shared database is one outside your pod: the deployment's sessions database, another team's
103
- database, any server whose other clients your role cannot stop. Your pod's own test server
104
- (`$LEGION_TEST_PG_DSN`, above) is not one of them, because it dies with your pod.
28
+ Read a database outside your pod through the read-only login whose URL is in the file `SESSION_READER_DSN_FILE` names. Never read it through the session URL the file `OMP_SESSION_SQL_DSN_FILE` names. Keep read-only inside one transaction (`BEGIN READ ONLY; … COMMIT;`, or `psql "$URL" --single-transaction -q -X -v ON_ERROR_STOP=1 -c 'SET TRANSACTION READ ONLY' -f <file>` with no `COMMIT` in the file): a session-wide setting stays on the pooled backend and fails the next client's writes. With no reader URL, report it as a fault of the deployment.
105
29
 
106
- - Read it through the deployment's read-only login. Where the deployment gives one, its URL is in
107
- the file `SESSION_READER_DSN_FILE` names.
108
- - Never read it through the session URL the file `OMP_SESSION_SQL_DSN_FILE` names. That URL is the
109
- one the role's own agent writes its transcript with, so a read through it puts a write-capable
110
- connection on a shared server for a read.
111
- - Keep the read-only setting inside one transaction, never on the connection for its whole life. A
112
- read-only setting made for the whole session stays on the backend after the connection goes back
113
- to the pool. The next client of that pool gets it, and that client's writes fail.
30
+ ## What the image carries
114
31
 
115
- These three forms do it. Each one holds the transaction read-only, so a write inside it is
116
- refused, and each one drops that state when the transaction ends.
32
+ - `command -v psql redis-cli sqlite3 nc dig unzip yq legion-testpg` shows which your digest has. `yq` is mikefarah's v4, not Debian's Python `yq`.
33
+ - `command -v gcloud bq az mise tmux busybox` shows the cloud CLIs and rig tools. `gsutil` is not on `PATH`; `az` is a wrapper that defaults `REQUESTS_CA_BUNDLE` to Debian's roots; run `busybox <applet>`, and download nothing with `busybox wget`, which checks no certificate.
117
34
 
118
- ```sql
119
- BEGIN READ ONLY;
120
- SELECT path FROM omp_session_files ORDER BY path LIMIT 1;
121
- COMMIT;
122
- ```
35
+ ## A tool the image lacks
123
36
 
124
- ```sql
125
- BEGIN;
126
- SET LOCAL transaction_read_only = on;
127
- SELECT path FROM omp_session_files ORDER BY path LIMIT 1;
128
- COMMIT;
129
- ```
130
-
131
- ```sh
132
- psql "$URL" --single-transaction -q -X -v ON_ERROR_STOP=1 -c 'SET TRANSACTION READ ONLY' -f <file>
133
- ```
134
-
135
- `-q` keeps psql's `SET` status line off stdout. Without it psql prints that line, and it becomes
136
- the first line of a file you redirect the output into. `-X` keeps your `~/.psqlrc` out of the
137
- run, and `ON_ERROR_STOP` ends the run at the first error. The file holds no `COMMIT` or
138
- `ROLLBACK` of its own: one would end the read-only transaction early, and every statement after
139
- it would run outside it.
140
-
141
- Your deployment may give no `SESSION_READER_DSN_FILE`. Then read nothing of a shared database
142
- through the session URL. Read your deployment's instructions for the route they give, and when
143
- they name none, report it as a fault of the deployment rather than reaching for the writer URL.
144
-
145
- ## The five clients the image already carries
146
-
147
- Check this list first: the worker image carries these five from the change that added them onward,
148
- and they are on a role's `PATH` once its deployment pins a digest at or after that change — a role
149
- still on an older digest finds none of them. Run `command -v psql redis-cli sqlite3 nc dig` to see
150
- which you have; those need no runner. `command -v legion-testpg` says whether your digest also
151
- carries the pod's own PostgreSQL server (the section above).
152
-
153
- - `psql` — the Dispatch browser suite (`bun run e2e`) resets its database for every spec through
154
- `packages/dispatch/e2e/psql.ts`, which `seed.ts` calls, and the local stack (`bun run
155
- dispatch:local`, `packages/dispatch/e2e/local-instance.ts`) refuses to start without `go`,
156
- `psql`, `flock`, `openssl` and `python3` on `PATH`, and without `docker` too unless a
157
- `DATABASE_URL` is given. The image carries `go`, `flock`, `openssl` and `python3`, a
158
- `DATABASE_URL` stands in for `docker`,
159
- and `psql` was the one a role had no way to supply — so a role can run the local stack as a
160
- running build, and the specs of that suite its change touches, by file.
161
- - `redis-cli` — a Redis client, for work that reaches a Redis server.
162
- - `sqlite3` — a repository's own SQLite fixture or database has no other way to open from a shell,
163
- and Oh My Pi's own profile databases (`~/.omp/profiles/legion/agent/agent.db`, `models.db`,
164
- `history.db`) are SQLite too. Your session is not one of them: it is `results.jsonl`,
165
- `state.json` and `title` under `XDG_STATE_HOME`.
166
- - `nc` — the reachability check you would otherwise write as an inline Python loop. The name comes
167
- from the alternatives system, so ask for `nc`, never `nc.openbsd`.
168
- - `dig` — how a role whose connection to a service name fails tells "the name does not resolve"
169
- from "the packets are dropped".
170
-
171
- ## Two more the image carries: `unzip` and `yq`
172
-
173
- Two programs beside those five ride in the image for a role's own work, and neither is a client of
174
- a service. Like the five, they are on a role's `PATH` only once its deployment pins a digest at or
175
- after the change that added them; `command -v unzip yq` says whether yours has them.
176
-
177
- - `unzip` — Debian trixie's, at `/usr/bin/unzip`: a script calls the `unzip` command by name, and
178
- no package runner in the image provides that program.
179
- - `yq` — mikefarah's `yq` 4, at `/usr/local/bin/yq`, a pinned release the build fetches and checks
180
- against a pinned SHA-256: a role's work that reads or rewrites YAML. Debian's `yq` is a different
181
- program — kislyuk's Python wrapper over `jq`, 3.4.3 in trixie — so an expression written for one
182
- does not run on the other, and a recipe you found may be written for the other one.
183
-
184
- ## Why a tool the image lacks is an image change, not an install
185
-
186
- Your role runs as an unprivileged user with no writable system prefix: `/usr/local/bin` and `/opt`
187
- are read-only, `/home` is read-only too, and `apt-get` cannot take dpkg's lock even to download.
188
- `$HOME` — `/home/legion`, the one writable directory under that read-only `/home` — is yours to
189
- write.
190
-
191
- ```text
192
- $ apt-get install -d -y postgresql-client
193
- E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
194
- ```
195
-
196
- So that writable `$HOME`, and the issue's disk, are where an install for yourself would go, and on
197
- the mechanics the answer is not a flat no: an extraction prefix under `$HOME`, with
198
- `LD_LIBRARY_PATH` set, can run some clients but not `psql` — Debian's
199
- `/usr/bin/psql` is a Perl wrapper that loads `PgCommon.pm` through Perl's own search path, which no
200
- extraction prefix is on. What rules such an attempt out is not the unpacking: it is the test of
201
- `skill://legion-worker/references/withheld-capability.md#the-test-where-it-lands-and-what-it-leaves-resolving`,
202
- and an extraction under `$HOME` fails that test's first condition whatever you scope it to,
203
- because `/home/legion` is the pod's disk rather than the issue's volume — the placement
204
- `roleEnvironment` (`packages/daemon/internal/runtime/sandbox/manifest.go`) exists to move writes
205
- off. The sanctioned extraction is the harness's: onto the issue's volume, and exported around its
206
- own commands and no further (the Dispatch e2e stack of that reference is the worked case). For
207
- everything the image does not carry, the one documented step is a pinned run through one of the
208
- three package runners it does — plus `uv run --with` when what you need is a library rather than
209
- a command — and a tool no runner reaches is an image change ("When no runner reaches it", below).
210
-
211
- ## What the withheld capability is, and what it is not
212
-
213
- What the withheld row says, the three artefacts that draw the line between it and a pinned runner
214
- form, and the worked harness case are in
215
- `skill://legion-worker/references/withheld-capability.md`: read it before you unpack, extract or
216
- install anything the image does not carry.
217
-
218
- ## The three pinned runner forms
219
-
220
- - `uvx --from <package>@<version> <command>`, for a Python tool: the distribution you pin and the
221
- command you run are named separately, because they are usually different names.
222
- `uvx --from httpie@3.2.4 http --version` prints `3.2.4`. Where the project's own name *is* its
223
- command's — checked once, never assumed — the short `uvx <name>@<version>` runs it:
224
- `uvx ruff@0.14.0 --version` prints `ruff 0.14.0`. A version that does not exist fails closed,
225
- exit 1, naming it: `uvx ruff@99.99.99
226
- --version` prints `error: No solution found when resolving tool dependencies`, with `cause:
227
- Because there is no version of ruff==99.99.99 …`.
228
- - `bunx --package <name>@<version> <binary>`, for an npm tool, naming the package and the binary
229
- separately because they differ. `bunx --package @biomejs/biome@2.6.3 biome --version` prints
230
- `Version: 2.6.3`; `bunx --package @biomejs/biome@99.99.99 biome
231
- --version` fails closed, exit 1, with `error: No version matching "99.99.99" found for specifier
232
- "@biomejs/biome" (but package exists)`.
233
- - `go run <module>@<version>`, for a Go tool. `go run github.com/nats-io/natscli/nats@v0.1.5
234
- --version` prints `v0.1.5`; a cold module cache makes the first run much slower than a warm one
235
- — budget for the cold one the first time an issue runs a Go tool. `go run
236
- github.com/nats-io/natscli/nats@v99.99.99 --version` fails closed, exit 1, with
237
- `go: github.com/nats-io/natscli/nats@v99.99.99: invalid version: unknown revision nats/v99.99.99`.
238
-
239
- ## When you need a library, not a command
240
-
241
- The three forms above run somebody else's command. When what you need is a package available to
242
- code of your own — PyYAML to read a file, not a CLI — the form is `uv run --with
243
- <package>==<version> --no-project` ahead of the program you are running:
244
-
245
- ```text
246
- $ uv run --with pyyaml==6.0.2 --no-project python -c "import yaml; print(yaml.__version__)"
247
- Installed 1 package in 12ms
248
- 6.0.2
249
- ```
250
-
251
- `--no-project` keeps it off whatever
252
- `pyproject.toml` happens to sit above your working directory, so it behaves the same wherever you
253
- type it, and `--with` takes a requirement specifier (`==<version>`), not a runner coordinate
254
- (`@<version>`). It is on the sanctioned side for the same reason a `uvx` run is: it fills
255
- `UV_CACHE_DIR` and leaves nothing another process resolves. Reaching for a command runner instead
256
- is the mistake the next section's `uvx pyyaml@6.0.2 --version` shows — uv installs the project and
257
- then finds no executable, because a library has none to find.
258
-
259
- ## Always write the exact coordinate and the exact version
260
-
261
- A pin has two halves, and a runner resolves what you asked for only when both are right:
262
-
263
- 1. **The coordinate** — the registry name the project itself publishes, scope and all:
264
- `@biomejs/biome`, not `biome`. The command's name is no evidence of the package's. Take the
265
- coordinate from the project's own published installation instructions — its documentation site
266
- or its repository's README, reached independently of the registry rather than through the
267
- registry entry of a name you guessed. That is the step, and it is the only one that establishes
268
- identity. Do it once, before the tool's first use.
269
- 2. **The version** on that coordinate.
270
-
271
- Everything a registry can tell you afterwards is corroboration, and it is worth knowing which kind
272
- each piece is.
273
-
274
- **Fields the publisher writes.** `npm view <name> version description repository.url homepage`
275
- reads what the publisher put in its own `package.json`. npm verifies none of it: a squatter closes
276
- this check by copying two strings, and a legitimate package that sets no `homepage` reads like a
277
- squat. Evidence, never proof.
278
-
279
- **A check whose evidence the subject controls is not a check.** Carry that past npm: every line
280
- below the next prompt was written by the party whose identity is in question.
281
-
282
- ```text
283
- $ npm view biome version description repository.url homepage
284
- version = '0.3.3'
285
- description = 'A simple way to manage environment variables on a per-project basis'
286
- $ npm view @biomejs/biome version description repository.url homepage
287
- version = '2.6.3'
288
- description = 'Biome is a toolchain for the web: formatter, linter and more'
289
- repository.url = 'git+https://github.com/biomejs/biome.git'
290
- homepage = 'https://biomejs.dev'
291
- ```
292
-
293
- Those two answers are *consistent with* `@biomejs/biome` being the project and `biome` being
294
- someone else's package. What settles it is biomejs.dev telling you to install `@biomejs/biome` —
295
- the site you reached without npm's help.
296
-
297
- **What a registry can attest.** npm verifies a provenance attestation when it is published, so it
298
- is the one part of an entry a publisher cannot forge by writing a string. What it proves is *build
299
- origin*: the attestation binds the artifact to the repository and workflow that built it. Presence
300
- is not identity — a squat published from its own public Actions workflow carries a genuine
301
- attestation of its own repository — so the check is to read whose build it names, and compare that
302
- with the repository the project's own documentation gave you:
303
-
304
- ```text
305
- $ npm view @biomejs/biome dist.attestations.url
306
- https://registry.npmjs.org/-/npm/v1/attestations/@biomejs%2fbiome@2.6.3
307
- $ curl -s "$(npm view @biomejs/biome dist.attestations.url)" \
308
- | jq -r '.attestations[] | select(.predicateType=="https://slsa.dev/provenance/v1") | .bundle.dsseEnvelope.payload' \
309
- | base64 -d | jq -r '.predicate.buildDefinition.externalParameters.workflow.repository'
310
- https://github.com/biomejs/biome
311
- ```
312
-
313
- That field is the SLSA v1 predicate's `buildDefinition.externalParameters.workflow`, which here
314
- reads `{"ref": "refs/heads/main", "repository": "https://github.com/biomejs/biome", "path":
315
- ".github/workflows/release.yml"}` — the repository biomejs.dev sent you to, building on its own
316
- main branch. The comparison is what makes the attestation worth anything: on its own it says only
317
- that *some* repository built these bytes. (`jq` in your bash tool is the harness's builtin, and a
318
- script gets `/usr/bin/jq`; both print this.)
319
-
320
- Its limit runs the other way: most packages publish no provenance at all — `npm view biome
321
- dist.attestations` prints nothing — so an absent attestation is no evidence of a squat.
322
-
323
- PyPI publishes attestations only for projects that release through a trusted publisher, and widely
324
- used tools do without: for `ruff 0.14.0`, `https://pypi.org/pypi/ruff/0.14.0/json` carries no
325
- `provenance` on any of its files and `https://pypi.org/integrity/ruff/0.14.0/<file>/provenance`
326
- answers 404. For a Python tool, the project's own documentation is the whole of the check.
327
-
328
- A Go module path is a domain-scoped URL, so the coordinate *is* the repository path, and you check
329
- it by going to that path. `sum.golang.org` pins a version's bytes once they are published, which
330
- stops the content changing under you later and says nothing about whether you picked the right
331
- module path in the first place.
332
-
333
- Pinning the version alone does not save you: it pins the squatter at a version, and obeys "write
334
- the version" to the letter while doing it.
335
-
336
- ```text
337
- $ bunx biome --version
338
- 0.3.3
339
- $ bunx biome@0.3.3 --version
340
- 0.3.3
341
- $ bunx --package @biomejs/biome@2.6.3 biome --version
342
- Version: 2.6.3
343
- ```
344
-
345
- Only the third runs the formatter, and what separates it from the second is the *name*, not the
346
- version. No runner exempts you from the coordinate half; each one's syntax just makes a different
347
- way of getting it wrong easy to type.
348
-
349
- - `bunx <binary>@<version>` resolves the token as an npm package name, which is why
350
- `--package <name>@<version> <binary>` exists: a bare `bunx biome@0.3.3` is a coordinate nobody
351
- checked.
352
- - `uvx <command>@<version>` does the same on PyPI, and carries it one step further: uv resolves
353
- the token as the **project**, installs that project, and only then looks for a command of that
354
- name.
355
-
356
- ```text
357
- $ uvx pyyaml@6.0.2 --version
358
- Installed 1 package in 23ms
359
- Package `pyyaml` does not provide any executables.
360
- ```
361
-
362
- Nothing there is about the version — `pyyaml` is a real project at a real version, and it is not
363
- what you meant by typing a command's name. `uvx --help` is where the distinction lives:
364
- `--from <FROM> Use the given package to provide the command`. Hence
365
- `uvx --from shellcheck-py@0.10.0.1 shellcheck --version`, which prints `ShellCheck - shell
366
- script analysis tool` and `version: 0.10.0`: the distribution and the command share no name at
367
- all.
368
- - `go run <module>@<version>` takes the coordinate as that domain-scoped URL, so a path you
369
- invented usually fails to resolve rather than running someone else's code — but a module path
370
- guessed from a binary's name is still a guess, and the checksum database will pin the wrong
371
- module's bytes as faithfully as the right one's.
372
-
373
- Nothing refuses an unpinned command: no guard, no lint and no check stops you typing a bare `bunx
374
- biome`. What you are given is a correct form and a tool that is already there, not a gate — so both
375
- halves are yours to type.
376
-
377
- ## When no runner reaches it
378
-
379
- A tool that is neither in the image nor reachable through one of the three runners is an image
380
- change: a pull request against cybermonklabs/legion that carries the same name through every site that
381
- spells it out, and those sites are not all held by a test.
382
-
383
- Do not work from a list of those sites. A list goes stale, so take them from the repository
384
- instead: grep for a client the image already carries,
385
- under both of its names — the command and the Debian package that provides it are spelled
386
- differently, and different sites spell each — and carry the new name through everything the two
387
- find.
388
-
389
- ```text
390
- $ grep -rn redis-cli
391
- $ grep -rn redis-tools
392
- ```
393
-
394
- One kind of hit wants more than a substitution: the toolchain smoke step in
395
- `packages/daemon/docker/worker.Dockerfile` runs each tool once, so a new one needs its own
396
- invocation there (`nc` and `dig` take no `--version`). The licence file the image carries at
397
- `/usr/share/doc/legion/THIRD_PARTY_NOTICES` needs no edit: its list of Debian packages is written at
398
- build time from the image's own dpkg database.
399
-
400
- Four of the files the grep finds are in Go, and those four are the gated ones: the `toolchain`
401
- name list in `packages/daemon/internal/capabilities/image.go` makes the probe require it; that
402
- row's summary in `packages/daemon/internal/capabilities/capabilities.go` has to name it, a test
403
- holding the summary to the list; the stub binaries in
404
- `packages/daemon/internal/capabilities/capabilitiestest/capabilitiestest.go` have to include it, or
405
- the capability and `probe-image` tests fail on an image that does not carry it; and
406
- `packages/daemon/internal/capabilities/image_test.go` spells the expected detail string out again.
407
- Those four are for a tool every deployment's image must carry: the `toolchain` row is the floor the
408
- probe holds every image to, not an inventory of this one, so a program this image carries need not
409
- be named there — `aws` is in the image and not in that row — and a name added to the row makes the
410
- probe refuse every other deployment's image that lacks it. `unzip` and `yq` are in none of the four.
411
-
412
- Miss one of those four and the suite is red, which is what makes them easy to find. Nothing holds
413
- a Dockerfile comment or the smoke step to anything, so a change that stops at the gated sites opens
414
- green with comments that no longer describe the image and a smoke step that never runs the new
415
- tool.
416
-
417
- So when your work needs such a tool, say so to the architect that owns your issue (`envoy_publish`
418
- to its role topic), with the tool, what your phase needs it for, and the runner forms you already
419
- ruled out. What is not the step is improvising a CLI for your own convenience — a vendored binary,
420
- a hand-rolled substitute, or an extraction prefix dropped on your own `PATH`: the architect decides
421
- whether the image change is work to schedule. An extraction a harness builds for its own runs is
422
- not improvising and is not what this rules out (the Dispatch e2e stack of
423
- `skill://legion-worker/references/withheld-capability.md`): the two cases part on its test,
424
- "The test: where it lands, and what it leaves resolving", which the convenience case fails.
425
-
426
- The operator's side of this — why the image carries those five clients rather than anything else,
427
- the five priced options with their measurements, and what the clients cost the image — is in
428
- `docs/kubernetes.md`, the subsection "The tools a role's own work needs".
37
+ 1. Run it pinned through a runner the image carries: `uvx --from <package>@<version> <command>`, `bunx --package <name>@<version> <binary>`, `go run <module>@<version>`, or for a library `uv run --with <package>==<version> --no-project <program>`.
38
+ 2. Take the package's name from the project's own documentation, never from a registry search: `bunx biome@0.3.3` runs a different package than `bunx --package @biomejs/biome@2.6.3 biome`.
39
+ 3. Never vendor a binary, write a substitute or put an extraction on your own `PATH`. A tool no runner reaches is an image change: tell the architect the tool, why you need it and the runner forms you ruled out.
40
+ 4. An image change carries the new name to every site an existing client's two names appear at (`git grep -n -e redis-cli -e redis-tools`), the smoke step of `packages/daemon/docker/worker.Dockerfile` included. Add it to the `toolchain` row of `packages/daemon/internal/capabilities/image.go` only when every deployment's image must carry it: the probe refuses an image without it.
429
41
 
430
42
  ## Before you measure Oh My Pi's binary
431
43
 
432
- Read Oh My Pi's source first, from the fork (`cybermonklabs/oh-my-pi`) at the tag `.omp-pin` names,
433
- not from upstream's version tag: the fork's release carries code upstream's does not. `.omp-pin`
434
- reads `github:cybermonklabs/oh-my-pi@<version>`, and the git tag adds a `v` in front of that text,
435
- so find it rather than type it:
436
-
437
- ```text
438
- $ git ls-remote --tags https://github.com/cybermonklabs/oh-my-pi.git 'v<version>'
439
- ```
440
-
441
- Search that source by the name of a construct or a setting, never by its value: one value is
442
- spelled in many places, and the code that sets it may spell it in none. If the module the binary
443
- names is absent at that tag, the binary is the ground truth: measure it, and say the source did not
444
- carry it. In a pod the binary (`$LEGION_OMP_PATH`) is the build the worker image was made from,
445
- and your workspace's `.omp-pin` can name another, so the tag you read may not be the build you
446
- measure: compare `"$LEGION_OMP_PATH" --version` with the pin first, and say which build each
447
- figure came from
448
- (`docs/solutions/testing/a-worker-pods-oh-my-pi-is-the-fleets-pin-not-the-branchs-fetch-the-branchs-build-and-say-which-pin-each-figure-came-from-LEGION-247.md`).
44
+ Read the source at the fork tag `.omp-pin` names (`git ls-remote --tags https://github.com/cybermonklabs/oh-my-pi.git 'v<version>'`), and compare `"$LEGION_OMP_PATH" --version` with the pin: the pod's binary can be another build. Say which build each figure came from.
449
45
 
450
46
  ## The tests your pod cannot run
451
47
 
452
- Some tests fail in a Kubernetes issue pod whatever your change, because of the pod, not the branch.
453
- A tmux pane runs on its host, and none of this holds there. Their evidence is CI's run at the head:
454
- cite that run, and name in your handoff each package the pod could not run. The cases below are
455
- the known ones, not every one: a failure they do not name is yours to explain. Several of them
456
- reach any work a pod runs, a test or a tool of your own, not a test suite alone. One habit holds
457
- them together: check the result, never the request. A call's exit code, a reported limit and a
458
- job's phase each answer a different question than the one you asked, so where you set something,
459
- read it back and refuse on a mismatch, and where you read something, confirm the tool ran. An
460
- empty result is evidence only then: a missing binary, a refused permission, or a truncated
461
- search gives you silence that reads as a clean answer, so check that the thing you counted had
462
- something to count.
463
-
464
- - **Read the summary your work wrote, never the Job's phase.** A Kubernetes Job that reports
465
- `Succeeded` says its container exited 0, and nothing more: read the artefact your work was to
466
- produce, or the log line that proves it ran, before you believe any result. Any interpreter,
467
- driver or wrapper that exits 0 when a command inside it fails leaves the Job `Succeeded` over a
468
- silent no-result, and a watcher that trusts the phase records it as a run that worked.
469
-
470
- Two habits make that phase true. Detect the failure in the text your tool prints and exit
471
- non-zero yourself, rather than passing the wrapper's exit code on. And write a verdict that
472
- matters to durable storage as it is produced, not at the end: a node can vanish soon after a
473
- pod ends, so an unpersisted log is gone even when nothing killed anything, and a
474
- terminating pod's grace period can be too short to flush.
475
-
476
- **The phase lies in the other direction too, and that one is worse.** A Job can report
477
- `Running` while its pod count is **zero**: when the quota is full, every pod create is refused
478
- (`exceeded quota …`) and the controller keeps retrying, so a watcher that reads the phase calls
479
- that build running. **The phase is a request; the pod list is the result.** If you watch
480
- a Job, watch `kubectl get pods -l batch.kubernetes.io/job-name=<job>`, or watch the marker
481
- your own work writes — never the phase alone.
482
- - **gVisor.** Every pod runs under gVisor, which does not give a test every interface the Linux
483
- kernel does. In `packages/envoy` the tests of `cmd/agent-secrets`, `cmd/agent-secrets-helper`
484
- and `internal/broker/helper` fail: the helper identifies its peer with `SO_PEERPIDFD`, which
485
- gVisor answers `protocol not available` (`PEER_UNIDENTIFIED` in the test output). The
486
- terminal-prompt tests of `cmd/agent-secrets` also need terminal job-control ioctls
487
- (`inappropriate ioctl for device`), and the `SigCgt` line of `/proc/<pid>/status`, which older
488
- gVisor releases lack. A timing test can fail too: `internal/dispatch/pmdoc`'s linearity
489
- tests time a call by the process's CPU time, which gVisor counts in 10 ms ticks, so a call under
490
- 10 ms can measure 0 s and the test reports `+Inf times`.
491
- - **`O_DIRECTORY|O_NOFOLLOW` follows a directory link under gVisor.** Almost everything matches
492
- an ordinary kernel: `O_RDONLY|O_NOFOLLOW` on a symlink to a
493
- file refuses `ELOOP`, `O_CREAT|O_EXCL|O_NOFOLLOW` on one refuses `EEXIST`, `O_PATH|O_NOFOLLOW`
494
- opens the link itself, and the controls (a regular file, a real directory, a free name) succeed
495
- on both. One call differs: `openat(dirfd, <a link to a directory>,
496
- O_DIRECTORY|O_NOFOLLOW|O_RDONLY|O_CLOEXEC)`, which the ordinary kernel refuses `ENOTDIR` and
497
- gVisor follows with no error. So code that walks a path one component at a time and opens each
498
- with `O_DIRECTORY|O_NOFOLLOW` is defeated there while every leaf check still passes, and its
499
- tests stay green on a developer's kernel. Dropping `O_DIRECTORY` changes it, because
500
- `openat(dirfd, <a link to a directory>, O_RDONLY|O_NOFOLLOW|O_NONBLOCK|O_CLOEXEC)` refuses
501
- `ELOOP` under gVisor too, relied on by `openSessionFileBeneath` in
502
- `packages/daemon/cmd/legion/sessions.go`, so what the sandbox follows is the `O_DIRECTORY`
503
- combination and not `O_NOFOLLOW` itself. A whole block of such tests failing in a pod is that
504
- one property of the environment, not one defect per test. The fix shape holds on both kernels:
505
- the walk cannot trust `O_DIRECTORY|O_NOFOLLOW` there, so it opens each component with
506
- `O_PATH|O_NOFOLLOW|O_CLOEXEC`, which opens the entry itself on both kernels, and reads the
507
- kind from fstat of that handle. The repository's own instance is `mountPointBeneath` in
508
- `packages/daemon/internal/launcher/roleinit_linux.go`. `openat2` is not the alternative
509
- there: gVisor can return `ENOSYS` for it, so the handle rule above is the portable check
510
- rather than a fallback. The question
511
- is not which tool to use but whether anything you run calls `openat2`, which you can read off
512
- the binary (two builds that report the same `--version` can differ here):
513
-
514
- ```sh
515
- b=$(readlink -f "$(command -v <tool>)")
516
- n=$(nm -D --undefined-only "$b" | wc -l)
517
- bad=$(nm -D --undefined-only "$b" | grep -c openat2 || true) # grep -c exits 1 on no match
518
- [ "$n" -gt 0 ] || { echo "no dynamic symbols: static binary or nm failed, use a tracer"; exit 2; }
519
- [ "$bad" -eq 0 ] || { echo "this binary calls openat2 and fails under gVisor"; exit 2; }
520
- ```
521
-
522
- The total count is the control: a total of zero is a static binary or a failed `nm`, not a
523
- clean result. **An undefined `openat2` symbol proves the binary calls it. Its absence proves
524
- nothing**, so the check is a positive test only: a caller can reach the syscall through
525
- `syscall(SYS_openat2, …)`, which leaves `syscall` in the table and never `openat2`, and a libc
526
- that exports no `openat2` wrapper produces the symbol for no binary at all. To establish that
527
- a binary is safe rather than suspect, trace it.
528
- - **Set the stack with `ulimit -s`, then read both limits back.** The check, not the number,
529
- is the durable part. 131072 is the number for an ordinary job; name a larger one when a tool
530
- you run polices its own limit and demands it:
531
-
532
- ```sh
533
- want=131072 # a tool with its own stack guard may demand more; use its minimum
534
- ulimit -S -s "$want" 2>/dev/null || { ulimit -H -s "$want" 2>/dev/null || true; ulimit -S -s "$want"; }
535
- { [ "$(ulimit -Hs)" = unlimited ] && ulimit -H -s "$want" 2>/dev/null; } || true
536
- soft=$(ulimit -Ss); hard=$(ulimit -Hs)
537
- [ "$soft" = "$want" ] || { echo "stack soft is $soft, want $want; refusing"; exit 2; }
538
- [ "$hard" != unlimited ] && [ "$hard" -ge "$want" ] || { echo "stack hard is $hard; refusing"; exit 2; }
539
- ```
540
-
541
- The soft limit must equal what you asked for, and the hard limit must be finite and no lower.
542
- `unlimited` is refused by name, because it reports `unlimited` and gives 8 MiB.
543
- Three things in that setter each answer a failure, and a simpler form breaks one of
544
- them. **The soft limit is set first**, because lowering the hard limit below a soft
545
- `unlimited` is `EINVAL` — `ulimit -H -s 131072` from that state fails with `cannot modify
546
- limit: Invalid argument`, and chained with `&&` the soft set never runs, so the process keeps
547
- `unlimited` and gets 8 MiB, the failure the rule exists to stop. **The hard limit is set only
548
- when it reads `unlimited`**, because setting it unconditionally lowers a higher finite hard
549
- limit the pod gave you, which is the headroom a tool with its own guard may need. The
550
- **`|| true` around it** is not decoration: on the ordinary path, where the hard limit is
551
- already finite, that test is false, and a bare `&&` list whose test fails is a non-zero exit
552
- status. `set -e` does not abort there, so the script runs to the end and does all of its work
553
- — and if that line is the last one in the file, the script exits 1 with everything correct.
554
- As a last line, `exit=1`; with `|| true`, `exit=0`; and with any command after it,
555
- `exit=0` either way, which is why it is easy to test and find nothing. And the
556
- **fallback** covers a want above the current hard limit, where the soft set fails first.
557
- From three starting states: `unlimited/unlimited` and `8192/unlimited` both end at
558
- `131072/131072`, and `131072/1048576` ends at `131072/1048576` with the higher hard limit
559
- kept. Do not reduce it to a single `ulimit -s <n>`: whether it also sets the hard limit
560
- differs from shell to shell, which is why the read-back is the rule and the setter is not.
561
- The ceiling is 128 MiB whichever finite value you choose —
562
- gVisor maps the whole stack at exec and caps it at `maxStackSize = 128 << 20` in `MapStack`
563
- (`pkg/sentry/mm/syscalls.go`), with `RLIM_INFINITY` falling back to the 8 MiB default — and a
564
- larger soft limit costs rather than buys, since glibc sizes a default thread stack from it and
565
- a tool that creates a thread pool can fail to allocate one.
566
- - **Compare durations within one pod, never across pods.** A gVisor sandbox runs syscall-heavy
567
- work several times slower than the same work outside it, and a pod lands on whatever node
568
- the autoscaler provisions, so two pods are two machines, two sets of neighbours and two
569
- moments. Three parts: within one pod, comparable — run both arms there, as two
570
- containers on one node started together, and a difference between them is a difference between
571
- the arms; across pods, not comparable; across platforms, not until something measures the gap.
572
- Label every figure taken there a gVisor figure. That factor is the cost of syscalls and no
573
- budget for a whole job: compute-bound work can run as fast or faster there.
574
- - **No Docker.** The image carries no container runtime, so a test that starts one through
575
- testcontainers panics `rootless Docker not found`: in `packages/envoy`, the tests that use
576
- `internal/tests3` (`internal/dispatch/files`, which `DISPATCH_TEST_NO_CONTAINERS=1` skips) and
577
- `internal/testpg` (unless `DISPATCH_TEST_DATABASE_URL` names a Postgres).
48
+ Cite CI's run at the head for these and name each package the pod could not run. A failure not listed is yours to explain.
578
49
 
579
- The daemon's NATS-backed tests have a way round it: `packages/daemon/internal/testnats` serves
580
- the server `LEGION_TEST_NATS_URL` and `LEGION_TEST_NATS_MONITOR_URL` name, and starts no
581
- container when both are set, so run one yourself and point them at it:
50
+ - Read what your work wrote, never a Kubernetes Job's phase: `Succeeded` means the container exited 0, and `Running` can mean zero pods under a full quota (`kubectl get pods -l batch.kubernetes.io/job-name=<job>`). A Job's harness detects the failure in the text its tool prints and exits non-zero itself, rather than passing a wrapper's exit code on, and writes a verdict that matters to durable storage as it is produced, not at the end: a node can vanish soon after its pod ends.
51
+ - gVisor lacks `SO_PEERPIDFD` and some terminal ioctls, so `cmd/agent-secrets`, `cmd/agent-secrets-helper` and `internal/broker/helper` of `packages/envoy` fail; `internal/dispatch/pmdoc`'s timing tests read `+Inf times`.
52
+ - Before you walk a path with `openat`, trust a tool's binary, set a stack limit, or report a duration measured in the pod: read `skill://legion-worker/references/gvisor.md`.
53
+ - No Docker: testcontainers panic. `DISPATCH_TEST_NO_CONTAINERS=1` skips `internal/dispatch/files`. For the daemon's NATS tests run one server per test binary and set both variables:
582
54
 
583
55
  ```sh
584
56
  go run github.com/nats-io/nats-server/v2@v2.15.1 -js -p 14222 -m 18222 -sd "$TMPDIR/nats" &
585
57
  export LEGION_TEST_NATS_URL=nats://127.0.0.1:14222 LEGION_TEST_NATS_MONITOR_URL=http://127.0.0.1:18222
586
58
  ```
587
59
 
588
- Both or neither: one set without the other fails the test rather than falling back. The
589
- monitor port is read, not decoration — the per-test reset waits there for every client
590
- connection to end, and the check at the end of each test reads it again, failing the test
591
- that leaves a client connected. One server serves one test binary at a time, so name one
592
- package a command (or pass `-p 1`): two packages' binaries on one server delete each other's
593
- streams, and each would see the other's connections as a leak.
594
- Pick ports no sibling role holds, and keep the store directory off your home. In your own
595
- work, run the NATS-backed tests your change touches by name (`go test -run`), as the first
596
- section says.
597
- - **The rest, by package**, for a named run the pod does make. A Postgres unpacked from Debian
598
- packages (the harness under **The worked case** of `withheld-capability.md`) has only the
599
- `C`, `C.utf8` and `POSIX` locales, so its default collation is byte order, and
600
- `internal/dispatch/api`'s
601
- `TestIssueRanksStayOrderedPastLowercaseDigitsAndProductionShapedMoves` refuses such a database
602
- by its own message. The pod's own `legion-testpg` server is made with ICU `en-US`, so that
603
- test runs there, as it does in CI's `envoy-go` job, whose Postgres has `en_US.utf8`.
604
- `internal/dispatch/pmdoc`'s browser-parity tests need `bun install` to have run for
605
- `@legion/proof-editor`. In the daemon's module, never export `GOWORK=off` inside
606
- `$LEGION_WORKSPACE`: `packages/daemon/go.mod` replaces `github.com/sjawhar/envoy => ../envoy`,
607
- and the go.sum entries its packages need live in `packages/envoy/go.sum`, which only the
608
- `go.work` workspace mode consults.
60
+ Each test's reset and leak check read the monitor port, so a test that leaves a client connected fails. Pick ports no other role holds.
61
+ - Never export `GOWORK=off` in `$LEGION_WORKSPACE`: the daemon's module resolves `../envoy` through `go.work`.