nl2bash_v1: validation run 2026-10-17-nl2bash_v1-b0c10dccb2cd

#23
by FWeindel - opened
evidence/2026-10-17-nl2bash_v1-b0c10dccb2cd/nl2bash_v1/patchers/0ff3d34f33f5d1d9678fdaf6b7567b85f8ee70126dbf2db7fc48206f9dad62de/patch.py ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Repair the NL2Bash verifier schema and let the harness run the seed setup."""
2
+
3
+ import sys
4
+ from pathlib import Path
5
+ sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
6
+
7
+ import argparse
8
+ import copy
9
+ import gzip
10
+ import hashlib
11
+ import io
12
+ import re
13
+ import tarfile
14
+ import tomllib
15
+
16
+ REVISION = '946884702046be1a7dcea2638186ad6b0d2ea103'
17
+ PATCH_VERSIONS = (
18
+ 'nl2bash-remove-unsupported-verifier-restart-v1',
19
+ 'nl2bash-harness-seed-setup-v1',
20
+ )
21
+ LABEL = 'static:task-toml-schema.py'
22
+ SETUP_LABEL = 'repair:harness-seed-setup.py'
23
+ REASONS = {
24
+ LABEL: ('Removed verifier.restart_environment from task.toml: the pinned Harbor '
25
+ 'schema does not recognize this field and the runtime ignores it.'),
26
+ SETUP_LABEL: ('Renamed setup_files/setup_seeds.sh to setup_files/setup.sh and pointed '
27
+ 'solve.sh at it (it called the missing /tests/setup_seeds.sh), so the harness '
28
+ 'seeds /workspace before every trial; removed the instruction block that '
29
+ 'asked the agent to run the script; the fixtures line now says the input '
30
+ 'files are already in /workspace, and the claim that the verifier inspects '
31
+ 'helper files is removed (it reads only /output/command_capture.txt).'),
32
+ }
33
+ SEED_SCRIPT = 'setup_files/setup_seeds.sh'
34
+ HARNESS_SCRIPT = 'setup_files/setup.sh'
35
+ BROKEN_SETUP_CALL = b'bash /tests/setup_seeds.sh'
36
+ HARNESS_SETUP_CALL = b'bash /setup_files/setup.sh'
37
+ INSTRUCTION_SETUP = (b'## Environment Setup (run before starting)\n\n```bash\n'
38
+ b'bash /setup_files/setup_seeds.sh\n```\n\n---\n\n')
39
+ INPUT_LINES = (
40
+ b'- From `/workspace`, assemble any missing fixtures using standard shell utilities '
41
+ b'before running your command.\n',
42
+ b'- The workspace already contains pre-seeded fixtures copied to `/workspace`; '
43
+ b'run the command from that directory.\n',
44
+ )
45
+ INPUT_LINE = (b'- The input files for this task are already in `/workspace`; '
46
+ b'run the command from that directory.\n')
47
+ HELPER_LINE = b'- Do not delete any helper files generated during execution; the verifier inspects them.\n'
48
+
49
+
50
+ def rewrite_instruction(body):
51
+ """Drop the setup block and the two lines that misdescribe the seeded start state."""
52
+ text = body[len(INSTRUCTION_SETUP):]
53
+ if [text.count(line) for line in INPUT_LINES].count(1) != 1 or \
54
+ sum(text.count(line) for line in INPUT_LINES) != 1 or text.count(HELPER_LINE) != 1:
55
+ raise ValueError('instruction.md lacks the expected fixtures and helper-files lines')
56
+ for line in INPUT_LINES:
57
+ text = text.replace(line, INPUT_LINE)
58
+ return text.replace(HELPER_LINE, b'')
59
+
60
+
61
+ def clean_config(content):
62
+ """Remove only the unsupported field; verify every other TOML value survives."""
63
+ text = content.decode('utf-8')
64
+ before = tomllib.loads(text)
65
+ if 'restart_environment' not in before.get('verifier', {}):
66
+ return content
67
+ expected = copy.deepcopy(before)
68
+ del expected['verifier']['restart_environment']
69
+ section = re.compile(r'(?ms)(^\[verifier\][^\n]*\n)(.*?)(?=^\[|\Z)')
70
+ field = re.compile(r'(?m)^[ \t]*(?:restart_environment|"restart_environment"|\'restart_environment\')[ \t]*=[^\n]*(?:\n|$)')
71
+ cleaned = section.sub(lambda m: m[1] + field.sub('', m[2]), text)
72
+ if tomllib.loads(cleaned) != expected:
73
+ raise ValueError('Unsupported task.toml layout for verifier.restart_environment removal')
74
+ return cleaned.encode('utf-8')
75
+
76
+
77
+ def patch_archive(blob):
78
+ """Apply narrowly scoped fixes while preserving all other archive payloads."""
79
+ with tarfile.open(fileobj=io.BytesIO(blob), mode='r:*') as source:
80
+ members = source.getmembers()
81
+ configs = [m for m in members if Path(m.name).as_posix() == 'task.toml']
82
+ if len(configs) != 1 or not configs[0].isfile():
83
+ raise ValueError('Expected exactly one regular task.toml in task archive')
84
+ config = configs[0]
85
+ original = source.extractfile(config).read()
86
+ cleaned = clean_config(original)
87
+ edited = {}
88
+ labels = []
89
+ if cleaned != original:
90
+ edited[id(config)] = cleaned
91
+ labels.append(LABEL)
92
+
93
+ by_name = {Path(m.name).as_posix(): m for m in members}
94
+ helper = by_name.get(SEED_SCRIPT)
95
+ solutions = [m for m in members
96
+ if Path(m.name).as_posix().startswith('solution/') and m.isfile()]
97
+ solution_bodies = {id(m): source.extractfile(m).read() for m in solutions}
98
+ instruction = by_name.get('instruction.md')
99
+ instruction_body = source.extractfile(instruction).read() if instruction else b''
100
+ calls = any(BROKEN_SETUP_CALL in body for body in solution_bodies.values())
101
+ renamed = {}
102
+ if helper is not None or calls or b'setup_seeds' in instruction_body:
103
+ # All three parts belong together; anything else needs a human look.
104
+ if helper is None or not helper.isfile() or not calls or HARNESS_SCRIPT in by_name:
105
+ raise ValueError('Unexpected seed setup layout: need setup_files/setup_seeds.sh, '
106
+ 'a /tests/setup_seeds.sh call in solve.sh and no setup_files/setup.sh')
107
+ if not instruction_body.startswith(INSTRUCTION_SETUP) or \
108
+ b'setup_seeds' in instruction_body[len(INSTRUCTION_SETUP):]:
109
+ raise ValueError('instruction.md does not start with the expected seed setup block')
110
+ renamed[id(helper)] = HARNESS_SCRIPT
111
+ edited[id(instruction)] = rewrite_instruction(instruction_body)
112
+ for member in solutions:
113
+ body = solution_bodies[id(member)]
114
+ fixed = body.replace(BROKEN_SETUP_CALL, HARNESS_SETUP_CALL)
115
+ if fixed != body:
116
+ edited[id(member)] = fixed
117
+ labels.append(SETUP_LABEL)
118
+ if not edited:
119
+ return blob, []
120
+ output = io.BytesIO()
121
+ compressed = blob[:2] == b'\x1f\x8b'
122
+ stream = gzip.GzipFile(filename='', fileobj=output, mode='wb', mtime=0) if compressed else output
123
+ with tarfile.open(fileobj=stream, mode='w', format=source.format) as target:
124
+ for member in members:
125
+ info = copy.copy(member)
126
+ info.name = renamed.get(id(member), member.name)
127
+ body = edited.get(id(member), source.extractfile(member).read()) if member.isfile() else None
128
+ if member.isfile() and id(member) in edited:
129
+ info.size = len(body)
130
+ target.addfile(info, io.BytesIO(body) if body is not None else None)
131
+ if compressed:
132
+ stream.close()
133
+ return output.getvalue(), labels
134
+
135
+
136
+ def patch(source, output):
137
+ import pyarrow as pa
138
+ import pyarrow.parquet as pq
139
+ from data.utils.patch_reporting import write_patch_report
140
+
141
+ source, output = Path(source), Path(output)
142
+ output.mkdir(parents=True, exist_ok=True)
143
+ destination = output / 'tasks.parquet'
144
+ if destination.exists():
145
+ raise ValueError('Use a new patch output directory')
146
+ parquet = pq.ParquetFile(source)
147
+ changed = {}
148
+ with pq.ParquetWriter(destination, parquet.schema_arrow) as writer:
149
+ for batch in parquet.iter_batches(batch_size=32):
150
+ rows = batch.to_pylist()
151
+ for row in rows:
152
+ row['task_binary'], labels = patch_archive(row['task_binary'])
153
+ if labels:
154
+ changed[row['path']] = labels
155
+ writer.write_table(pa.Table.from_pylist(rows, schema=parquet.schema_arrow))
156
+ with source.open('rb') as source_stream:
157
+ source_hash = hashlib.file_digest(source_stream, 'sha256').hexdigest()
158
+ return write_patch_report(source, destination, source={
159
+ 'dataset': 'open-thoughts/TaskTrove/nl2bash (TOML-normalized input)',
160
+ 'url': 'https://huggingface.co/datasets/open-thoughts/TaskTrove',
161
+ 'revision': f'sha256:{source_hash}'}, dropped={}, change_labels=changed,
162
+ change_reasons={name: '; '.join(REASONS[label] for label in labels)
163
+ for name, labels in changed.items()},
164
+ patches=PATCH_VERSIONS, patcher=__file__)
165
+
166
+
167
+ def main():
168
+ parser = argparse.ArgumentParser()
169
+ parser.add_argument('--source', type=Path, required=True)
170
+ parser.add_argument('--output', type=Path, required=True)
171
+ args = parser.parse_args()
172
+ report = patch(args.source, args.output)
173
+ print(f"NL2Bash: {sum(t['action'] == 'changed' for t in report['tasks'])} tasks repaired")
174
+
175
+
176
+ if __name__ == '__main__':
177
+ main()
images/manifests/2026-10-17-nl2bash_v1-b0c10dccb2cd.json ADDED
The diff for this file is too large to render. See raw diff
 
nl2bash_v1/README.md ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NL2Bash
2
+
3
+ ## Dataset stats
4
+
5
+ - **Tasks:** 1,497 original, 1,425 kept, all 1,497 patched; 72 archived.
6
+ - **Source:** [TaskTrove](https://huggingface.co/datasets/open-thoughts/TaskTrove) `nl2bash` at revision `946884702046be1a7dcea2638186ad6b0d2ea103`.
7
+
8
+ ## Original datasource
9
+
10
+ - NL2Bash — https://arxiv.org/abs/1802.08979
11
+
12
+ ## Domains
13
+
14
+ File Operations, System Administration
15
+
16
+ - **File Operations:** Every sampled task asks the agent to locate, filter, count, sort, or copy files in a seeded /workspace using find, grep, xargs, du, sort, cp and friends (e.g. find .log files up to depth 3 and list the three largest; copy file.ext matches with attributes preserved; count zero-byte files under subdir), then write the command's combined stdout/stderr to /output/command_capture.txt.
17
+ - **System Administration:** Tasks are framed as 'Terminal Automation Requests' in an Ubuntu container and are solved by composing shell one-liners with coreutils, bash variables, redirection and pipelines (e.g. capturing whoami into a variable, `2>&1` capture, -print0/xargs -0 handling); the manifests show each task was generated from an NL2Bash NL-to-bash pair with added flags such as -maxdepth, -type f, -iname.
18
+
19
+ ## Agent capabilities
20
+
21
+ Specification Adherence
22
+
23
+ - **Specification Adherence:** Intended practice: each goal stacks several precise, easily-dropped details (depth limit, case-insensitivity, regular-files-only, exact extension, numeric sort on a specific field, zero matches omitted, capture of both stdout and stderr to a fixed path). The verifier compares a normalized multiset of output lines against the reference command's output and fails on any missing record or error text, so dropping one qualifier changes the output and zeroes the reward. No trajectories were supplied, so this is the designed target, not observed behavior.
24
+
25
+ ## Expected benchmark transfer
26
+
27
+ - **Terminal-Bench 2.0**: The tasks use the same Harbor-style layout (task.toml, tests/test.sh writing /logs/verifier/reward.txt, /output artifacts) and train the core skill of translating a natural-language request into correct shell pipelines inside an Ubuntu container, which is a prerequisite for most TB2 tasks even though TB2 tasks are far longer-horizon.
28
+ - **OpenThoughts-TBLite 2.0**: TBLite is a faster, lighter terminal-agent panel calibrated to Terminal-Bench 2; practice at precise find/grep/sort/xargs command composition and writing results to a required output path should transfer directly to its shorter shell-centric tasks.
29
+ - **Harbor-Index**: Harbor-Index is a Harbor-format terminal-agent panel; the dataset's tasks are built in the same task.toml/verifier format and exercise basic Linux file-manipulation commands with executable verification, so modest gains on its shell-heavy tasks are plausible.
30
+
31
+ ## Patches
32
+
33
+ - **Verifier schema:** removed `verifier.restart_environment` from `task.toml`; the pinned Harbor schema does not recognize it and the runtime ignores it (1,497 tasks).
34
+ - **Seed setup:** renamed `setup_files/setup_seeds.sh` to `setup_files/setup.sh`, so the harness runs it automatically before the agent and the verifier start (the reference solution called a script that did not exist). Removed the instruction block that told the agent to run it, and the instructions now say the input files are already in `/workspace`. Also removed the claim that the verifier inspects helper files: it reads only `/output/command_capture.txt` (1,497 tasks).
35
+ - **Output path (task_267):** the goal said to capture output in `$PWD/command_capture.txt`, where `$PWD` resolves to `/workspace`, but the verifier expects the output in `/output/command_capture.txt`. The goal now names `/output/command_capture.txt`.
36
+
37
+ ## Per-stage breakdown
38
+
39
+ - **Build and setup:** 1,497 passed, 0 archived.
40
+ - **Reference solution (reward 1):** 1,425 passed, 72 archived (see below).
41
+ - **No-op baseline (reward 0):** 1,497 passed, 0 archived.
42
+ - **Rule-based checks:** 1,497 passed; 111 advisory path warnings (see below).
43
+
44
+ ## Notes
45
+
46
+ **Instruction paths.** The automatic path check flagged relative paths in 111 tasks. We inspected all of them: 110 are clear to the agent. In 96 the path is a seed folder that setup copies into `/workspace`, the directory the instructions say to work from; in 24 the task itself creates the path; one is an exclusion pattern, and three were filename patterns rather than paths. One task was misleading and is fixed (task_267, see Patches).
47
+
48
+ **Archived: reference solution scores 0 (72 tasks).** The verifier compares the output with an `expected_output` recorded in the original environment, which cannot be reproduced in this environment:
49
+
50
+ - **Fixtures changed in the TaskTrove conversion:** e.g. a 50,000-line input became a zero-filled file (task_2706); files meant to be older than 10 days are created fresh, so `find -atime +10` finds nothing (task_9135).
51
+ - **Output tied to the recording machine:** kernel version, hostname, date or file timestamps.
52
+ - **Output that depends on the filesystem:** `find` order, `du` sizes, filesystem type.
53
+ - **Output that depends on timing:** commands that read the capture file they are writing.
54
+
55
+ ## Runtime
56
+
57
+ - **Versions:** Apptainer **1.5.4**, Python **3.12.14**, Harbor **0.8.1**.
58
+ - **Resources:** Helma; 48 CPU cores, 64 GiB RAM per job, 17 concurrent tasks, no GPUs.
59
+
60
+ ## Files
61
+
62
+ - `tasks.parquet`: kept tasks.
63
+ - `archive.parquet`: excluded tasks with validation reasons.
64
+
65
+ Domain and capability labels follow CLI-Universe. Taxonomy source: https://arxiv.org/abs/2606.22883v1
nl2bash_v1/archive.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ca84631bfe4f8c2261449b005548478fe92997edbb0019fe724c4b90c1bcabd
3
+ size 330636
nl2bash_v1/tasks.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea08f8cf7f49d8472bc515a3c0a674b8c21f199a24f12c086301b6480958d052
3
+ size 855485
runs/2026-10-17-nl2bash_v1-b0c10dccb2cd.json ADDED
The diff for this file is too large to render. See raw diff