# datagen — synthetic macro trajectories `datagen` generates verified training trajectories for every macro in the registry. Each trajectory is one macro (or a short chain) performed on a MiniWeb train site, recorded as **screenshots + pixel actions**. A student model learns to act from these pixels. The executor is a coding LLM with privileged DOM access. It writes a script against a restricted action wrapper, so it does not have to perceive the page to act. Privileged information (site map, DOM, backend state, guides) decides which tasks are made and how they are executed, but it never enters a training trajectory. Failed attempts are kept separately as negatives. ## What humans provide Every human input is fixed before a run starts: | Input | Where | |---|---| | The websites and their data | `src/miniweb/sites/`, `data/miniweb.db` | | The macro registry, and where each macro lives on each site | `data/macros.yaml`, `data/macro_locations.yaml` | | What a macro's target looks like on a page | control-kind code, `src/miniwebgen/kinds/` | | Human demonstrations: annotated recordings on train sites, summarized once per macro into a guide | `data/annotations/` → `data/datagen/guides/` | | The train/test site split | `data/datagen/site_split.json` | Nobody curates anything inside a run. Each keep or drop decision comes from the deterministic backend gate (plus the LLM judge unless `--no-judge` is set), dedup and the per-site caps. The one hand-maintained list that affects outputs is `retired.json` (see [Retired trajectories](#retired-trajectories)). ## One command ```bash PY=~/.conda/envs/miniweb/bin/python $PY -m miniwebgen run --run-id myrun --target 100 --no-judge --workers 12 --servers 6 ``` Without `--macros`, the run covers every macro that some control kind serves. That is all 46 registry macros: `$PY -c "from miniwebgen import kinds; print(len(kinds.supported_macros()))"`. `run` first builds anything that is missing: the site split, the guides for the run's macros (and for macros a mid-chain prefix may demonstrate), and the site maps of the sites it needs. It then runs the stages below, writes the exports and prints the yield log. To resume an interrupted run, run the same command again. Each stage is skipped when its output exists, and `--redo ` recomputes one stage. A new `--run-id` with the same `--target` tops each macro up: earlier runs' kept trajectories count toward the target and their dedup keys are excluded from sampling. Requirements: - Gemini credentials in `.env` for the LLM stages. All stages default to `gemini-3.5-flash`; override per stage with `DATAGEN_MODEL_GUIDE`, `_SUGGEST`, `_EXECUTOR` or `_REASON`. - The headless Chromium in `config.CHROME`: `chromium-1117`, overridable with `DATAGEN_CHROME`. ## Stages `runs/` means `data/datagen/runs/`. | # | Stage | Module | Output | |---|---|---|---| | 0 | Train/test **site** split, decided once before anything is generated | `split.py` | `data/datagen/site_split.json` (52 train / 13 test sites) | | – | Privileged site map: crawl train sites, find controls, probe each control's backend signature | `sitemap.py` | `data/datagen/sitemap/.json` | | 1 | Guide: up to 24 human demonstrations of one macro (train sites) → a site-agnostic procedure | `guides.py` | `data/datagen/guides/.{json,md}` | | 2 | Sample (site, target control, argument, start state); stratified, capped, deduped, dry-run validated | `sampler.py` | `runs//params.jsonl`, `infeasible.jsonl`, `spare.jsonl`, `caps.json` | | 3 | Suggest: an NL instruction around the sampled parameters, plus the expected backend check | `suggester.py`, `checks.py` | `runs//tasks.jsonl` | | 4 | Execute: the LLM writes a script for the restricted wrapper; screenshots and pixel actions are recorded (up to `--attempts` tries) | `executor.py`, `actions.py`, `driver.py` | `runs//episodes//a/` | | 5 | Filter: backend gate (+ judge), dedup, per-site cap, `--target`; failures go to the failure pool | `filter.py`, `judge.py` | `kept.jsonl`, `surplus.jsonl`, `failure_pool.jsonl`, `judged.jsonl` | | – | Finalize: kept attempt → student-neutral trajectory + element side file (no LLM) | `trajectory.py`, `elements.py` | `runs//accepted//` | | 6 | Thoughts (**optional, off by default**): a VLM writes one thought per step in a given style | `reasoning.py` | `accepted//thoughts/