--- license: mit task_categories: - text-generation language: - en tags: - bash - shell - code - instruction-tuning - sft - command-line size_categories: - 10K` β€” bad / extra operand - `uname java`, `cp --parents f1 f2`, `lspci -s notes.xml`, `head 20 -3 file` - `echo -e "appdb" | tsort` β€” odd number of tokens A second pass (manual analysis + a stricter validator) caught two generator bugs and fixed them at the source (55,000 β†’ **54,808**): - **Invalid long-form flag variant.** The answer-diversity generator applied a command's shortβ†’long flag map across a whole pipeline, leaking e.g. grep's `-n β†’ --line-number` onto a downstream `tail -n` β†’ `tail --line-number` (invalid). **146 rows removed**; the generator now restricts substitution to the owning command's segment. (`tail --lines` / `head --lines` are valid on GNU and were kept.) Also removed 3 `kill --CONT `. - **`find -size` missing its comparison operator.** "larger than N" requests emitted bare `-size N` (means *exactly* N). **113 rows repaired** to `-size +N`; the template now sets `+`/`-` from the request direction. Re-running the hardened validator (now with `set -o pipefail` + a per-stage stderr scan for `invalid/unrecognized option`) then surfaced **5 more** malformed rows the old exit-status check had missed β€” `journalctl ` (bare units need `-u`) β€” which were removed (β†’ **54,803**). ### Running the validator yourself (`validate.py`) Validation is **decoupled** from generation β€” nothing in `generate.py` calls it. ```bash # instant static checks: bash -n on every command + shellcheck (if installed), # broken down by category and utility python validate.py --data bash_dataset.jsonl # execute the SAFE self-contained subset in a disposable fixture dir python validate.py --data bash_dataset.jsonl --execute --n 3000 # whole-set execution on a THROWAWAY Linux box (WSL etc.): runs nearly every # single-line command AND scripts, then reports the genuine-error rate and offers # to delete those rows (backs up the dataset first) python validate.py --data bash_dataset.jsonl --execute --permissive --n 60000 --timeout 5 ``` Two execution modes: - **strict** (default) β€” only self-contained, read-only coreutils on relative paths. - **`--permissive`** β€” for a disposable Linux box. Runs β‰ˆ43k rows including scripts and system-info / fs-mutating tools, while **hard-blocking** genuinely dangerous commands (`dd`/`mkfs`/`shutdown`/`reboot`/`mount`, fork bombs, `kill`/`pkill`, writes to `/etc`Β·`/var`Β·`$HOME`, block devices) and **skipping** anything that would hang (`tail -f`, `watch`, `while true`, `sleep`, installers, network, `yes`). Every command runs in a temp sandbox with a timeout, `stdin` from `/dev/null`, `sudo` stripped, and `stdout` discarded so infinite-output commands can't exhaust memory. The report separates **ran-clean**, **environmental** (not correctness failures), and **genuine errors** (bad flag/option/logic). `--dump-errors FILE` writes every genuine error for inspection; `--yes` / `--no` control the delete prompt non-interactively. --- ## Reproducing (`generate.py`) ```bash python generate.py plan # quota table + registered recipes python generate.py run # generate to ./bash_dataset.jsonl (resumable) python generate.py status # where a run stands python generate.py validate-all # re-run bash -n over the whole file python generate.py seeds # build/inspect the real-phrasing seed pool ``` Resumable: `bash_dataset.jsonl` is ground truth and a derived `bash_dataset.progress.json` snapshot is rewritten after every batch, so re-running continues where it stopped. ### How it's built - **Recipe engine** β€” β‰ˆ150 hand-written recipe families emit `(request, command)` pairs by combining varied phrasings with realistic parameter pools (filenames, dirs, ports, services, users, patterns). Every parameter is drawn **once** per example and reused in both the request and the command, so they never disagree. - **Argument-fidelity gate** (`argcheck.py`) β€” a pair is rejected unless the command references the concrete nouns the request names (filename, extension, user, group, service, process, port). - **Real phrasing (seeds)** β€” a share of requests are seeded from [tldr-pages](https://github.com/tldr-pages/tldr): the human description becomes the request, its command the solution, with `{{placeholders}}` filled fresh from the pools. Heavily quality-filtered (subcommand multiplexers and non-fillable placeholders dropped) down to β‰ˆ600 clean coreutils/text/net templates, cached in `seeds/_seedcache.json`. - **Answer diversity** β€” a share of requests also emit 1–2 genuinely-equivalent alternates sharing a `variant_group` (flag reorderings, long/short options, `wc -l f` ↔ `cat f | wc -l`, `sort -u` ↔ `sort | uniq`, …), each re-checked before it's kept. - **Guards** β€” SHA-1 dedup; a degeneracy guard rejecting no-op transforms (`sed 's/x/x/'`, `mv f f`); category quotas (40/35/25); a 4% per-utility request cap + 6% row cap; minimum floors for the system/info utilities; and a `bash -n` gate on every command. ### Tunable flags | Flag | Default | Effect | |---|---|---| | `--target` | 55000 | Total rows (rescales quotas, caps, floors). | | `--seed-frac` | 0.40 | Target share of seedable requests drawn from real seeds. | | `--seed-reuse` | 8 | Max reuse of one tldr template (higher = more real phrasing, less request variety). | | `--variant-frac` | 0.30 | Share of requests that attempt alternate answers. | | `--row-cap-pct` | 0.06 | Max total-row share per utility (trades off answer diversity). | | `--no-net` | off | Never download seeds; use the local cache only. | Seed and answer-diversity fractions are **soft** (they land under target when the clean seed pool or the caps bind). The hard invariants β€” category split, caps, floors, argument fidelity, `bash -n`, dedup β€” always hold. --- ## Files | File | What it is | |---|---| | `bash_dataset.jsonl` | The dataset β€” 54,803 rows (β‰ˆ22 MB, no Git LFS needed). | | `generate.py` | The generator (reproducible, resumable). | | `validate.py` | Standalone validator (strict + `--permissive` execution). | | `argcheck.py` | Argument-fidelity checker (generation gate + standalone auditor). | | `seeds/_seedcache.json` | Cleaned real-phrasing templates so generation runs offline. | ## Intended use & limitations **Good for** teaching a small model to map natural-language requests to correct single commands, short pipelines, and small scripts β€” including the fumble-prone system utilities. - **Synthetic.** Variety comes from recombining templates + token pools and a quality-filtered slice of real tldr phrasings; request *shapes* come from a finite family set (phrasing is diversified β€” request text β‰ˆ97% unique). - **Valid β‰  fully semantically correct.** `bash -n`, shellcheck, sandbox execution, and the argument gate show commands parse, lint, run, and use the request's nouns β€” none prove the command's *logic* perfectly matches intent (e.g. an `awk` column index assumes a particular layout). - **Single-turn.** No explanations or negative examples, aside from the equivalent answers grouped by `variant_group`. ## License MIT.