{"data":{"kind":"file","path":"README.md","version_id":"olt7767dm5ogfwmpylp54uhj","entry":{"name":"README.md","path":"README.md","is_directory":false,"size":13966,"modified_at":"2026-11-25T19:17:58.817000","content_hash":"4d01198e1296973c29a59b79a8a5cede6a3fdb21a88149c8459b35f0775e54b1"},"entries":[],"content":"# git-orchestration-v1\n\nGit tool use as a `verifiers.v1` taskset: a model gets 13 git tools and a\nfresh sandbox repository per rollout, and is graded on the repository it\nleaves (write tasks) or on its final answer (read tasks). It is the earlier\n`git-orchestration` environment, a `load_environment()` package, ported to v1\nbecause the Prime Intellect hosted training runtime only loads v1 tasksets.\n\nNothing about the task changed in the port. The episodes, sandbox templates,\ntool functions, the shaped reward (A0–A6) and the outcome graders are the\nlegacy package's own modules, copied byte for byte: `episodes.py`,\n`sandbox.py`, `tools.py`, `reward.py`, `reward_config.py`,\n`outcome_metrics.py` and `l5.py`.\n\nBackground and results: https://brunose.github.io/blog-git-rl-transfer.html\n\nNew in this package:\n\n- `git_orchestration_v1.py`: the taskset, the task (sandbox setup and\n  teardown, reward and metrics) and their configuration.\n- `git_toolset.py`: the git tools as a tool server.\n- `fs_transfer.py`: the filesystem transfer sets.\n- `answer_line.py`: the answer-line read grader.\n\n## Configuration\n\nUnder `env.taskset` of a training or evaluation config:\n\n| Key | Values | Default |\n|---|---|---|\n| `id` | `git-orchestration-v1` (Hub: `<owner>/git-orchestration-v1@<version>`) | |\n| `split` | `all`, `train`, `heldout`, `l5_existing`, `l5_new_tools`, `fs_basic`, `fs_hard` | `all` |\n| `reads_only` | `true` / `false` | `false` |\n| `task.ablation` | `A0` … `A6` (reward preset) | `A0` |\n| `task.read_grader` | `contains`: the published read grader; `answer_line`: see below | `contains` |\n| `task.fix_digit_hashes` | `true`: under `contains`, an all-digit commit hash matches like any other hash; see below | `false` |\n| `task.shared_tools` | `true`: one tool server per environment worker; `false`: one per rollout | `true` |\n\nSet `env.agent.max_turns = 10` to keep the legacy turn limit, and use the\n`null` harness (plain chat with tools).\n\nEach rollout records the reward `shaped_reward` (the training signal) and the\nmetrics `outcome`, `outcome_facts`, `success` and `success_facts`. The success\nmetrics are 1.0 only when the matching outcome is exactly 1.0, so their mean\nover rollouts is the task success rate. Report results with the metrics, not\nthe reward: the reward includes the tool bonus.\n\n`task.shared_tools` changes cost, not behaviour. Starting a tool server for\nevery rollout took about half of a rollout's CPU in local measurements (5.2\nagainst 2.5 CPU-seconds per rollout), and CPU on the environment server is\nwhat limited the first hosted run. In two otherwise identical 2-step hosted\nruns on 2026-11-15, training rollouts took a median of 151 s with a server\nper rollout and 28 s with the shared server. Set it to `false` if the shared\nserver misbehaves.\n\nA hosted run writes one record per episode, with these metrics, to its volume\nunder `runs/<run id>/monitors/file/traces/stream/*.jsonl.zst`\n(`prime volumes get <volume> runs/<run id>/monitors <dir>`).\n\n## The answer-line read grader (0.11.0)\n\n`task.read_grader = \"answer_line\"` changes how the 114 L1-L4 read episodes are\ngraded. The default, `contains`, is the published grader and is unchanged.\n\n- **Why:** `contains` looks for expected strings anywhere in the final answer.\n  A script that calls the read tools and pastes their output passes 94% of the\n  held-out read episodes, and the November 2026 training run learned that\n  habit.\n- **What changes:** each read question gets one more sentence naming the\n  values to report on `ANSWER:` lines (numbered `ANSWER 1:`, `ANSWER 2:` when\n  there are several), and only those lines are graded. A line must equal its\n  value, so pasting earns nothing. Repositories, questions, splits and task\n  ids are the same; write, L5 and filesystem episodes are untouched.\n- **Which values:** they follow from the strings the old grader looked for\n  (`answer_line.py`). A hash, message or count stays that value; git's own\n  wording becomes a fact, e.g. \"diff --git\" becomes the name of the file the\n  commit changes. Three questions asked for something other than what the old\n  grader checked and are set by hand.\n- **Scores:** `outcome` and `outcome_facts` are both the fraction of answer\n  lines that are right, 0.0 with no tool call. The shaped reward keeps the\n  preset's structure (format gate, tool bonus, cap at 1.0).\n- **Answers that never change:** the sandbox templates give some facts the\n  same value in every repository (the untracked file is always `scratch.py`).\n  Such a line can be answered from memory. `answer_line.fixed_slots()` finds\n  them; 3 of the 33 held-out read episodes and 18 of the 81 training ones\n  consist only of such lines. Report results with and without them.\n- **Tests:** `test_answer_line.py` checks, for every read episode, that each\n  value appears in the read tools' output, that a correct reply scores 1.0,\n  and that pasting the tool output (into the reply or onto the answer lines)\n  scores 0.0.\n\n## The filesystem transfer sets (0.10.0)\n\n`split = \"fs_basic\"` and `split = \"fs_hard\"` are evaluation-only sets on a\ndifferent tool server: the model gets `list_dir`, `read_file`, `write_file`\nand `move_path` and no git tool. They ask whether training on git tools\ncarries over to tools the model never trained on. Training splits never load\nthese tasks or these tools.\n\n- **`fs_basic`, 48 tasks:** 12 patterns of two or three calls. The untrained\n  Qwen3.5-2B solves most of them, so this set can show harm but little gain.\n- **`fs_hard`, 48 tasks:** 12 patterns that need more calls, an order that\n  matters, or files that must be left alone (move without overwriting, rotate\n  three generations, change a setting only where it exists).\n- **Variants:** each pattern has 4 tasks that differ in file names, values and\n  wording.\n- **Grading:** file tasks are graded on the files left in the workspace,\n  including that nothing else was touched; question tasks on one\n  `ANSWER: <value>` line. A long final answer cannot satisfy either, unlike\n  the L1-L4 read grader. `outcome` and `outcome_facts` are the same number.\n- **Records:** tasks carry `level = 5`, `episode_type = \"fs\"`, and the pattern\n  as `family`, so results can be grouped per pattern like the L5 sets.\n- **Tests:** `test_fs_transfer.py` runs each task's reference solution and\n  checks that three shortcuts fail: no tool calls, pasting every file into the\n  answer, and a wrong last step.\n\n## Tool arguments and paths (0.11.1, 0.11.2)\n\nThe model's tool arguments are passed to git as command-line arguments. Up to\n0.11.0 one that started with `-` was read by git as an option:\n`git_show(\"--output=<path>\")` wrote a file wherever the process could. Hosted\nsandboxes contain that; a local run with the `subprocess` runtime does not.\n\n- **Git tools:** an argument that starts with `-` is refused before git runs,\n  and the tool returns `error: argument ... starts with '-'; options are not\n  accepted`. This covers `git_diff`, `git_show`, `git_add`,\n  `git_create_branch`, `git_checkout`, `git_cherry_pick`, `git_merge` and\n  `git_resolve_conflict`.\n- **0.11.1 was incomplete.** Its check looked one level into a list, and\n  GitPython flattens nested lists into separate arguments, so\n  `git_add([[\"--pathspec-from-file=<path>\"]])` still made git read a file\n  outside the repository and show it in the error text. 0.11.2 checks every\n  level, and `git_commit` refuses a message that is not text.\n- **Also refused:** a bare `-`, git's shorthand for the previous branch.\n- **Not isolated:** git inside the sandbox still reads the global git\n  configuration of the user running it (signing, hooks, templates). On a\n  hosted sandbox there is none; on your own machine it is yours.\n- **Filesystem tools:** the check that a path stays inside the workspace\n  compared strings, so `../<workspace name>x/file` passed. It now compares\n  paths.\n- **Effect on results:** none found. In about 32,000 recorded tool calls\n  (Qwen3.5-2B and Qwen3.5-4B, before and after training), no argument started\n  with `-`. Tasks, prompts, splits and graders are unchanged.\n- **Use 0.11.2 or later** for anything run outside a sandbox.\n\n## Without the verifiers runtime (0.11.3)\n\n`git_rollout.py` is the taskset's own setup, tools and grading as plain\nfunctions, for a training or evaluation harness that is not verifiers. It\nimports nothing from verifiers, and the taskset itself calls it, so both ways\nof running an episode use the same code.\n\n```python\nfrom episodes import generate_all_episodes      # split=\"train\" | \"heldout\" | \"all\"\nfrom l5 import generate_l5_episodes             # \"l5_existing\" | \"l5_new_tools\"\nimport git_rollout as gr\n\ntask = gr.task_fields(episode, read_grader=\"contains\")   # or \"answer_line\"\ntools = {fn.__name__: fn for fn in gr.tools_for_split(task[\"split\"])}\nschemas = [gr.tool_schema(fn) for fn in tools.values()]  # what the model is shown\n\nstate = gr.start(task)                           # creates the sandbox repository\ntry:\n    # task[\"system_prompt\"], task[\"prompt\"]; at most gr.MAX_TURNS model turns.\n    result = gr.run_tool(tools[name], state.repo_path, kwargs=arguments)\nfinally:\n    gr.wrap_up(state)                            # records the final state, deletes the sandbox\nscores = gr.score(state, task, completion, ablation=\"A0\")\n```\n\n- **`score`** returns `shaped_reward`, `outcome`, `outcome_facts`, `success`\n  and `success_facts`. Report `success` and `outcome`; the shaped reward\n  includes the tool bonus.\n- **`completion`** is the model's turns and the tool results as chat-format\n  dicts; the module's docstring gives the exact shape.\n- **`tool_schema`** gives the definition the verifiers tool server serves, key\n  for key. The end-to-end tests compare the two, and check that the same\n  scripted rollouts score the same with and without the runtime.\n- **Left to the harness:** what the model is told when it names a tool that\n  does not exist or sends arguments that are not valid JSON. The verifiers\n  runtime answers those itself, outside this package.\n\n## All-digit commit hashes (0.11.4)\n\nThe published `contains` grader matches an expected fragment made only of\ndigits as a whole number, so that a commit count of 3 does not match inside\n\"13\". A short commit hash is all digits about one time in forty\n((10/16)^8), and then the same rule applies to it: an answer that quotes the\nfull 40-character hash fails, although it is right.\n\n`task.fix_digit_hashes = true` matches an expected commit hash as text whatever\nit is made of. It is off by default, so the published grader and every recorded\nnumber stay as they are.\n\n- **What it changes:** the outcome, the facts outcome and the shaped reward of\n  the L1-L4 read episodes that expect a commit hash (61 of 114), and only in\n  rollouts where that hash happens to be all digits.\n- **What it does not change:** prompts, task ids, commit counts (still whole\n  numbers), write, L5 and filesystem episodes, and the answer-line grader,\n  which never had the problem.\n- **Without the runtime:** `gr.task_fields(episode, fix_digit_hashes=True)`.\n- **Which repositories are affected is not reproducible:** commit dates are\n  the wall clock, so hashes differ from one sandbox to the next.\n\n## Differences from the legacy environment\n\n- The tool descriptions reach the model through the runtime's tool server, so\n  the JSON schema the model sees is generated differently (same names,\n  parameters and docstrings).\n- A failing git command still comes back as the error text in a normal tool\n  result.\n- The `GIT_ORCH_ABLATION` environment variable is not read; set\n  `task.ablation`.\n- Per-batch reward logging (`metrics.py`) is not ported. The per-rollout\n  metrics replace it.\n\n## Development\n\n```bash\nuv run pytest                 # 684 tests, about four minutes\n```\n\n`test_end_to_end.py` runs whole rollouts through the real runtime (`vf-run`,\nthe tool server, the chat harness) against `fake_model.py`, a scripted\nstand-in for the model on localhost. No model, key or outside service is\ninvolved.\n\n`fake_model.py` and `export_oracle.py` are development helpers: they are in\nthe source directory but not in the wheel.\n\nThe package requires `verifiers>=0.4.1`, the release on PyPI, and the tests\npass on it. `uv run` in this directory instead resolves the git commit the\nhosted runtime used when the package was last tested (0.4.2.dev47, set under\n`[tool.uv.sources]` in `pyproject.toml`). The runtime moves quickly; re-pin\nand re-run the tests before a training run.\n\nThe seven copied modules are kept identical to the legacy package's.\n`test_core_in_sync.py` checks that when the legacy package is checked out\nnext to this one (`../git-orchestration`) and is skipped otherwise;\n`sync_core.sh` refreshes the copies from there.\n\n## Running it against a local model\n\n```bash\n# from a scratch directory; LM Studio (or any OpenAI-compatible server) on port 1234\nLMSTUDIO_KEY=lm-studio uv run --project <path to this package> vf-run @ local.toml\n```\n\n```toml\n# local.toml\nmodel = \"qwen3.5-2b\"\nnum_rollouts = 3\nmax_concurrent = 2\noutput_dir = \"out\"\n\n[client]                       # without this block requests go to Prime Inference (paid)\nbase_url = \"http://localhost:1234/v1\"\napi_key_var = \"LMSTUDIO_KEY\"\n\n[sampling]\ntemperature = 0.9\nmax_tokens = 1024\nreasoning_effort = \"none\"\n\n[env.taskset]\nid = \"git-orchestration-v1\"\nsplit = \"heldout\"\n\n[env.agent]\nmax_turns = 10\n\n[env.agent.harness]\nid = \"null\"\n\n[env.agent.runtime]            # without this block each rollout starts a Prime sandbox (paid)\ntype = \"subprocess\"\n```\n\nEach line of `out/<run>/traces.jsonl` is one episode; its trace has\n`rewards.shaped_reward.score`, `metrics.outcome` and `metrics.outcome_facts`.\nAdd `--dry_run` to print the resolved config without running anything.\n\n## Licence and acknowledgement\n\nMIT; see `LICENSE`.\n\nThe names of the 13 training tools and several of their return strings follow\nthe Model Context Protocol reference git server (`mcp-server-git`, MIT\nlicence).\n","encoding":"utf-8","truncated":false,"total_bytes":13966},"status":null}