auto-optimize 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- auto_optimize/__init__.py +3 -0
- auto_optimize/__main__.py +5 -0
- auto_optimize/cli.py +651 -0
- auto_optimize/skills/auto-optimize-code/LICENSE +21 -0
- auto_optimize/skills/auto-optimize-code/SKILL.md +251 -0
- auto_optimize/skills/auto-optimize-code/VERSION +1 -0
- auto_optimize/skills/auto-optimize-code/references/algorithm.md +182 -0
- auto_optimize/skills/auto-optimize-code/references/changes.md +146 -0
- auto_optimize/skills/auto-optimize-code/references/cli.md +206 -0
- auto_optimize/skills/auto-optimize-code/references/dashboard.md +203 -0
- auto_optimize/skills/auto-optimize-code/references/documents.md +55 -0
- auto_optimize/skills/auto-optimize-code/references/extending.md +87 -0
- auto_optimize/skills/auto-optimize-code/references/external-validation.md +98 -0
- auto_optimize/skills/auto-optimize-code/references/glossary.md +134 -0
- auto_optimize/skills/auto-optimize-code/references/idea-miner.md +108 -0
- auto_optimize/skills/auto-optimize-code/references/issue-bugs.md +182 -0
- auto_optimize/skills/auto-optimize-code/references/layout.md +300 -0
- auto_optimize/skills/auto-optimize-code/references/main-session.md +45 -0
- auto_optimize/skills/auto-optimize-code/references/measuring.md +208 -0
- auto_optimize/skills/auto-optimize-code/references/pr-optimization.md +127 -0
- auto_optimize/skills/auto-optimize-code/references/pr-tests.md +254 -0
- auto_optimize/skills/auto-optimize-code/references/promotion.md +133 -0
- auto_optimize/skills/auto-optimize-code/references/reading-a-search.md +65 -0
- auto_optimize/skills/auto-optimize-code/references/repo-mode.md +224 -0
- auto_optimize/skills/auto-optimize-code/references/resume.md +81 -0
- auto_optimize/skills/auto-optimize-code/references/shared-knowledge.md +114 -0
- auto_optimize/skills/auto-optimize-code/references/step0-interview.md +298 -0
- auto_optimize/skills/auto-optimize-code/references/step1-unit-tests.md +136 -0
- auto_optimize/skills/auto-optimize-code/references/step2-baseline.md +708 -0
- auto_optimize/skills/auto-optimize-code/references/step3-rounds.md +350 -0
- auto_optimize/skills/auto-optimize-code/references/step4-final.md +121 -0
- auto_optimize/skills/auto-optimize-code/references/step5-ship.md +220 -0
- auto_optimize/skills/auto-optimize-code/references/step6-finish.md +67 -0
- auto_optimize/skills/auto-optimize-code/references/subagent.md +467 -0
- auto_optimize/skills/auto-optimize-code/references/symptoms.md +67 -0
- auto_optimize/skills/auto-optimize-code/references/writing-briefs.md +117 -0
- auto_optimize/skills/auto-optimize-code/scripts/attribution.py +156 -0
- auto_optimize/skills/auto-optimize-code/scripts/autoopt.py +12863 -0
- auto_optimize/skills/auto-optimize-code/scripts/check_seeding.py +334 -0
- auto_optimize/skills/auto-optimize-code/scripts/cold.py +90 -0
- auto_optimize/skills/auto-optimize-code/scripts/dashboard/README.md +165 -0
- auto_optimize/skills/auto-optimize-code/scripts/dashboard/autoopt_monitor.py +850 -0
- auto_optimize/skills/auto-optimize-code/scripts/dashboard/gpu_scan.py +954 -0
- auto_optimize/skills/auto-optimize-code/scripts/dashboard/monitor_writer.py +684 -0
- auto_optimize/skills/auto-optimize-code/scripts/dashboard/scan.py +1030 -0
- auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/dashboard.css +775 -0
- auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/dashboard.js +3652 -0
- auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/index.html +191 -0
- auto_optimize/skills/auto-optimize-code/scripts/issue_body.py +2118 -0
- auto_optimize/skills/auto-optimize-code/scripts/lint_text.py +448 -0
- auto_optimize/skills/auto-optimize-code/scripts/opt_pr_body.py +894 -0
- auto_optimize/skills/auto-optimize-code/scripts/opt_pr_tables.py +367 -0
- auto_optimize/skills/auto-optimize-code/scripts/paired.py +188 -0
- auto_optimize/skills/auto-optimize-code/scripts/preflight.py +280 -0
- auto_optimize/skills/auto-optimize-code/scripts/probe_run.py +72 -0
- auto_optimize/skills/auto-optimize-code/scripts/publish.py +385 -0
- auto_optimize/skills/auto-optimize-code/scripts/run_iteration.py +1382 -0
- auto_optimize/skills/auto-optimize-code/scripts/ship.py +1193 -0
- auto_optimize/skills/auto-optimize-code/scripts/stages.py +651 -0
- auto_optimize/skills/auto-optimize-code/scripts/tests_pr_body.py +1267 -0
- auto_optimize/skills/auto-optimize-code/scripts/tests_pr_push.py +426 -0
- auto_optimize/skills/auto-optimize-code/scripts/tests_pr_tables.py +779 -0
- auto_optimize-1.0.0.dist-info/METADATA +610 -0
- auto_optimize-1.0.0.dist-info/RECORD +67 -0
- auto_optimize-1.0.0.dist-info/WHEEL +4 -0
- auto_optimize-1.0.0.dist-info/entry_points.txt +2 -0
- auto_optimize-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# External validation
|
|
2
|
+
|
|
3
|
+
One or more measures computed **once a round** on inputs the search does not
|
|
4
|
+
otherwise touch: against the new root after each promotion. It may be slow.
|
|
5
|
+
It is **not a gate and not an observer**: it chooses nothing, rejects nothing,
|
|
6
|
+
and its numbers need not be comparable to the objective.
|
|
7
|
+
|
|
8
|
+
A search measures one input, and an optimization can fit itself to it: a
|
|
9
|
+
bitwise gate proved on one file says nothing about a larger input, an empty
|
|
10
|
+
one, or one of size 1.
|
|
11
|
+
|
|
12
|
+
`$AO` and `$WORK` are as in `SKILL.md`.
|
|
13
|
+
|
|
14
|
+
## Three rules
|
|
15
|
+
|
|
16
|
+
- **The user signs off before it ever runs.** Infer a good validation and
|
|
17
|
+
propose it: the command, what it measures, and what it costs per round.
|
|
18
|
+
Only after they say yes, run `validate $WORK --approve`; `validate`
|
|
19
|
+
refuses until then. Inferring the validation is your job; approving it is
|
|
20
|
+
not.
|
|
21
|
+
- **A bad result goes to the user, and nothing else changes.** Tell them
|
|
22
|
+
with the round's summary, which carries the record. Do not revert the root, do not turn the check into a gate
|
|
23
|
+
mid-search, and do not carry on as if it passed. Bit-exact on the
|
|
24
|
+
benchmark and wrong on a wider set is the finding.
|
|
25
|
+
- **Name the round and the iteration it ran against.**
|
|
26
|
+
|
|
27
|
+
## Choosing one
|
|
28
|
+
|
|
29
|
+
| Search | A validation that catches a win tuned to the benchmark's input |
|
|
30
|
+
|---|---|
|
|
31
|
+
| kernel speed, bitwise gate | the same bit-identity check over many inputs: bigger, smaller, a single element, degenerate shapes, other dtypes |
|
|
32
|
+
| a command-line tool's speed | real files of other sizes and formats, other flag combinations, the malformed inputs it must still reject |
|
|
33
|
+
| a latency change | the other entry points and batch shapes, the shapes production sends |
|
|
34
|
+
|
|
35
|
+
## Setting it up, at `init` (or `init --force` later)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
--validation-command 'python3 validate_all.py --iteration {iteration} --out {out}' \
|
|
39
|
+
--validation-measures n_inputs,n_bit_mismatches_all,largest_input \
|
|
40
|
+
--validation-note '12 input files, 40 to 5000 records, sizes 1 to 60'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The command must contain `{iteration}` and `{out}` and name at least one
|
|
44
|
+
measure. `{src}` (the worktree, as in `command`), `{round}`, `{id}`,
|
|
45
|
+
`{out_abs}` and `{cache}` (of the validated iteration's commit) are also
|
|
46
|
+
substituted. It runs with the iteration's directory as its working directory.
|
|
47
|
+
In plain mode that directory is the worktree, so a script copied in with
|
|
48
|
+
`--copy` resolves relatively, as above. In repository mode it holds only
|
|
49
|
+
records, and `--copy` puts the script in `autooptimize/harness/`: give its
|
|
50
|
+
absolute path in double quotes, and have it import from `{src}`:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
--validation-command "python3 $WORK/autooptimize/harness/validate_all.py --src {src} --iteration {iteration} --out {out}" \
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
It writes `<out>/validation.json`:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{"measures": {"n_inputs": 12, "n_bit_mismatches_all": 0},
|
|
60
|
+
"units": {"n_bit_mismatches_all": "elements"},
|
|
61
|
+
"ok": true, "note": "one input has a record of size 60"}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Every key is optional. A missing `ok` falls back to the script's exit code.
|
|
65
|
+
Name a unit for every measure that has one, here or in `config.json`'s
|
|
66
|
+
`external_validation.units` (added by hand; `init` has no flag). The
|
|
67
|
+
dashboard merges the two, the newest round's winning; a measure with no unit
|
|
68
|
+
is shown bare.
|
|
69
|
+
|
|
70
|
+
## Running it
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
python3 $AO/autoopt.py validate $WORK --round 3 # promote: orchestrator; with auto the runner runs it
|
|
74
|
+
python3 $AO/autoopt.py validate $WORK --dry-run # print the command
|
|
75
|
+
python3 $AO/autoopt.py validate $WORK --id A57 --out $DIR/validation # a subagent, on its own iteration
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| Flag | Meaning |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `--round N` | the round to file it under (default: the current one) |
|
|
81
|
+
| `--id` | the iteration to validate (default: the root); a label or a number, never a path |
|
|
82
|
+
| `--approve` | record the user's sign-off in `config.json` with the date, and run nothing |
|
|
83
|
+
| `--dry-run` | print the command and stop |
|
|
84
|
+
| `--out DIR` | with `--id`: write the output and `record.json` into `DIR`, and file no round record |
|
|
85
|
+
|
|
86
|
+
`validate` **always exits 0**, whatever it found, and never touches a
|
|
87
|
+
`result.json`, a status, or the frontier. A round's record lands in
|
|
88
|
+
`validations/round-<N>.json` (`round`, `iteration`, `command`, `seconds`,
|
|
89
|
+
`exit_code`, `measures`, `ok`, `note`, `created`). `summary --round N`
|
|
90
|
+
prints it under a heading saying it gated nothing, and the dashboard draws
|
|
91
|
+
each numeric measure over rounds (`references/dashboard.md`, *What to
|
|
92
|
+
look at*).
|
|
93
|
+
|
|
94
|
+
To have a subagent validate its own iteration, brief it with `brief
|
|
95
|
+
--validate`, which writes the `validate` command with its label and `$DIR`
|
|
96
|
+
filled in, as in the last line above. A brief never gives the validation
|
|
97
|
+
script itself: `validate` substitutes `{iteration}` as the path the script
|
|
98
|
+
expects.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Glossary
|
|
2
|
+
|
|
3
|
+
Every term with a fixed meaning. Other files use them exactly as defined here;
|
|
4
|
+
two words that look interchangeable are not.
|
|
5
|
+
|
|
6
|
+
## The unit of work
|
|
7
|
+
|
|
8
|
+
| Term | Meaning |
|
|
9
|
+
|---|---|
|
|
10
|
+
| **run** | one execution of the benchmark with one seed. Writes one `metrics.json` |
|
|
11
|
+
| **iteration** | one idea, measured by several runs and reduced to their median. One subagent, one worktree, one branch |
|
|
12
|
+
| **round** | the iterations forked from one root, closed by `promote`. One summary each. Numbered from 1; A0 carries round 0 |
|
|
13
|
+
| **width** | the concurrent runs one iteration can start, `gpus_per_agent` (without a GPU, the runs it starts at once): the concurrency step 2 measures. One iteration is in flight at a time |
|
|
14
|
+
| **settled** | has a `result.json`, whatever its status, `partial` included |
|
|
15
|
+
| **in flight** | running, finishing, or briefed and not yet spawned: what `end` refuses while. A finishing iteration is settled and still in flight |
|
|
16
|
+
| `running`, `finishing`, `STALLED` | `status`'s list of subagents still working, from which `brief --next` counts the free slot (one): `running` has no `result.json`; `finishing` is measured, has no `README.md`, and was written to within the hour; either is also `STALLED` after 15 minutes without a write, and still holds its slot until it is handed over |
|
|
17
|
+
|
|
18
|
+
## Who does what
|
|
19
|
+
|
|
20
|
+
| Term | Meaning |
|
|
21
|
+
|---|---|
|
|
22
|
+
| **the user** | the person who asked for the search. Decides gates, tolerances, the keep rule, external validation and anything off limits; at step 5, how to ship, which documents, the branch names, and whether the reviewed batch is posted |
|
|
23
|
+
| **main session** | the user's Claude Code session. Runs steps 0, 1, 4, 5 and 6, spawns the setup subagent and the first idea miner, opens each phase (`autoopt.py loop`), relays questions and shows round summaries; reads only `status --brief` and the reports it is handed (`references/main-session.md`) |
|
|
24
|
+
| **orchestrator**, **orchestrator subagent** | the subagent `autoopt.py loop` starts for each phase, from step 3 on. It spawns iteration subagents and later idea miners, briefs from `ideas.md`, reads `status --brief` and short reports, and hands questions and round summaries back to the main session. Measures, promotes (except with `promote: orchestrator`), and strikes nothing, checks no ledger, writes no summary prose, and reads no code, logs, READMEs or outputs |
|
|
25
|
+
| **phase** | one run of the orchestrator subagent, opened by `autoopt.py loop` and numbered from 1. It ends after `loop_handback` settled iterations, at *When to stop*, or with a question for the user. The noise band's reference spread is re-measured from the root when a phase opens and held for it |
|
|
26
|
+
| **setup subagent** | the subagent that does step 2, by `references/step2-baseline.md`: the benchmark, the gate proof, the checks, the width, A0, the first ledger entries and A0's README. Started by `autoopt.py setup`; asks the user through `setup --ask`; closed by `setup --done` |
|
|
27
|
+
| **idea miner** | a subagent that reviews the code, the ledger and the READMEs and appends ideas to `ideas.md`, by `references/idea-miner.md`. Started by `autoopt.py mine` once setup has closed (A0's profile exists) and whenever fewer than two untried ideas are left; one at a time |
|
|
28
|
+
| **stage**, `S<n>` | one run of the idea miner: one batch of ideas. `new` stamps the last finished stage on each iteration (`mining_stage`); the dashboard's stage boundaries fall where it changes. The unit of a search's budget when the user gives one in stages (`after.budget_stages`); a budget can also be iterations (`after.budget_iterations`) or hours (`after.budget_hours`). Not `result.json`'s `stage`, nor the six stages `stages.py` reports (below), nor the runner's stages 0 to 4 (`references/subagent.md`, *Checks beyond the runner*) |
|
|
29
|
+
| `interview`, `setup`, `search`, `final`, `ship`, `finish` | the six stages `stages.py` reports and the dashboard's strip shows, each `not started`, `running` or `complete`: steps 0, 2, 3, 4, 5 and 6 (step 1 has none). `final` is `end`'s step, not the command `autoopt.py final`; `finish` is step 6, not `autoopt.py finish` nor the `finishing` status |
|
|
30
|
+
| **check** | the task's own checks, written once at step 2 into `checks/`: the cold first call and the compare against A0's cached outputs, run by the runner before and between its runs (`references/subagent.md`, *Checks beyond the runner*) or by hand with `autoopt.py check`. Its `check:` line is in the report block |
|
|
31
|
+
| **subagent model** | `config.json`'s `subagent_model` (`opus`, `sonnet`, `haiku` or `fable`), the model every iteration subagent is spawned with; the miner and the orchestrator keep the session's |
|
|
32
|
+
| **subagent** | runs one iteration by `references/subagent.md`, writes its README and stops |
|
|
33
|
+
| **brief** | everything a subagent knows about its iteration, written by `autoopt.py brief` into `briefs/<id>.md`; the Agent call carries only a short prompt that has the subagent read it (`references/writing-briefs.md`) |
|
|
34
|
+
| **document writer** | the one subagent step 5 spawns on the GitHub route, from the prompt `ship.py brief` prints: it writes each chosen document's tables, prose and commit messages, renders each, and ends when `ship.py rehearse` exits 0 (`references/step5-ship.md`). Not the dashboard's publisher |
|
|
35
|
+
| **lease** | the GPUs one command holds while it runs, named by `CUDA_VISIBLE_DEVICES`: taken by the scripts themselves through `gpu_command`, the machine's allocator, or given as indices where there is none (`references/step2-baseline.md`, *GPU leases*) |
|
|
36
|
+
| **`gpu_command`** | the machine's GPU allocator, as the words that go before a command and run it with `CUDA_VISIBLE_DEVICES` set (`srun --gres=gpu:1`); see **lease** |
|
|
37
|
+
| **`workers`** | the worker, rank or thread count the task names; A0's runs must show that many threads running at once (`references/step2-baseline.md`, *The price of the base*) |
|
|
38
|
+
|
|
39
|
+
## Places
|
|
40
|
+
|
|
41
|
+
| Term | Meaning |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `<work>`, `$WORK` | the search's directory, chosen at step 0 (default offered: `~/auto-optimize/<YYYY-MM-DD>-<name>/`). Holds `autooptimize/` and later work on the search (`references/layout.md`, *The search directory*) |
|
|
44
|
+
| `$AO` | this skill's `scripts/` directory |
|
|
45
|
+
| `autooptimize/` | the search's record: `config.json`, `spec.md`, `state.json`, `ideas.md`, `knowledge.md`, `tools/`, `briefs/`, `setup/`, `reference/`, `repo.git/`, `iterations/`, `rounds/` (`references/layout.md`). `autoopt.py` accepts `<work>` or this directory |
|
|
46
|
+
| `$DIR` | one iteration's directory, `autooptimize/iterations/<id>/`, which `autoopt.py new` prints |
|
|
47
|
+
| **worktree**, `$SRC` | the iteration's code checkout: `$DIR` in plain mode, `$DIR/src` in repository mode. The brief gives both paths |
|
|
48
|
+
| **branch** | `autoopt/<id>` in `repo.git`: the parent's branch plus this iteration's commit |
|
|
49
|
+
| **plain mode** / **repository mode** | the benchmark and code copied in with `init --copy`, or an existing git repository copied with `init --repo` (`references/repo-mode.md`) |
|
|
50
|
+
| **the original** | the user's code the search copied: the files `config.json` `copied` names (plain mode), or the repository and branch `repo` records (repository mode; with a step-1 suite, `tests/branch.json`). Never written to before step 5, and then only on the user's yes |
|
|
51
|
+
| **step-1 suite** | the new unit tests step 1 writes on its own branch, one commit above the original's (`references/step1-unit-tests.md`). A0 includes it; the unit-test PR ships it; the optimization PR and a local branch leave it out. Not the unit-test gate, which runs whatever tests the search names |
|
|
52
|
+
| **benchmark** | the script one run executes; its output is `metrics.json` |
|
|
53
|
+
| **harness** | the benchmark in repository mode: `autooptimize/harness/`, outside every worktree, fixed for the whole search |
|
|
54
|
+
| **reference** | the baseline's saved outputs in `autooptimize/reference/`, which an identity gate compares every run to. Written only by A0 |
|
|
55
|
+
| **notes** | `$DIR/notes.md`, the subagent's prose; `autoopt.py finish` assembles it with the numbers into `README.md` |
|
|
56
|
+
| **publisher** | the background process that scans the search and publishes the dashboard's data (`references/dashboard.md`). Its files call it the writer (`monitor_writer.py`, `writer.log`); it is never the document writer |
|
|
57
|
+
| **probe** | a subagent's own script for a check the runner does not make (a fallback path, a sweep of variants), kept under `$DIR/probe/` |
|
|
58
|
+
|
|
59
|
+
## Names
|
|
60
|
+
|
|
61
|
+
| Spelling | Names |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `auto-optimize-code` | this skill |
|
|
64
|
+
| `auto-optimize` | the repository, the plugin and the installer; the default search root `~/auto-optimize/`; the branch prefix `auto-optimize/` (step 1's branch, and step 5's when `after.branch_prefix` is `yes`); the author of the iteration commits |
|
|
65
|
+
| `autooptimize/` | the search's record directory |
|
|
66
|
+
| `autoopt` | the scripts (`autoopt.py`), iteration branches (`autoopt/<id>`), the environment variable `AUTOOPT_REF`, the dashboard's files (`autoopt_monitor.py`, `~/autoopt-monitor/`) |
|
|
67
|
+
|
|
68
|
+
## Measures
|
|
69
|
+
|
|
70
|
+
| Term | Meaning |
|
|
71
|
+
|---|---|
|
|
72
|
+
| **objective** | the one number per run being improved, with a direction (`max` or `min`) |
|
|
73
|
+
| **gate** | a hard constraint checked on every run; one violating run fails the iteration. `{"name", "op", "threshold", "tol"}` |
|
|
74
|
+
| **observer** | a number recorded on every run, never optimized and never gated |
|
|
75
|
+
| **tracking measure** | an observer that is the objective on other inputs (`seconds_tiny`, the seconds on a second input) |
|
|
76
|
+
| **external validation** | a check on inputs the search never measures, run once a round, or by a subagent on its own iteration when a brief asks. Chooses nothing; runs only after the user signs off (`references/external-validation.md`) |
|
|
77
|
+
| **unit-test gate** | the package's tests, run once per iteration after its first run passes its gates. A failure is `gate-failed`. With `{selected}`, the runner runs a **subset**, the files for the changed modules, and then the full suite when the median passes the keep rule; `promote` refuses a subset-only pass |
|
|
78
|
+
| **noise band** | the wider of the reference spread (the standard deviation across the root's runs, re-measured each time a phase opens; A0's before the first) and this iteration's: the margin the default keep rule asks a median to beat its parent's by |
|
|
79
|
+
| **paired** | two versions compared in alternating separate processes, stopped by a sign test: `scripts/paired.py`. A search runs it once, at the end: `autoopt.py final`, A0 as A, the winner as B. Verdicts `B better`, `B worse`, `no difference resolved` |
|
|
80
|
+
| **control** | the unchanged parent, re-measured as its own iteration (briefed to a subagent with `brief --control`) or as a variant, to show what a measurement reads for no change. Never on the frontier and never promoted |
|
|
81
|
+
| **cold** | the first call in a fresh process with an empty compiler cache, timed by the runner with `scripts/cold.py` before each iteration's runs (`checks.first_call`) |
|
|
82
|
+
| **prediction** | the change an iteration is expected to make to its parent's median, in the objective's units: `--predict` |
|
|
83
|
+
| **floor** | a minimized objective's smallest value worth measuring (`config.json` `floor`, the user's at step 0): at it the search stops (`references/step3-rounds.md`, *When to stop*) |
|
|
84
|
+
| **price of the base** | what each later step that runs the base costs, from A0's seconds a run (`autoopt.py price`; `references/step2-baseline.md`, *The price of the base*) |
|
|
85
|
+
| **transplant** | a change moved from one search into another; priced again there, never assumed |
|
|
86
|
+
|
|
87
|
+
## Measuring an iteration
|
|
88
|
+
|
|
89
|
+
| Term | Meaning |
|
|
90
|
+
|---|---|
|
|
91
|
+
| **runs per iteration** | `runs_per_iteration`, chosen at step 0 (default 5): every iteration, A0 included, runs that many, one seed each, and its median is its result |
|
|
92
|
+
| **depth** | how many runs an iteration has; at full depth it has `runs_per_iteration` |
|
|
93
|
+
| `status` | `ok` (every run passed every gate, and the tests); `gate-failed`; `error` (a run crashed or wrote nothing usable); `partial` (fewer runs than `runs_per_iteration`: never compared to anything). **Passing** means `ok` |
|
|
94
|
+
|
|
95
|
+
## The tree
|
|
96
|
+
|
|
97
|
+
| Term | Meaning |
|
|
98
|
+
|---|---|
|
|
99
|
+
| **label** | the letter `A` and an iteration's number, `A107`, used wherever an id is written; a bare `107` names the same iteration. Directories and branches carry the bare number |
|
|
100
|
+
| **baseline** | A0: the unmodified code, measured like any iteration by the setup subagent at step 2 |
|
|
101
|
+
| **the base** | the original's code as the search copied it, which the winner is compared against and merged onto: a branch of a git repository (`init --repo`) or stand-alone code (`init --copy`). Not the baseline, which is A0, the iteration that measures the same code; with a step-1 suite, A0 is the base plus the suite. In `table`'s `vs_base` and `vs_base_pct`, and in gate names such as `n_mismatch_vs_base`, *base* means A0 |
|
|
102
|
+
| **parent** | the iteration a new one forks from; the current root unless a brief names another |
|
|
103
|
+
| **root** | the iteration new ones fork from: the last promoted iteration, or A0 before any |
|
|
104
|
+
| **promote** | make an `ok` iteration the root (`autoopt.py promote`), closing the round |
|
|
105
|
+
| **preflight** | `preflight.py`: the checks of a change's added lines that need no measurement, made at promotion (`references/promotion.md`, *The preflight*) |
|
|
106
|
+
| **keep rule** | what earns a promotion, written in `spec.md` before the first iteration: by default, a median beyond the noise band of the parent's, plus any **tie rule**, what the user said decides a tie (a compile-time cut, say). The runner applies the default rule and records its verdict as `keep`; it promotes on it with `promote: auto` |
|
|
107
|
+
| **frontier** | the best `ok` median so far, and the iteration holding it. Never a single run. The keep rule judges a child against its parent (the root unless a brief named another), so briefs, `status` and reports name the root as the reference and show a better median outside the root's path as "best median, not in the root" (kept out by the noise band, or passed but not promoted) |
|
|
108
|
+
| **frontier path** | the iterations that each beat everything before them, in id order: a record of progress, not a lineage. "On the frontier" in `status` and the dashboard means on this path |
|
|
109
|
+
| **path** to N | every iteration from A0 to N following parents, N included: `autoopt.py path --id N` |
|
|
110
|
+
| `best_run` | the single best run inside one iteration: one sample, never a score |
|
|
111
|
+
| **category** | what an idea changes: `MICRO`, `NUMBA`, `CACHING`, `CACHE_MISS`, `PRECISION`, `PARALLEL`, `REORGANIZATION`, `IO`, `ALGORITHM`, `OPTIMIZATION` (each defined in `references/idea-miner.md`). `MISC` is the catch-all; `ROOT` is the baseline's alone |
|
|
112
|
+
| **topic** | the block of ideas a subagent owns when the user divided work by topic |
|
|
113
|
+
| **toolchain-specific** | a change whose gain depends on a compiler's, version's, flag's or pass's decisions. The miner proposes none; a subagent that answers `yes` in `notes.md`'s `## Toolchain` closes it, and `promote` refuses it (`references/subagent.md`, *Portability*) |
|
|
114
|
+
|
|
115
|
+
## After the search
|
|
116
|
+
|
|
117
|
+
| Term | Meaning |
|
|
118
|
+
|---|---|
|
|
119
|
+
| **winner** | the iteration `--id best` names: the best median among the root and the iterations descending from it that passed the keep rule (its code holds every kept change; a better median outside the root's line does not); after `end`, `ended.json`'s. `best` is the literal value of `--id`, the default of `final`, `end`, `path`, `show`, `archive`, `autoopt.py pr`, `opt_pr_tables.py`, `preflight.py`, `ship.py apply` and `ship.py branch` |
|
|
120
|
+
| **winning iteration** | an iteration on the path to the winner, A0 excluded, whose code differs from its parent's (`ended.json` `winning_iterations`) |
|
|
121
|
+
| **kept change** | one winning iteration's change against its parent. `ship.py branch` and the optimization PR make one commit of each. Not an iteration `reset --keep` keeps |
|
|
122
|
+
| **ended** | the state after `autoopt.py end`: `ended.json` records it (`references/step4-final.md`); `end --reopen` undoes it until step 5 applies the change, makes a branch or posts any document (a **hold**) |
|
|
123
|
+
| **`--after-end`** | the flag of `new` and `brief` for an iteration made after `end`, the only kind made then; promoted, it becomes the winner (`references/step4-final.md`, *An iteration made after the end*) |
|
|
124
|
+
| **ship**, **shipping** | step 5: the winner taken back to the original, on the user's choice (`after.ship`): applied to the original files (`apply`), a branch in the original repository (`branch`), the GitHub documents they check (`github`), or not now (`none`) (`references/step5-ship.md`). Shipping applies, makes a branch or posts; it never publishes, which is the dashboard publisher's word |
|
|
125
|
+
| `after` | `config.json`'s answers about what follows the search: eleven asked at step 0 and five at step 5 (`ship`, `ship_documents`, `branch_prefix`, `pr_remote`, `pr_head_owner`). `ask` means not yet answered (`references/layout.md`, *config.json*) |
|
|
126
|
+
| **document** | one of what step 5 opens on GitHub: the optimization PR, the unit-test PR, the bug report; each in its folder under `$WORK/ship/`, rendered from tables and prose (`references/documents.md`) |
|
|
127
|
+
| **target branch** | the original's branch a PR opens on and a local branch starts from. A document names it (`main`) where the search would say "the base" |
|
|
128
|
+
| **stand-in** | `#<bug issue>` or `#<tests PR>` in a document drafted before that number exists; filled when the document it names is posted |
|
|
129
|
+
| **rehearsal** | `ship.py rehearse`: every chosen document rendered and previewed together, and a digest of their inputs; `ship.py post` posts only the batch with that digest |
|
|
130
|
+
| **hold** | one entry of `autooptimize/reopen-lock.json`, `{"by", "reason", "at"}`, written by `ship.py apply --yes`, `ship.py branch --yes` and each posted document; while one exists, `end --reopen` refuses |
|
|
131
|
+
| **move** | one line of `stages.py next`, with its kind: `run` (a script; `--run` starts it), `wait` (`end` is finishing), `agent` (the session does it), `stop` (the user answers). Once every stage is complete, `next` prints `every stage is complete` and nothing else |
|
|
132
|
+
| **prune** | delete regenerable artifacts, keeping every record (`autoopt.py prune`) |
|
|
133
|
+
| **reset** | delete every iteration but the kept ones, records included (`autoopt.py reset`) |
|
|
134
|
+
| `<<FILL: …>>` | the placeholder a generated skeleton leaves where prose goes (`notes.md`, the final report, each document's `prose.md`). The command that consumes the file refuses while one is left |
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# The idea miner: reviewing the code for ideas
|
|
2
|
+
|
|
3
|
+
You read code and write ideas. You edit no code, run no benchmark and time
|
|
4
|
+
nothing: the baseline or the iterations are timing on this machine while you
|
|
5
|
+
work. Write no code to test an idea either: the iteration that takes it
|
|
6
|
+
measures the speed and checks the output, so *Gain* and *Exact* are your
|
|
7
|
+
reading of the code. Do not read the skill's scripts or probe the machine;
|
|
8
|
+
the setup subagent proves the harness at step 2. Your prompt (`autoopt.py
|
|
9
|
+
mine`) gives the paths, your stage `S<n>`, the code to review, the spec's
|
|
10
|
+
rules and the categories to use. A term you do not know is in
|
|
11
|
+
`references/glossary.md`; read it for that only.
|
|
12
|
+
|
|
13
|
+
## Read first
|
|
14
|
+
|
|
15
|
+
Your first turn reads your prompt, this file, `knowledge.md` and `ideas.md`
|
|
16
|
+
together, as your prompt lists.
|
|
17
|
+
|
|
18
|
+
1. `knowledge.md`: settled facts and `[closed]` ideas. Propose nothing it
|
|
19
|
+
closed. Take *Gain* from your prompt's *The profile of* section, the root
|
|
20
|
+
you review (or its nearest ancestor with one), and from the ledger's
|
|
21
|
+
`[code:<subsystem>]` entries only without it.
|
|
22
|
+
2. `ideas.md`: what is queued or tried. Repeat nothing; a variant of a tried
|
|
23
|
+
idea needs a reason the first attempt did not cover.
|
|
24
|
+
3. From stage S2 on, your prompt's *Settled since the last stage*: what became
|
|
25
|
+
of each iteration, and its README's *What to try next*, which becomes
|
|
26
|
+
ideas. Read a README's *Notes and failures* only for an idea you build
|
|
27
|
+
on.
|
|
28
|
+
4. The code, read only, starting from what one run calls: your prompt's
|
|
29
|
+
*What one run does* line, and the harness (repository mode:
|
|
30
|
+
`autooptimize/harness/`; plain mode: the benchmark in the baseline's
|
|
31
|
+
directory) only for what the line leaves out. A miner started with `mine
|
|
32
|
+
--without-profile` may run before the benchmark exists: then start from
|
|
33
|
+
the function the spec's task names. Your prompt's
|
|
34
|
+
*The code* lists each source file with its line count, and each Python
|
|
35
|
+
function with its line, the profile's files first: go from it straight to
|
|
36
|
+
`sed -n` ranges, not to `ls`, `find` or whole files. Follow the calls the objective's time is spent in.
|
|
37
|
+
Read with `grep -n` and `sed -n` ranges, not whole large files.
|
|
38
|
+
|
|
39
|
+
## The categories
|
|
40
|
+
|
|
41
|
+
| Category | Look for |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `MICRO` | a small local change with a large effect: a hoisted invariant, a removed copy or conversion, a cheaper operation in a hot loop |
|
|
44
|
+
| `NUMBA` | multi-step Python or numpy code (several passes, temporaries, a Python loop) that one custom numba function does in a single pass. In compiled code, file the same fusion under `MICRO` or `REORGANIZATION` |
|
|
45
|
+
| `CACHING` | an intermediate result computed more than once, or on every call, that can be stored and reused later |
|
|
46
|
+
| `CACHE_MISS` | operations reordered to avoid cache misses: strided or scattered access, a loop order against the memory layout, an array of structs where a struct of arrays fits, a working set past L2 |
|
|
47
|
+
| `PRECISION` | a wider dtype than the values need: `int64` for counts under 128 fits `int8`, `float64` for an approximate quantity |
|
|
48
|
+
| `PARALLEL` | a serial loop or map whose steps are independent, which threads or processes can split with little change |
|
|
49
|
+
| `REORGANIZATION` | a broad restructuring that enables caching or parallelism the current shape blocks: batching calls, splitting a pass, a data structure changed across modules |
|
|
50
|
+
| `IO` | time in reading, writing, parsing, decompressing or formatting: fewer passes over a file, larger or batched reads and writes, a parser that skips fields the call never uses, a cheaper intermediate format, memory mapping, overlapping I/O with compute |
|
|
51
|
+
| `ALGORITHM` | a different algorithm or data structure for a step, with less work asymptotically or in the constant (a sort, a search, a lookup, an index, a pruned search space, an approximation that keeps the output), more than a local tweak |
|
|
52
|
+
| `OPTIMIZATION` | any other optimization |
|
|
53
|
+
|
|
54
|
+
`MISC` is a change that is not an optimization (a fix); the miner files none under it.
|
|
55
|
+
|
|
56
|
+
## What makes an idea usable
|
|
57
|
+
|
|
58
|
+
- **It can pass the gates.** Under a bitwise gate, a lower precision or a
|
|
59
|
+
reordered floating-point reduction changes the output: write that under
|
|
60
|
+
*Exact*, and drop an idea the gate rules out unless a guard with a fallback
|
|
61
|
+
keeps the output (say so). Respect *Off limits* and *Portability*.
|
|
62
|
+
- **It works on any OS, compiler and CPU.** Propose nothing that needs one: a compiler-specific flag or pragma, `-march=native` or an intrinsic, a syscall or `/proc` read, a size or thread count fit to this machine, a GPU-generation feature; even where *Portability* names this machine's OS only. A run-time choice with an identical-output fallback is allowed.
|
|
63
|
+
- **It is not toolchain-specific.** No change whose gain depends on a compiler's decisions: a hint, pragma, flag, LTO or source order that steers inlining, or a gain explained by a compiler or pass; hints on a new function are allowed, even where *Off limits* lists compiler flags (`references/subagent.md`, *Portability*, Toolchain).
|
|
64
|
+
- **It vectorizes portably** (`references/subagent.md`, *Portability*, Vectorizing): numba in Python, else restructure for the compiler; never raw intrinsics.
|
|
65
|
+
- **It names its place**: `file:function`, or a line range.
|
|
66
|
+
- **Gain comes from the profile** as the share of the call the idea could
|
|
67
|
+
remove, or reads "unmeasured". Never invent a number. A function the
|
|
68
|
+
profile does not name is probably not on the timed path: say so in the
|
|
69
|
+
line, or drop it.
|
|
70
|
+
- **One change per idea.** Changes that each stand alone are separate lines;
|
|
71
|
+
four settings of one parameter are one idea, swept by one iteration.
|
|
72
|
+
- **Most promising first**: expected gain, times the chance it holds, against
|
|
73
|
+
the work.
|
|
74
|
+
|
|
75
|
+
## Writing them down
|
|
76
|
+
|
|
77
|
+
1. Write your stage file (its path is in your prompt): the idea lines, in
|
|
78
|
+
`ideas.md`'s form, then a `## Notes` section with anything longer an idea
|
|
79
|
+
needs (a sketch, the evidence, the lines read):
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
- [CATEGORY] where (file:function): what to change. Why: why it should help. Gain: the share of the call it could remove, or unmeasured. Exact: bit-identical, within tolerance, or changes outputs. (S<n>)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
2. A fact you established while reading (where the time goes, a caller the
|
|
86
|
+
benchmark never exercises) is a ledger entry, with `(S<n>, root <label>)`
|
|
87
|
+
in place of an iteration's label: write the entries, one a line, to the
|
|
88
|
+
entries file your prompt names (`mining/ledger-S<n>.txt`).
|
|
89
|
+
3. Close the stage: `python3 $AO/autoopt.py mine $WORK --done`. It appends
|
|
90
|
+
the stage file's idea lines to `ideas.md` and the entries file to
|
|
91
|
+
`knowledge.md`, each under its lock; the notes stay in the stage file. It
|
|
92
|
+
refuses, with nothing written, an idea under no known category or a
|
|
93
|
+
correction that matches no entry; fix the file and call it again, since
|
|
94
|
+
nothing is appended twice.
|
|
95
|
+
|
|
96
|
+
## What to report back
|
|
97
|
+
|
|
98
|
+
Exactly this, and nothing more:
|
|
99
|
+
|
|
100
|
+
1. The number of ideas per category.
|
|
101
|
+
2. The three you would brief first, one line each.
|
|
102
|
+
3. At most two sentences: a ledger entry or README premise you found false
|
|
103
|
+
first, then anything else the agent that spawned you must know: the main
|
|
104
|
+
session at S1, the orchestrator from S2 on.
|
|
105
|
+
|
|
106
|
+
If writing a file was refused, return the idea lines in your report instead:
|
|
107
|
+
the agent that spawned you writes them to the stage's file and closes the
|
|
108
|
+
stage (`mine --done`).
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# The bug report
|
|
2
|
+
|
|
3
|
+
Bugs that step 1 found in the base while writing the unit tests
|
|
4
|
+
(`references/step1-unit-tests.md`, *It passes on the base, in every
|
|
5
|
+
configuration the repository's CI runs*) are filed as one
|
|
6
|
+
bug report, a GitHub issue on the original's repository. It is posted first
|
|
7
|
+
of the step 5 documents, so the unit-test PR and the optimization PR can name
|
|
8
|
+
its number. A bug an existing GitHub issue already reports is cited in
|
|
9
|
+
`related`, not filed again (`dupes`, below).
|
|
10
|
+
|
|
11
|
+
Step 1 leaves one folder per bug in `$WORK/tests/work/bugs/<short-name>/`:
|
|
12
|
+
what the base does, what it should do, a command that reproduces it, and the
|
|
13
|
+
tests removed. The document writer turns those folders into the inputs below.
|
|
14
|
+
Everything lives in `I=$WORK/ship/issue-bugs`; every flag is in
|
|
15
|
+
`python3 $AO/issue_body.py <command> --help`.
|
|
16
|
+
|
|
17
|
+
The document writer writes one row per bug and the sentences, commands and outputs;
|
|
18
|
+
`issue_body.py` writes the rest: the layout of
|
|
19
|
+
[haowenz/chromap#210](https://github.com/haowenz/chromap/issues/210) (the
|
|
20
|
+
first paragraph, severity table, introduction, setup block, a section per
|
|
21
|
+
category, a paragraph and a collapsed reproduction per bug), every heading,
|
|
22
|
+
and the numbering. It refuses to render a bug whose
|
|
23
|
+
reproduction was not rerun on the base binary as shown, and any wording
|
|
24
|
+
`lint_text.py` refuses in a posted document. The same inputs give the
|
|
25
|
+
same body byte for byte, and a refusal lists every problem on stderr.
|
|
26
|
+
|
|
27
|
+
## What the document writer decides
|
|
28
|
+
|
|
29
|
+
**Category**, one per bug, which also orders and numbers them 1 to N: wrong
|
|
30
|
+
output, crash, nondeterminism, silent acceptance of bad input, performance,
|
|
31
|
+
documentation mismatch, misc. `misc` is the last section and holds a bug none of
|
|
32
|
+
the others fits: use the closest named category first, and say in the bug's
|
|
33
|
+
text why it is neither. A bug with several effects is listed once under its
|
|
34
|
+
first, and its `effect` lists all.
|
|
35
|
+
|
|
36
|
+
**Severity**, one of three, the document writer's estimate of how likely a user is to
|
|
37
|
+
meet the bug and what it costs them:
|
|
38
|
+
|
|
39
|
+
| Severity | Means |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `high` | likely to be met in ordinary use, with wrong output or a crash |
|
|
42
|
+
| `medium` | needs unusual input, options or an environment, or costs time rather than correctness |
|
|
43
|
+
| `low` | an edge case, malformed input, a rarely used option, or a documentation mismatch |
|
|
44
|
+
|
|
45
|
+
Most bugs a test suite finds are `medium` or `low`; rate one `high` only when
|
|
46
|
+
a reproduction from the tool's documented, ordinary use shows it.
|
|
47
|
+
|
|
48
|
+
**The title** starts with a capital letter, has no closing period and is at
|
|
49
|
+
most 72 characters: `Bugs found while testing chromap 949043c`. It carries
|
|
50
|
+
no prefix.
|
|
51
|
+
|
|
52
|
+
**Tone.** Write for the tool's authors: what happens, with the numbers the
|
|
53
|
+
reproduction shows; what was expected and its source (README, manual page,
|
|
54
|
+
`-h`, a specification); the code responsible with file:line and a fix, hedged
|
|
55
|
+
("appears to", "we believe", "would fix it"). No blame or adjectives; the
|
|
56
|
+
renderer names any blunt word it refuses.
|
|
57
|
+
|
|
58
|
+
**Reproductions** are minimal and self-contained: inputs built by the setup (a
|
|
59
|
+
seeded random reference, say), not downloaded, printing only the lines that
|
|
60
|
+
show the bug, running in seconds. Public data only when no synthetic input
|
|
61
|
+
shows the bug; the bug's `context` says how much it downloads and how long it
|
|
62
|
+
runs.
|
|
63
|
+
|
|
64
|
+
## The inputs
|
|
65
|
+
|
|
66
|
+
`bugs.tsv`, tab-separated, header `number slug title short category severity
|
|
67
|
+
effect related` (`short` may be left out):
|
|
68
|
+
|
|
69
|
+
| Column | Holds |
|
|
70
|
+
|---|---|
|
|
71
|
+
| `number` | 1 to N, once each (`renumber` fixes the order) |
|
|
72
|
+
| `slug` | lower-case letters, digits, hyphens; names the verify log |
|
|
73
|
+
| `title` | the `###` heading after "N. ", no closing period |
|
|
74
|
+
| `short` | the table's Bug cell, or `-` for the title |
|
|
75
|
+
| `category`, `severity` | as above |
|
|
76
|
+
| `effect` | categories separated by semicolons, the bug's own first, each with an optional qualifier in parentheses: `crash; wrong output`, `wrong output (test-only option)` |
|
|
77
|
+
| `related` | `-`, or the text after "Related: ", naming at least one `#N` or URL: `#172, where --chr-order is suggested` |
|
|
78
|
+
|
|
79
|
+
`prose.md`: fields that each start with a line `=== <field>`; no other line
|
|
80
|
+
may start with `=== `. `issue_body.py template $I > $I/prose.md` writes one
|
|
81
|
+
`<<FILL: …>>` per field. Paragraphs may wrap; prose holds no headings,
|
|
82
|
+
placeholders, code fences in commands, or the fixed sentences.
|
|
83
|
+
|
|
84
|
+
| Field | Required | Holds |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `opening` | yes | one complete sentence of the document writer's own, on one line, starting with a capital letter and ending with a period: "These bugs turned up while we wrote a test suite for chromap (#209)." It says what was being done when the bugs turned up, and names no tool or group behind the report. The renderer follows it, in the same paragraph, with the two fixed sentences of `attribution.ISSUE_NOTES`: many of the bugs are likely edge cases, and what the severity levels mean |
|
|
87
|
+
| `intro` | yes | the version, the commit (the one `verify --commit` records), the build (compiler, flags) and the platform the bugs were reproduced on; which bugs need a special build or harness; which came from which part of the work |
|
|
88
|
+
| `reading` | no | how to read the report; without it, a default sentence |
|
|
89
|
+
| `setup.context`, `setup` | no | what the shared setup needs and makes; the shell commands every reproduction starts from |
|
|
90
|
+
| `<n>.what` | yes | one paragraph: what happens; it may end with a semicolon, colon or comma and run on into `expected` |
|
|
91
|
+
| `<n>.expected` | yes | one paragraph: what should happen, and the source of that |
|
|
92
|
+
| `<n>.cause` | yes | one paragraph: the code responsible and a fix |
|
|
93
|
+
| `<n>.context` | no | what the reproduction needs beyond the setup, shown before its commands |
|
|
94
|
+
| `<n>.reproduction` | yes | shell commands |
|
|
95
|
+
| `<n>.output` | yes | a paragraph starting "Expected", then one starting "Actual" followed by a fenced block of the actual output, cut to the lines that show the bug (`...` marks a cut). `verify` passes the bug when every line of that block is printed by the reproduction |
|
|
96
|
+
| `<n>.varies` | no | regular expressions, one per line, for values that change between runs (timings); masked in the comparison and not shown |
|
|
97
|
+
|
|
98
|
+
## Verify, then render
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
I=$WORK/ship/issue-bugs; B=<the base build of the tool>; mkdir -p $I/work
|
|
102
|
+
python3 $AO/issue_body.py template $I > $I/prose.md # once, after bugs.tsv
|
|
103
|
+
python3 $AO/issue_body.py dupes $I --repo <owner/repo> # candidates in dupes.tsv, then fill `related`
|
|
104
|
+
python3 $AO/issue_body.py verify $I --bin <tool>=$B --commit <sha> --workdir $I/work [--bug N | --stale]
|
|
105
|
+
python3 $AO/issue_body.py verify $I --bin <tool>=$B --commit <sha> --manual N --reason '<clause>' --log <earlier run's output>
|
|
106
|
+
python3 $AO/issue_body.py status $I [--bin <tool>=$B] # where the inputs stand; what render would refuse
|
|
107
|
+
python3 $AO/issue_body.py $I --title 'Bugs found while testing <tool> <sha>' --out $I/body.md --bin <tool>=$B
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`dupes` makes one read-only `gh issue list` call; `--issues FILE` reads the
|
|
111
|
+
JSON of `gh issue list --state all --json number,title,state,url,body`
|
|
112
|
+
instead. Its candidates are a list to read, not a verdict.
|
|
113
|
+
|
|
114
|
+
`verify` runs each bug's setup and reproduction in its own temporary
|
|
115
|
+
directory with the binary first on the PATH under `<tool>`; the exit code is
|
|
116
|
+
recorded, not judged, since a reproduction often ends on a failing command.
|
|
117
|
+
Put a long set in the background (`(… ; echo "exit $?") > $I/verify.log 2>&1
|
|
118
|
+
&`, then `autoopt.py wait $I/verify.log`) and check the free cores first
|
|
119
|
+
(`--cpus LIST` pins it).
|
|
120
|
+
|
|
121
|
+
**Every edit to the setup, a reproduction, an actual block or a mask means
|
|
122
|
+
running verify again** for the bugs it touches (all, for the setup). Prose
|
|
123
|
+
edits elsewhere need none. `--stale` runs exactly the bugs that need it and
|
|
124
|
+
reports a stale manual row without running anything.
|
|
125
|
+
|
|
126
|
+
**`manual`** is for a bug that needs a special build, a harness or data
|
|
127
|
+
`verify` cannot provide: `--reason` is a clause the body shows ("it needs a
|
|
128
|
+
clang++/libomp build"), `--log` the output of the run that showed it. Mark
|
|
129
|
+
only what cannot run here, never to get past a failure.
|
|
130
|
+
|
|
131
|
+
**The trust model.** The reproductions are the document writer's own text, written from
|
|
132
|
+
its own runs, and `verify` runs them with the user's privileges and no
|
|
133
|
+
sandbox. Never put commands copied from an issue, a PR or a web page
|
|
134
|
+
into `prose.md`, and read every reproduction before the first verify.
|
|
135
|
+
|
|
136
|
+
**Adding, dropping and renumbering.** A number appears in `bugs.tsv`, in every
|
|
137
|
+
`<n>.` field, in `verify.tsv` and in `verify-logs/`; never renumber by hand.
|
|
138
|
+
To add a bug, append its row under any unused number (99, say), write its
|
|
139
|
+
`99.*` fields, run `issue_body.py renumber $I`, then `verify --stale`.
|
|
140
|
+
`--drop 4,9` and `--only 1,3,5` keep fewer bugs. The originals go to
|
|
141
|
+
`$I/before-renumber-<time>/`. Numbers inside sentences ("bug 3 needs a clang++
|
|
142
|
+
build") are reported on stderr, not rewritten: edit those by hand.
|
|
143
|
+
|
|
144
|
+
**Length.** GitHub refuses a body or comment over 65,536 characters. Past
|
|
145
|
+
62,000 (`--limit`), `render` moves the longest reproductions into
|
|
146
|
+
`body.comment-1.md`, `-2.md` and on, in bug order, each bug keeping its
|
|
147
|
+
paragraph and a pointer to its comment. They are posted in order right after the issue. It refuses
|
|
148
|
+
when the prose alone, or one reproduction alone, is over the limit: cut the
|
|
149
|
+
output to the lines that show the bug, or file fewer bugs.
|
|
150
|
+
|
|
151
|
+
## Filing it
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
python3 $AO/issue_body.py file $I --repo <owner/repo> # preview: posts nothing
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The preview shows the repository, the title, each comment with its bugs and
|
|
158
|
+
size, and what the post needs. It refuses a body that is not what the inputs
|
|
159
|
+
render to now.
|
|
160
|
+
|
|
161
|
+
No document is posted on its own. All the chosen documents are reviewed
|
|
162
|
+
together and then posted together: `python3 $AO/ship.py rehearse $WORK`,
|
|
163
|
+
then `python3 $AO/ship.py post $WORK all --approved --digest D`, both
|
|
164
|
+
described in `references/step5-ship.md`, which also says what `D` is. The
|
|
165
|
+
bug report goes first: `issue_body.py file $I --repo <owner/repo>
|
|
166
|
+
--post` creates the issue, posts each comment in order, and records them in
|
|
167
|
+
`$I/filed.json` (the repository, the issue's URL and number, the title, a
|
|
168
|
+
digest of the title and body, the date, the URL of each comment posted, and
|
|
169
|
+
`comments_left`, the number still to post). The bug report counts as posted
|
|
170
|
+
only once `comments_left` is 0. A second run posts nothing, or only the
|
|
171
|
+
comments a failure left, and never opens a second issue; it refuses when the
|
|
172
|
+
title or body is no longer the one the issue was created with. `ship.py post`
|
|
173
|
+
then renders the other documents again, which puts the issue's number where
|
|
174
|
+
they hold `#<bug issue>`.
|
|
175
|
+
|
|
176
|
+
`file --post` refuses a repository the account `gh` is logged in as does not
|
|
177
|
+
own unless `--other-owner` is given, and `ship.py post` takes the same flag;
|
|
178
|
+
pass it only once the user has confirmed the repository. The preview's
|
|
179
|
+
`post needs:` lines say whether it is needed.
|
|
180
|
+
|
|
181
|
+
`issue_body.py link $I FILE… [--placeholder '#<tests PR>' --value '#N']` fills
|
|
182
|
+
a number into the given files by hand, with or without `filed.json`.
|