Plan: brush on Windows without Git Bash’s tools - our own pinned build, and grep, sed, awk and find refused by name
Closes: #772; and #652 (its pin). Relates to: #650, #753 (reversed here), #755, #757, #759, #769, #770. Branch: feat/brush-own-build. Status: N/A
Erratum (2026-11-24): brush was removed by #907.
Erratum (2026-11-10): Status is In progress. Unit 1’s first Risks row happened: upstream main at 0b6a4acc fails the 20,000-run differential on a <<E0 | a 1 >out1.txt (after a here-document tag a token’s span begins one byte early, so 1 is read as the redirection’s descriptor). The operator chose a second carried patch, tools/brush/patches/0002-heredoc-pending-token-start.patch (seven lines in brush-parser’s tokenizer and two of its span snapshots). With it the differential passes at 20,000 on panther and four times on luchs, where the unpatched control fails.
Erratum (2026-11-10): D1 and D2 as built. The Rust image ships no node, so the job first runs tools/brush/ci-setup.sh, which installs mingw-w64, the Windows target, and the node pin.json names, checked against its SHA-256. Each patch in pin.json is a file with a why saying which platform it matters on and when it can be dropped. The build also runs brush-parser’s own tests.
Erratum (2026-11-10): D9(a) runs the differential twice, under the test’s fixed CI seed and under a fresh one, so that successive builds are not all judged on the same 20,000 lines; a skipped test counts as a failure.
Erratum (2026-11-10): Risks, one more row (silent): a refused name exits 127, so inside a test of absence (if ! grep -q X f, grep -q X f || …) the refusal takes the "absent" branch and the script goes on with a wrong answer. The refusal line still reaches stderr; the trial counts such lines per session beside the refusals.
Erratum (2026-11-10): D5’s "none reaches System32" holds for a name brush itself resolves, at any depth of brush. A native child that spawns by name (node’s spawn("find")) does its own lookup: it finds a refusal stub only where it searches PATH for .cmd, and otherwise reaches System32’s program. The real-brush case asserts the first, not the second.
Erratum (2026-11-10): Out, one more line. "No Git Bash dependency" is true of the bash tool, not of git: git runs its hooks with Git for Windows' own sh, with Git’s grep and sed. The exported python3 function (D7) is imported by that sh too, harmlessly.
Erratum (2026-11-11): D5 as built. The shell directory is <agentDir>/gadhs-pi-shell/bin-<first 16 hex of the brush’s SHA-256>/, not <pin>/bin/: PI_BRUSH names a brush with no pin, and a directory named by the bytes is never shared by two brushes. It is rebuilt or repaired and then checked whole at each registration, and anything else found in it is removed. brushOperations puts it ahead of everything on the command’s PATH, WindowsApps included, which holds a second WSL bash.exe.
Erratum (2026-11-11): D4 as built. PI_WINDOWS_SHELL=brush with nothing pinned for the machine runs Git Bash and says so, rather than silently.
Erratum (2026-11-11): D7 as built. A real Store python3.exe under WindowsApps is passed over as the stub is (a listing cannot tell them apart), so python3 runs the first python on PATH.
Erratum (2026-11-11): the pinned build is brush-2, version 0b6a4acc-2. brush-1 published nothing: the differential’s own time bound (260 s at 20,000 lines) was shorter than the runner needed, fixed as #774. The job ran 52 of the project’s 60 minutes, so it needs its own timeout before a brush-3.
Erratum (2026-11-11): after the pin, the trial found brush’s bundled tail -F panicking on a drive-relative path that appears late (#779), and the operator chose to patch. tail is a crates.io dependency (uu_tail), not source in brush’s tree, so D1 gains a step: pin.json lists crates, each downloaded at the version upstream’s Cargo.lock names, checked against that lock’s checksum as read from the pinned commit, inspected, unpacked beside brush’s tree and patched; brush patch 0003 points cargo at it by a path relative to brush’s tree, so the recipe builds only in the layout tools/brush-build.mjs makes (a test holds the two equal). uu_tail publishes no tests of its follow code, so the evidence for the fix is ours: a regression case on the built binary, Windows only.
Erratum (2026-11-11): the pin moved to brush-3, version 0b6a4acc-3, the first build with the uu_tail patch (#779). Its gate: in the job, brush-parser 276 passed and the differential 4 of 4 on both seeds; on panther, from PowerShell, the real-brush suite 13 of 13 three times, rm 29 of 29, and tail -F on a late drive-relative file following in 36 trials of 36.
Erratum (2026-11-13): the pin moved to brush-7, version 751dae80-7, on upstream 751dae80 with sixteen carried patches and three crate patches; brush-4 and brush-6 were published and never pinned, and brush-5’s job died with its runner and was not retried. `brush-6 passed its gate and was held back when a row taken for the docs showed a file with no ! line run through a same-named neighbour that had one (#795, fixed by 0016); the gate had run brush without PATHEXT in its environment, which a seat always has, and now sets it. The operator’s rule for the patches: each must be a fix any brush user would want, written to go upstream, and the carrying is meant to end (#782). Two more faults were found by rehearsing the recipe in the build’s image before the tag: a text file with no ! line ran as a script (#793, fixed by 0015), and a utility built from a patched crate printed its message keys, as tail had since brush-3 (#794, fixed by fetching the locked crates before they are redirected, with a gate in the build). Its gate on panther, on the published binary (brush.exe 346312e4c7746060…): the real-brush suite, rm 29 of 29, the tail probe, 29 background shapes and 9 trap rows through pi’s chain, here-documents to 200,000 bytes in the foreground and to readers left in the background, the script and null-device rows, the messages of the three patched utilities, and pi’s own fetch end to end.
Erratum (2026-11-13): the pin moved to brush-8, version 751dae80-8: the same upstream commit with three more carried patches, nineteen in all (a shell handed /dev/null gets it as written, #791; disown, #798; on Linux, process substitutions answered for as background jobs are, #799). Its gate on panther, on the published binary (brush.exe d04468e67eb379f0…), beside the rehearsal of the tagged commit and the published 751dae80-7: the same set as for brush-7, with a table of 30 rows for the three patches; only the rows the patches mean to change differ from 751dae80-7.
Erratum (2026-11-14): the pin moved to brush-11, version 751dae80-11: the same upstream commit with twenty-three carried patches (globstar, #803; a subshell’s own EXIT trap, #804; one list of unsettled background jobs for a shell and its subshells, waited on only where the process exits, #806, #807, #808). brush-9 and brush-10 were published and never pinned: -9 hung a pipeline writing to a >(shell loop) (#808), and -10 carried a patch for exec in a subshell that ended the subshell on the unparsed {name}>file (#805), which is withdrawn. What that round changed in the method: a many-runs check under CPU load was withdrawn for a reading of the source, which found the faults the runs could not; a row with a job the shell runs itself is timed at the command, not the call; every patch re-runs every earlier table; a census leaves out the sessions of whoever is probing; and a pin is stopped by any row where the pinned build’s outcome equals bash’s and the candidate’s does not, a rule written before the result. Its gate on panther, on the published binary (brush.exe 3d5df0d2dbdbfa46…): that rule over 53 forms of exec in a subshell, no row tripping; the three faults' rows; and the earlier set, no line differing from the rehearsal of the tagged commit.
Context
Measured on panther, 2026-11-10, over 58,494 real bash calls from the 80 largest sessions since 10-25, and with brush built from upstream main at 0b6a4acc (cargo install --git … --rev … --locked, plain and with experimental-bundled-coreutils):
-
What the calls run. grep is in 53.6%, head 44.8%, sed 21.9%, tail 18.5%, awk 3.1%; find, diff, cmp and xargs under 0.5% each. All 51,727 grep uses map to
rg. Of 16,829 sed uses, 63% print a line range of a file (the read tool), 14% edit in place (the edit tool), 6% a range on a pipe (head, tail), 16% need a script. No awk use needed gawk. -
No native replacement is clean. A native tool whose runtime expands wildcards re-globs what bash quoted, because brush puts
.mdon the Windows command line bare (noraw_argin brush-core; no setting). uutils coreutils and uutils grep do this (wild::args_osin uucore):grep -F '.md' a.mdsearched fora.md. GNU sed 4.9 and grep 3.12 (MSYS2 ucrt64) write CRLF, andsed -iturns an LF file CRLF, silently. uutils sed 0.3.0 rejectss/*.md/X/. uutils find prints.\a.md. -
In-process coreutils are correct. In the bundled-coreutils build, argv never crosses a command line:
ls '*.md'is literal, pipes and redirects work, and itsrmagreed with GNUrmon 29 of 29 sandbox cases (exit code and what was removed). It adds 76 builtins (cat, head, tail, cut, wc, sort, ls, cp, mv, rm, mkdir, date, tr, uniq, tee, mktemp, sha256sum, env, …), not grep, sed, awk, find, xargs, diff, cmp, stat, chmod, timeout. -
With Git’s directories off PATH, 33.0% of calls run as written, 57.1% are stopped only by grep, sed or awk, and 10.0% name something else not found (python3 3,997, jq 673, diff 204, cmp 175, xargs 117).
-
Three names then reach a different Windows program, with no error:
findandtimeout(System32), andbash(System32’s WSL launcher; 2,897 calls runbash). -
Main is better than 0.4.0, not finished.
cd sub && ./tool.exeand./batch(PATHEXT) work on main, andnpxruns with no prelude. A relative command that does not exist in the cwd still runs the same path under brush’s starting directory (#759):resolve_executable_pathfalls back to the bare path. -
A redirect to
name::$DATAwrites the file itself under brush (#769, fixed in the rules); under Git Bash it makes a separate file.
The operator’s rulings (2026-11-10): opt-in first, the default decided later on the trial’s numbers; find, timeout, xargs, diff and cmp refused beside grep, sed and awk; the Windows binary cross-compiled with mingw on the Linux runner; monitors, jobs and ! left on Git Bash for a later plan; no replacement toolset - refuse with the replacement named, and scripts that need the tools fail (repositories should not depend on Unix-only shell scripts); python3 runs python where one is installed; a CI job in this repository builds brush and publishes it to our GitLab package registry, pinned by checksum; our build carries the #759 fix, and no upstream report is sent.
Design
D1. The build. tools/brush/pin.json names the upstream commit, the Cargo features (experimental-bundled-coreutils), the Rust image by digest, and the patch list. tools/brush/patches/0001-relative-command-in-cwd.patch makes resolve_executable_path’s fallback the joined path (`working_dir.join(&path)), so a relative command absent from the cwd is not found. tools/brush-build.mjs clones the commit, applies the patches, and builds twice with --locked: x86_64-pc-windows-gnu (mingw-w64 from the image’s package manager; the runners are Linux Docker, and there is no Windows runner) and the host’s Linux target, for D9. Upstream’s own CI builds that Windows target from Linux (cross, on ubuntu-24.04; its note says the container fails on 26.04). The measurements in Context used the msvc target, so the C runtime differs (msvcrt, not the UCRT) while the Rust code is the same; D9 re-reads them on this build. It packs brush.exe as brush-<rev>-<n>-win32-x64.tar.gz, writes its SHA-256, and uploads both to this project’s generic package registry as brush/<rev>-<n>/. It refuses to overwrite a version that exists.
D2. The job. brush-build in .gitlab-ci.yml, stage release, $RUNNER_2XLARGE, runs only on a tag brush-<n>: never on a push, an MR or a v tag. Auth is CI_JOB_TOKEN. The project is public, so the download needs no token (checked in unit 1).
D3. The pin. PINNED_BRUSH in packages/pi-workspace/windows-shell.ts gains the asset’s full URL and its SHA-256, committed in the repository by the pin MR; nothing is read from the registry at run time but the bytes, which verifiedBinaryAt checks against the committed digest before anything runs them. pinned-binary.ts’s `PinnedAsset gains an optional url (a GitHub release URL is derived as today when absent).
D4. Opt-in first. With a pin set, brush runs only where PI_WINDOWS_SHELL=brush or PI_BRUSH says so; the default stays Git Bash. Making it the default is one line, on the operator’s word after the trial (Acceptance). windowsShell changes accordingly: pinned and not asked for is git-bash, with no fetch.
D5. The shell directory. <agentDir>/gadhs-pi-shell/<pin>/bin/, first on each brush command’s PATH, built at registration:
-
bash.exeandsh.exe: copies of the verified brush, each with its.sha256sidecar, checked withkeptIntactas the binary itself is. Sobash ./x.shandbash -crun brush, at every depth. -
One
NAME.cmdper refused name (D6): two lines, the fixed message to stderr andexit /b 127. A stub never reads, forwards or prints its arguments.
Git for Windows' mingw64\bin and usr\bin are no longer added (#753’s gitToolDirs goes); the inherited PATH is otherwise as given. Measured on main: from the top level and from inside bash ./inner.sh, each refused name printed its line and exited 127, in a pipeline too, with 'a&b|c' as an argument.
Fail closed: if the directory cannot be written, or a copy fails its check, the bash tool does not run brush: Git Bash where pi finds one, else the tool’s registration notes why and every call fails with that reason. Never brush without the directory, since bash would then be the WSL launcher.
D6. The refused names and their lines (in packages/pi-workspace/brush-refusals.ts, one table; the text is prompt text, pinned whole by a test):
| Names | Line (after pi: NAME is not available in this shell.) |
|---|---|
|
Use rg: the same -n -i -v -c -o -l -A -B -C. Write alternation with a bare pipe, never backslash-pipe; add --no-ignore to search ignored files; never -r or -E. |
|
To print lines of a file use the read tool (offset, limit); to change a file use the edit tool; on a pipe use head, tail, cut or tr; otherwise node -e. |
|
Use cut or tr for columns, or node -e. |
|
Use fd, or a |
|
Use a |
|
Use |
|
Pass the bash tool’s own timeout. (Windows' timeout.exe is not this.) |
D7. python3. The prelude sourced before each command (brush-prelude.ts, #757) defines and exports python3() { python "$@"; } when python is on PATH and no python3.exe is, other than the Store stub under WindowsApps. Measured on main: the function passed a&b, p|q, %PATH%, x^y, q"r, a b, an empty argument and *.md whole, and a multi-line -c; export -f reached bash -c and bash ./child.sh. A forwarding .cmd failed on the multi-line -c, and a renamed copy of python.exe reports itself as the copy, so neither is used. Not covered: env python3 (a builtin that spawns), stated in the docs.
D8. The description. BRUSH_DESCRIPTION gains, so the model learns before the first refusal: grep, sed, awk and find are not here (rg, fd, the read and edit tools); /dev/null as a program’s argument is NUL; scratch files go under .pi/scratch/.
D9. The gate for a pin, on the CI-built binary: (a) pi-bash’s differential, PI_BASH_DIFF_RUNS=20000, against the job’s Linux build of the same source, run in the job; (b) on panther, the real-brush suite (packages/pi-ssh/test/brush-shell.test.ts) and this plan’s new cases; (c) on panther, the measurements above re-read on that binary: the 29 rm cases, the #759 repro, the refusals at two depths. The differential cannot run on Windows (#755); that stays open and is said on the pin MR.
Scope
In
-
Unit 1, the build proved.
tools/brush/,tools/brush-build.mjs, the CI job; tagbrush-1; the artifact fetched anonymously and run on panther through D9. If the windows-gnu build fails or differs from the msvc build measured here, stop and report: the alternatives (cargo-xwin, a Windows runner) are the operator’s. -
Unit 2, the shell directory and the refusals.
brush-refusals.ts;windows-shell.ts(the directory, PATH, fail-closed, D4, D8);command-file.ts;pinned-binary.ts(url);brush-prelude.ts(D7). -
Unit 3, the pin MR.
PINNED_BRUSHset; the gate’s numbers on it. -
The field count.
tools/lib/shell-field.mjsalso counts, per session, refusals by name and the calls until a name stops being used. -
Docs.
modes.adoc#windows-shell(rewritten: what is there, what is refused,python3, opt-in, the known gaps:<(…),./x.shwantsbash ./x.sh,env python3);tuning.adoc#windows-shelland thePI_WINDOWS_SHELLrow ofpublic-surface.adoc(D4 changes whatbrushand unset mean);security.adoc(one more pinned binary: who builds it, from what, where the digest lives);packages.adoc; any otherpublic-surface.adocrow the inventory test names;plans/brush-windows-shell.adocgets an erratum (its pin is this plan’s) and its Status moves to Done when unit 3 merges;nav.adoc. CHANGELOG under Unreleased, one entry per unit. -
Delivery and close. Three MRs, squash off. Units 1 and 2 are
Relates to#772; unit 3’s MR carriesCloses #772andCloses #652, and after it merges each issue gets one line with the merge SHA and what is deferred (the default, monitors and jobs, #755). This plan’s Status moves to Done in that MR’s follow-up, with its nav entry to Archive.
Out
-
Monitors, jobs and
!: they keep Git Bash, and do not work on a box without it. Their move is its own plan. -
Making brush the default (D4), and Linux or macOS.
-
Removing #757’s script-and-batch shim rules, unneeded on this build: its own issue, after the pin.
-
The shell guard reading
fd -x rmandfd -X rm, which become the way to delete by search: pi-shellcheck’s issue (pi-dev’s), a dependency of making brush the default, not of this plan. -
Any change to the judge’s rubric. More
rg,fdandnode -elines will reach it; the trial counts them. -
An upstream report or patch (the operator’s ruling), and #755’s Windows oracle.
Tests
-
The build and its job (run on every platform, no network):
packages/pi/test/distribution.test.ts, which already reads.gitlab-ci.yml, assertsbrush-build’s only rule is a `brush-<n>tag (D2’s "never on a push, an MR or avtag");tools/lib/test/brush-build.test.mjs, with the registry faked, asserts an upload to a version that exists is refused and nothing is sent (D1), and that the patch list inpin.jsonis the one applied. -
The field count:
tools/lib/test/shell-field.test.mjsgains a synthetic log with refusals of two names and asserts the per-name counts and the calls until each name stops. -
Contract: each refusal line, whole, per name; the prelude defines
python3whenpythonis listed andpython3.exeis not, treats apython3.exeunderWindowsAppsas absent, and defines nothing when a realpython3.exeis listed (D7, on listing tables, so it runs in CI); a stub’s text holds no%(it forwards nothing); the description’s new sentences;PinnedAsset.urlis fetched as given; the directory holds exactlybash.exe,sh.exe, their sidecars and the stubs. -
Regression: Git’s tool directories are not on brush’s PATH (#753’s cases inverted); with a pin and no opt-in, the operations are Git Bash’s and nothing is fetched; a stub called with
a&b,p|q,%PATH%,x^yand a quote exits 127 with only its line on stderr. -
Fail-closed: an unwritable directory, and a
bash.exethat fails its digest, each give Git Bash where there is one and a refusal where there is none, never brush. -
Concurrency: two registrations building the directory at once leave one whole copy of each file.
-
Real brush, on panther (skipped visibly elsewhere): at the top level and inside
bash ./inner.sh,grep,sed,findandtimeoutprint their lines and exit 127 and none reaches System32;bashreportsBRUSH_VERSION;python3passes the hostile arguments and a multi-line-c, at both depths;cd other && decoy/tool.exeis not found (#759);cat,head,sort,wcandrmare builtins.
Risks
| Risk | Response |
|---|---|
Main at |
D9(a) runs in the build job. A failure is read before anything else is built on it: a later commit, or a carried patch, is the operator’s. |
The windows-gnu cross-build behaves unlike the msvc build these measurements used (silent) |
D9(b) and (c) re-read every measurement on the CI-built binary on panther before the pin MR. |
A refused name reaches another program: a stub missing, or the directory not first (silent: Windows' find or WSL runs) |
The directory is built or the tool does not run brush (D5); the real-brush case asserts no refused name resolves under System32. |
The model does not adapt, and more than half of shell calls are refused (fail-closed: an error and a lost turn, never a wrong run) |
Opt-in (D4); the description teaches first; |
|
The grep line names all three; the count of |
The registry artifact is replaced after the pin (fail-closed: the digest no longer matches, the fetch is refused, Git Bash runs) |
The digest is committed; the job refuses to overwrite; |
A build job run from a tag publishes a binary nobody reviewed (fail-open only if also pinned) |
Nothing uses an artifact until a reviewed MR commits its digest; the tag’s |
Scripts in gesso, thegame, craig and canopy that call grep or sed fail under brush (fail-closed; 38 of 57 scripts) |
The operator’s intent. Stated in the docs and the CHANGELOG; brush is opt-in until he says otherwise. |
Acceptance
-
Unit 1: a binary from tag
brush-1, fetched anonymously, passes D9, or the plan stops there with the reason. -
With no opt-in, a Windows seat behaves exactly as before the plan.
-
With
PI_WINDOWS_SHELL=brushon panther and no Git tool directory on PATH:task validateis started from a brush session and its result reported (it need not pass: #770); a day of this seat’s work runs on it;shell-fieldgives refusals per session and calls to adapt. -
The operator has those numbers before any decision on the default.