Repository navigation
crates: install per-project worker packages with nix - #244
Merged
Merged
Conversation
A project lists nixpkgs packages on a Worker packages card. When the list is non-empty, every agent and checks run of that project starts its command inside `nix shell nixpkgs#<a> nixpkgs#<b>`, so a stdio MCP server finds what it needs on PATH. The scheduler reads the list on every run. A fixed bash wrapper builds the packages first and exits with code 86 when that fails. An agent run then fails with a reason that names the worker packages, and a checks run is a checks error, not a checks failure. The design doc gains a Worker packages row and the playwright-mcp recipe.
The ast-grep rule no-inline-tests forbids tests under src/, so the validation tests move to the dashboard tests and post to the card.
The wrapper takes a package count instead of a -- separator, so no package name can collide with the command. The command touches a marker file when it starts. Exit 86 now means the setup failed before the command ran, and a command that exits 86 itself is reported as 1.
moonthebot
force-pushed
the
factory/job-76-pr-5
branch
from
November 23, 2026 22:00
56fec1e to
84cb1fd
Compare
A marker file in the temporary directory could be erased by the command's own cleanup, which reported a setup failure. The wrapper now holds a deleted file open on a descriptor, which leaves nothing behind.
A failed mktemp, descriptor setup or unlink let the command run and then reported a setup failure. The wrapper now exits 86 before nix shell, and the inner shell execs the command only after the start signal is written.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A stdio MCP server such as playwright-mcp needs tools in the worker, for example a browser. The worker image has none, and baking them in would grow it for every project. A project now lists nixpkgs packages on a "Worker packages" card. Its agent and checks runs then execute inside
nix shell nixpkgs#<a> nixpkgs#<b> --command ....The runner wraps the backend command in a bash script. The script takes a package count, then that many package names as argv elements, then the command. A count ends the list, so no package name can collide with a separator. The script builds the packages with
nix build --no-linkand exits 86 if that fails. It then creates a temporary file, holds it open on a descriptor and deletes it, and exits 86 if any of those steps fails. The command writes a line to that file and runs only if the write succeeds. Cleanup of temporary files by the command cannot erase the signal, and nothing is left on disk. Ifnix shellends without that line, the script also exits 86. Otherwise it passes on the command's exit code, and a command that exits 86 itself becomes 1. So 86 always means setup failed, and a checks command that exits 86 is stillChecksFailed. With an empty list the arguments are unchanged. Checks usebash -cinstead ofbash -lcwhen packages are present, because the image's/etc/profileresetsPATHfor a login shell.The server stores the list in a new
project_packagestable and reads it on every run. It validates names (at most 128 bytes, at most 32 entries, duplicates collapsed) and answers 400 with the bad entry.Docs
docs/design.md: a Worker packages row that describes the count and descriptor protocol, the Project registry and Settings layout rows, the Architecture block, and a new "Recipe: playwright-mcp" section.Verification
nix develop -c just lintpassed.nix develop -c cargo test -p factory-runner --test github wrapperpassed. It executes the generated wrapper under a fakenixfor a build failure, anix shellfailure, command exits of 3 and 86, a command that deletes temporary files before exiting 3, a missing temporary directory (the command must not run), and a package named--. It also checks that no marker file is left behind.nix develop -c just testandnix develop -c just e2e(167 tests) passed before the wrapper changes. Those changes touch only the runner wrapper.