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.
Files changed (67) hide show
  1. auto_optimize/__init__.py +3 -0
  2. auto_optimize/__main__.py +5 -0
  3. auto_optimize/cli.py +651 -0
  4. auto_optimize/skills/auto-optimize-code/LICENSE +21 -0
  5. auto_optimize/skills/auto-optimize-code/SKILL.md +251 -0
  6. auto_optimize/skills/auto-optimize-code/VERSION +1 -0
  7. auto_optimize/skills/auto-optimize-code/references/algorithm.md +182 -0
  8. auto_optimize/skills/auto-optimize-code/references/changes.md +146 -0
  9. auto_optimize/skills/auto-optimize-code/references/cli.md +206 -0
  10. auto_optimize/skills/auto-optimize-code/references/dashboard.md +203 -0
  11. auto_optimize/skills/auto-optimize-code/references/documents.md +55 -0
  12. auto_optimize/skills/auto-optimize-code/references/extending.md +87 -0
  13. auto_optimize/skills/auto-optimize-code/references/external-validation.md +98 -0
  14. auto_optimize/skills/auto-optimize-code/references/glossary.md +134 -0
  15. auto_optimize/skills/auto-optimize-code/references/idea-miner.md +108 -0
  16. auto_optimize/skills/auto-optimize-code/references/issue-bugs.md +182 -0
  17. auto_optimize/skills/auto-optimize-code/references/layout.md +300 -0
  18. auto_optimize/skills/auto-optimize-code/references/main-session.md +45 -0
  19. auto_optimize/skills/auto-optimize-code/references/measuring.md +208 -0
  20. auto_optimize/skills/auto-optimize-code/references/pr-optimization.md +127 -0
  21. auto_optimize/skills/auto-optimize-code/references/pr-tests.md +254 -0
  22. auto_optimize/skills/auto-optimize-code/references/promotion.md +133 -0
  23. auto_optimize/skills/auto-optimize-code/references/reading-a-search.md +65 -0
  24. auto_optimize/skills/auto-optimize-code/references/repo-mode.md +224 -0
  25. auto_optimize/skills/auto-optimize-code/references/resume.md +81 -0
  26. auto_optimize/skills/auto-optimize-code/references/shared-knowledge.md +114 -0
  27. auto_optimize/skills/auto-optimize-code/references/step0-interview.md +298 -0
  28. auto_optimize/skills/auto-optimize-code/references/step1-unit-tests.md +136 -0
  29. auto_optimize/skills/auto-optimize-code/references/step2-baseline.md +708 -0
  30. auto_optimize/skills/auto-optimize-code/references/step3-rounds.md +350 -0
  31. auto_optimize/skills/auto-optimize-code/references/step4-final.md +121 -0
  32. auto_optimize/skills/auto-optimize-code/references/step5-ship.md +220 -0
  33. auto_optimize/skills/auto-optimize-code/references/step6-finish.md +67 -0
  34. auto_optimize/skills/auto-optimize-code/references/subagent.md +467 -0
  35. auto_optimize/skills/auto-optimize-code/references/symptoms.md +67 -0
  36. auto_optimize/skills/auto-optimize-code/references/writing-briefs.md +117 -0
  37. auto_optimize/skills/auto-optimize-code/scripts/attribution.py +156 -0
  38. auto_optimize/skills/auto-optimize-code/scripts/autoopt.py +12863 -0
  39. auto_optimize/skills/auto-optimize-code/scripts/check_seeding.py +334 -0
  40. auto_optimize/skills/auto-optimize-code/scripts/cold.py +90 -0
  41. auto_optimize/skills/auto-optimize-code/scripts/dashboard/README.md +165 -0
  42. auto_optimize/skills/auto-optimize-code/scripts/dashboard/autoopt_monitor.py +850 -0
  43. auto_optimize/skills/auto-optimize-code/scripts/dashboard/gpu_scan.py +954 -0
  44. auto_optimize/skills/auto-optimize-code/scripts/dashboard/monitor_writer.py +684 -0
  45. auto_optimize/skills/auto-optimize-code/scripts/dashboard/scan.py +1030 -0
  46. auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/dashboard.css +775 -0
  47. auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/dashboard.js +3652 -0
  48. auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/index.html +191 -0
  49. auto_optimize/skills/auto-optimize-code/scripts/issue_body.py +2118 -0
  50. auto_optimize/skills/auto-optimize-code/scripts/lint_text.py +448 -0
  51. auto_optimize/skills/auto-optimize-code/scripts/opt_pr_body.py +894 -0
  52. auto_optimize/skills/auto-optimize-code/scripts/opt_pr_tables.py +367 -0
  53. auto_optimize/skills/auto-optimize-code/scripts/paired.py +188 -0
  54. auto_optimize/skills/auto-optimize-code/scripts/preflight.py +280 -0
  55. auto_optimize/skills/auto-optimize-code/scripts/probe_run.py +72 -0
  56. auto_optimize/skills/auto-optimize-code/scripts/publish.py +385 -0
  57. auto_optimize/skills/auto-optimize-code/scripts/run_iteration.py +1382 -0
  58. auto_optimize/skills/auto-optimize-code/scripts/ship.py +1193 -0
  59. auto_optimize/skills/auto-optimize-code/scripts/stages.py +651 -0
  60. auto_optimize/skills/auto-optimize-code/scripts/tests_pr_body.py +1267 -0
  61. auto_optimize/skills/auto-optimize-code/scripts/tests_pr_push.py +426 -0
  62. auto_optimize/skills/auto-optimize-code/scripts/tests_pr_tables.py +779 -0
  63. auto_optimize-1.0.0.dist-info/METADATA +610 -0
  64. auto_optimize-1.0.0.dist-info/RECORD +67 -0
  65. auto_optimize-1.0.0.dist-info/WHEEL +4 -0
  66. auto_optimize-1.0.0.dist-info/entry_points.txt +2 -0
  67. auto_optimize-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,467 @@
1
+ # Running one iteration: the subagent's protocol
2
+
3
+ You implement **one** idea, measure it, write it up, and stop.
4
+
5
+ Your brief gives every path absolute: `AO` (the scripts), `WORK` (holds
6
+ `autooptimize/`), `DIR` (your records) and `SRC` (your worktree: `DIR` in
7
+ plain mode, `DIR/src` in repository mode). The rules it quotes from `spec.md`
8
+ bind you as much as this file does. A term you do not know is in
9
+ `references/glossary.md`; read it for that only.
10
+
11
+ **GPUs.** Your brief's GPU line is one of two. *An allocator command*: run
12
+ `run_iteration.py` bare, it takes and waits for the lease itself, and put the
13
+ allocator's words before every other command that runs the code (`paired.py`,
14
+ `cold.py`, `checkers`, `validate`, your probes). *Indices*: prefix every
15
+ command that runs the code with `CUDA_VISIBLE_DEVICES=<them>`. Never read
16
+ `nvidia-smi` and pick a device yourself (`references/step2-baseline.md`, *GPU
17
+ leases*).
18
+
19
+ ## The sequence
20
+
21
+ **1. Your first turn** makes the calls your prompt lists, together: it
22
+ reads your brief, this file, the ledger (`knowledge.md`) and the `tools/` and
23
+ `tools/checkers/` READMEs, and runs `new --brief`, which prints `$DIR` and
24
+ creates a git worktree on branch `autoopt/<id>` holding exactly the code the
25
+ parent ran. A premise the ledger settled is not measured again; a helper or
26
+ checker in `tools/` is reused, not rewritten.
27
+
28
+ **2. Implement the idea.** Edit code only in `$SRC`, after reading the
29
+ parent's code, which differs from the baseline once anything is promoted. What
30
+ one run calls, with which inputs, is your brief's *What one run does* line. In
31
+ repository mode the benchmark is `harness/`, which no iteration edits, and the
32
+ brief lists its files and functions, which a probe or checker may import: read
33
+ the harness only for what those leave out. For code compiled by numba, read
34
+ `references/algorithm.md`, *Numba*, first.
35
+
36
+ Change **one thing**. If the idea needs three changes to work at all, it is
37
+ one idea; if it splits into three that each stand alone, it is three
38
+ iterations: implement the first and say so in your report (*What to report
39
+ back*).
40
+
41
+ Keep the benchmark's contract intact: it still takes `--seed` and `--out`,
42
+ and still writes `metrics.json` with the objective, every gate and every
43
+ observer. An idea that changes what the objective means is a different
44
+ search.
45
+
46
+ **3. Run the iteration.** Your brief says whether the runner goes in the
47
+ foreground or the background:
48
+
49
+ ```bash
50
+ python3 $AO/run_iteration.py $DIR # foreground, timeout: 240000
51
+
52
+ python3 $AO/run_iteration.py $DIR --background # writes probe/runner.log
53
+ python3 $AO/autoopt.py wait $DIR/probe/runner.log # repeat until `wait: finished`
54
+ ```
55
+
56
+ The runner commits your edit and runs the stages in *Checks beyond the
57
+ runner*, each only when the ones before it passed: one run, then the unit
58
+ tests and the compare, then the other runs. A broken edit therefore costs one
59
+ run. It writes `result.json` and `report.txt`, whose `run <seed>`
60
+ rows give each run's objective and observers beside your parent's run of the
61
+ same seed, any gate it broke, and the load when it started: read those rows,
62
+ not the runs' `metrics.json`. Do not loop over seeds yourself. After you fix
63
+ the code, run it again: the new commit runs every seed afresh, while seeds
64
+ already measured on an unchanged commit are reused (`--rerun` runs them
65
+ again).
66
+
67
+ **When `"tests"` is configured**, the runner runs the unit tests once, after
68
+ the first run passes its gates. A failure is `gate-failed`. Read
69
+ `$DIR/unit-tests/log.txt` and fix the code, never the test: editing or
70
+ deselecting a test changes what the gate checks. If the idea changes behavior
71
+ a test pins, stop and report that.
72
+
73
+ **4. Run the checks your brief asks for** (*Checks beyond the runner*).
74
+
75
+ **5. Write the README** (*The README*), append what you established to the
76
+ ledger (*Before you stop*), and report back.
77
+
78
+ ## Checks beyond the runner
79
+
80
+ **The runner's stages**, each run only when the ones before it passed; with
81
+ the task's checks (your brief's *Checks* section says so) it prints a
82
+ `check:` line:
83
+
84
+ | Stage | Runs | A failure |
85
+ |---|---|---|
86
+ | 0. before the runs | with compiled code (`first_call`), the cold first call on empty caches, beside your parent's recorded value | a crash is `error`, and nothing runs |
87
+ | 1. the first run | one seed, every gate and observer | `error` or `gate-failed`, and nothing more runs |
88
+ | 2. the code's checks | the unit tests (with `{selected}`, only the files for the modules you changed), then the compare: your code against A0's cached outputs, on the benchmark's inputs, the edge cases and every public function | `gate-failed` (`failed_check: compare` for the compare) |
89
+ | 3. the other runs | the rest of `runs_per_iteration`, one seed each, every gate and observer on every run, `gpus_per_agent` at once (one per leased GPU on a GPU search); run one at a time, they stop at the first that fails | `error` or `gate-failed` |
90
+ | 4. the whole suite | with `{selected}`, only when your median passes the keep rule: only such an iteration can be promoted | `gate-failed` |
91
+ | 5. the keep rule | the verdict against your parent, your median beyond the noise band of your parent's, recorded as `keep` and on the `keep:` line | none: a `keep: no` is a result |
92
+ | 6. promotion | with `promote: auto`: a pass while your parent is still the root promotes you, then runs the closed round's approved validation | none. You promote nothing |
93
+
94
+ **Do not time your version against the parent yourself** (`paired.py`,
95
+ `cold.py` or a probe of your own): the runner's `check:` and `keep:` lines are
96
+ the verdict. Timing variants to choose between implementations before the
97
+ runner runs is yours (*Timing variants*). Your own checks:
98
+
99
+ | Check | Yours |
100
+ |---|---|
101
+ | forced-fallback and guard-breaking checks | for a path your change adds that the compare's inputs cannot reach (a fallback, a guard); in a search without the task's checks, for every path it adds |
102
+ | external validation | when the brief asks |
103
+
104
+ **A checker in `tools/checkers/` that guards a file you change** is run, not
105
+ read: `python3 $AO/autoopt.py checkers $WORK --id A7 --touched` runs every
106
+ one whose `files` your edit touches, on your parent and your code, and says
107
+ which passed (`--name <dir>` runs one; with no flag it lists them). Start it
108
+ in the background with `wait` when a checker's run time passes four
109
+ minutes. Read a checker's `ROW.md` only for what its index line leaves out.
110
+
111
+ A compare that fails is a result, like a gate: read `check/compare.log` in
112
+ `$DIR`, fix the code, and `--rerun`. Never edit the checks or the cached
113
+ outputs in `reference/`, which are off limits like the harness.
114
+
115
+ **Run your checks together, in the background, never while you time
116
+ variants**: a check beside a timing takes its cores and voids it.
117
+
118
+ ```bash
119
+ (python3 $AO/autoopt.py validate $WORK --id A7 --out $DIR/validation > $DIR/validation.log 2>&1 &
120
+ python3 $DIR/probe/fallbacks.py > $DIR/probe/fallbacks.log 2>&1 &
121
+ wait; echo "exit $?") > $DIR/probe/checks.log 2>&1 &
122
+ python3 $AO/autoopt.py wait $DIR/probe/checks.log
123
+ ```
124
+
125
+ **Prove a checker you wrote on planted faults in one call.** Write each fault
126
+ to `$DIR/probe/faults.txt`, the old text copied exactly:
127
+
128
+ ```
129
+ ## nomirror
130
+ file: textstats/distance.py
131
+ <<<
132
+ G[start:end, :start] = G[:start, start:end].T
133
+ ===
134
+ pass
135
+ >>>
136
+ ```
137
+
138
+ ```bash
139
+ python3 $AO/autoopt.py prove $WORK --id A7 --checker $DIR/probe/guards \
140
+ --checker-row $DIR/probe/checker.txt --faults $DIR/probe/faults.txt
141
+ ```
142
+
143
+ It runs the checker's `run` line on your edit against the parent, which must
144
+ pass, then on a copy of your edit per fault (refusing one whose old text is
145
+ not in the file exactly once), and prints which it caught. `finish` takes the
146
+ row's `faults` from that table. A fault it missed goes in the row as missed,
147
+ or makes the checker stronger. One run per fault: start it in the background
148
+ with `wait` when that may pass four minutes.
149
+
150
+ ## Timing variants
151
+
152
+ Choosing between implementations before the runner runs is the one timing
153
+ that is yours. A sweep inside one process ranks variants; it never measures
154
+ a gain, and its delta can be several times the runner's.
155
+
156
+ - **Rotate the variants' order on every repetition**: a fixed order gives the
157
+ first one a cache-warmth edge, enough for a byte-identical copy to win.
158
+ - **Include a byte-identical copy of the parent** as a variant, and claim
159
+ nothing that this control also shows.
160
+ - **Rank by wins, not by the mean delta**: report "fastest in 15 of 15".
161
+ Nine rotated repetitions separate most things; run fifteen for a tie. Two
162
+ variants inside each other's noise are a tie: say so and pick either.
163
+ - **Compare only within one sweep.** Separately compiled copies land in
164
+ different places in memory, so one copy reads faster, level and slower
165
+ across three sweeps.
166
+ - **Never time A once, then B**: drift between the two can exceed the change.
167
+ Interleave, and report each repetition.
168
+
169
+ Before pricing the parts of the root (`references/measuring.md`, *Profile the
170
+ root you are actually on*), reading generated code (*Reading the generated
171
+ code*) or timing code a compiler caches (*A cached compile can outlive the
172
+ edit*), read that section of `references/measuring.md`.
173
+
174
+ ## The README
175
+
176
+ `$DIR/README.md` is the only thing that outlives you: the orchestrator reads
177
+ your report once; whoever returns in three months reads this file. You write
178
+ its prose in `$DIR/notes.md`; `autoopt.py finish` (*Before you stop*) adds
179
+ the header and every number from `result.json`, so none is typed by hand.
180
+
181
+ `notes.md` holds these four `## ` sections, non-empty. Any others you add (a
182
+ *Variants* section, say) follow the numbers in the order written:
183
+
184
+ | Section | Holds |
185
+ |---|---|
186
+ | *The idea* | what was changed, where (file and function), and why it might help |
187
+ | *What happened* | the result in words |
188
+ | *Notes and failures* | anything surprising: a seed that differed, a dependency pinned, a setting changed to make the idea run at all, a false premise in the brief, the share of a tolerance this spent |
189
+ | *What to try next* | the follow-ups this result suggests, or "closed" and the number that closes it |
190
+
191
+ ```markdown
192
+ ## The idea
193
+
194
+ Prefetch the next block of records on a second thread in `scan.py:read_blocks`,
195
+ so the parser never waits on the disk: the hope was the same throughput at a
196
+ lower per-call latency.
197
+
198
+ ## What happened
199
+
200
+ Throughput rose, the best of the round, but every run broke the 10 ms latency
201
+ gate: the prefetch thread starts cold on each call, and a short call pays its
202
+ startup. Per record it is cheaper; per call it is not.
203
+
204
+ ## Notes and failures
205
+
206
+ - The first attempt used a queue of depth 8 and was 3 ms slower again; the
207
+ measured version has depth 2.
208
+
209
+ ## What to try next
210
+
211
+ A prefetch thread kept alive across calls, or prefetching only for inputs
212
+ past one block, where the startup is amortised.
213
+ ```
214
+
215
+ **When the runner's `keep:` line reads `promoted` or `passes`, in a repository
216
+ search, add two more sections; `finish` refuses the README without them.** They
217
+ are the text shipped with your change, so nobody has to read your diff again
218
+ to describe it. An iteration made with `--after-end` writes them before
219
+ `promote`. `finish` and `promote` lint both (`references/promotion.md`, *The
220
+ preflight*): name nothing of the search (no winner, baseline, round, label such
221
+ as A12, or path on this machine), and call the original code by its branch
222
+ name.
223
+
224
+ | Section | Holds |
225
+ |---|---|
226
+ | *Change* | first line `name: <three to six words naming the change>`; then what the change does as it stands in the code, in complete sentences, with no number a table computes |
227
+ | *Commit message* | the commit's message: an imperative subject of at most 72 characters with no closing period, a blank line, then the body: what this change does and what stays the same (output, defaults, the plain build), wrapped at 72 columns, in the repository's own style (`git -C $WORK/autooptimize/repo.git log --oneline -20`). Leave out the `after.commit_trailer` line here, though the commits you make in the worktree end with it: step 5 adds it when it makes the commits the user ships (`references/pr-optimization.md`) |
228
+
229
+ ```markdown
230
+ ## Change
231
+
232
+ name: Reuse the parsed header across records
233
+ The record parser parses a block's header once and passes it to each record,
234
+ where it parsed the header again for every record.
235
+
236
+ ## Commit message
237
+
238
+ Parse a block's header once
239
+
240
+ parse_record() took the raw header and parsed it for each record of the
241
+ block. read_block() parses it once and hands the result down.
242
+ ```
243
+
244
+ The README's *Numbers*
245
+ section gives the per-seed table, the median and its range, the frontier and
246
+ noise band it was judged against, and each gate's worst value. The median is
247
+ the iteration's result; quoting the best single run (`best_run`) overstates
248
+ the idea by about the seed spread. A re-run re-assembles `README.md` from the same
249
+ `notes.md`.
250
+
251
+ An iteration whose README says only "did not help" is an iteration somebody
252
+ will run again: a negative result is welcome, with its number.
253
+
254
+ ## Before you stop
255
+
256
+ Write up to three files, then make one call:
257
+
258
+ - `$DIR/notes.md` (*The README*);
259
+ - `$DIR/probe/ledger.txt`: what you established, and a correction for
260
+ anything you disproved, one entry a line in the ledger's format (`- [tag]
261
+ fact (label, root <label>)`); a correction ends `(corrects: <words only the
262
+ old entry has>)`;
263
+ - for a checker you wrote (`references/shared-knowledge.md`, *The checker
264
+ library*), `$DIR/probe/checker.txt`, one `key: value` line each: `name` (the
265
+ subsystem, such as `distance`), `files` (the files it guards, relative to
266
+ the code's root, comma-separated; a directory or a glob covers what is
267
+ under it), `compares` (its first sentence is the index line), `built`,
268
+ `run` (a shell
269
+ command, run in `$DIR`, so `&&` and pipes work, with `{checker}` for its
270
+ directory and `{parent}` and `{child}` for the two trees, substituted
271
+ shell-quoted: the two worktrees, or, when the search registers
272
+ `checks.build`, copies built with it), `faults` (each planted fault and
273
+ what it caught; left out after `prove --id`), `inputs`.
274
+
275
+ ```bash
276
+ python3 $AO/autoopt.py finish $WORK --id A7 --ledger $DIR/probe/ledger.txt \
277
+ --checker $DIR/probe/guards --checker-row $DIR/probe/checker.txt
278
+ ```
279
+
280
+ It checks everything before it writes anything, and refuses, naming what to
281
+ fix, when there is no `result.json` or no `notes.md`, a placeholder is left,
282
+ a required section is missing, empty or twice, text comes before the first
283
+ `## ` heading, a correction's words match no entry or several, the row lacks
284
+ a key, or the checker does not exit 0 on your parent and your code (its log
285
+ is `probe/finish-checker.log`). Then it writes `README.md`, strikes the
286
+ `ideas.md` line you were briefed from, copies the checker into
287
+ `tools/checkers/<name>-<label>/` with its row and its measured run time,
288
+ appends the entries under the ledger's lock, and prints the block to report.
289
+ After a fix, make the same call: nothing is appended twice. A checker that
290
+ cannot finish in four minutes gives `time:` (its run time) in place of
291
+ `run:`. If writing a `.md` file is refused, your notes and entries go in your
292
+ report (*What to report back*).
293
+
294
+ ## Check your brief before you follow it
295
+
296
+ Your brief was written from a profile of another root and a memory of what
297
+ was tried, so check its premises before relying on them. When the search profiles its roots, *The idea*
298
+ quotes your parent's profile on the idea's function; one that says the
299
+ profile does not name it is the first premise to check, before building
300
+ anything. Premises that turned out false:
301
+
302
+ | The brief said | It was |
303
+ |---|---|
304
+ | "this argument is always −1, so the branch is dead" | false: another entry point passes a real index, and deleting it would have passed every run here and broken the package |
305
+ | "each `(k, l)` writes a distinct target, so reordering is safe" | false: it is a convolution, up to 100 additions land on one element, and the change was exact only because it kept the loop order |
306
+ | "this clear is a large memset, worth attacking" | a small fraction of that; the buffer never left L1 |
307
+ | "this is worth X on top of the root" | well short of X: the headline was a variant's, and the parent already had part of it |
308
+
309
+ **When a brief states a premise, measure it**, and **put a correction first
310
+ among your report's sentences** (*What to report back*, item 2): a premise
311
+ wrong in a brief is usually wrong in `ideas.md` and the ledger too. Correct
312
+ the ledger entry yourself (*Before you stop*); the orchestrator fixes
313
+ `ideas.md`.
314
+
315
+ ## Off-benchmark callers of the code you are changing
316
+
317
+ A package usually has more than one entry point into the kernels you edit,
318
+ and the benchmark exercises one. **A missed update passes every run here and
319
+ breaks the installed package**, at import or compile time, on a path this search
320
+ never runs. Find the other callers before changing a shared function's
321
+ signature or an array's shape, and compile-check them afterwards.
322
+
323
+ If such an entry point is **nondeterministic on unmodified code**, such as one
324
+ returning uninitialized scratch that differs between processes, comparing its
325
+ output between your branch and the parent proves nothing. Say so, check only
326
+ that it compiles and returns the right shape, and record the bug as a
327
+ `[bug]` ledger entry rather than spending your iteration fixing it.
328
+
329
+ ## Portability
330
+
331
+ Your brief quotes `spec.md`'s *Portability* line. **By default the change must
332
+ work on every common OS: Linux, macOS and Windows.** Code that relies on one OS
333
+ (reading `/proc`, `os.sched_setaffinity`, the `fork` start method, `madvise`,
334
+ a POSIX-only call, a shell command) is allowed only behind a check that falls
335
+ back, on the other systems, to a path with identical output; that fallback is
336
+ a path the change adds, so it gets the forced-fallback check (*Checks beyond
337
+ the runner*). When the line names this machine's OS only, such code is
338
+ allowed as it is. Either way, say in the README which OS-specific code the
339
+ change uses.
340
+
341
+ **Vectorizing.** Python: numba. Otherwise restructure the code first so the
342
+ compiler vectorizes it (contiguous arrays, a struct of arrays, no aliasing,
343
+ simple loops). Only then use the language's own general-purpose route to SIMD,
344
+ one every compiler or runtime for it accepts (a standard pragma, a portable
345
+ vector type). Never raw intrinsics, `-march=native` or a flag for one
346
+ instruction set.
347
+
348
+ **Toolchain.** The change must not depend on a compiler's decisions. Before
349
+ `notes.md`, ask whether the gain exists because of how one compiler, version,
350
+ flag or optimization level treats the code: an attribute, pragma, inline hint,
351
+ build flag or source order that steers it, or a cause that names a compiler or
352
+ pass. Pragmas and attributes on a new function you add are allowed. Start a
353
+ `## Toolchain` section with `Relies on a compiler decision: no` or `yes`, then
354
+ the mechanism that makes the change faster. `yes` rejects the idea: `finish`
355
+ records it, `promote` refuses it, and the ledger closes it (`[closed]`, the
356
+ compiler named). `finish` also scans the diff against the parent and refuses
357
+ without the section when an existing function's hint or pragma changed (or a
358
+ lone one was added) or a build flag changed; `promote` refuses until the
359
+ answer is `no`. With `promote: auto` the runner then prints `keep: passes (…);
360
+ not promoted: <reason>`: fix what the reason names, run `finish`, and put that
361
+ line first in item 2 of your report; the orchestrator promotes it (`promote
362
+ --id`). The scan also flags every build
363
+ file (Makefile and `*.inc`, `CMakePresets.json`, `build.sh`, `config.toml`, an
364
+ `include` of a new file), a compiler or flag variable set in one, an optimize
365
+ or target pragma or attribute wherever it sits, a new assembly file, a binary
366
+ or library, and a file under `vendor/` or `third_party/`. The runner scrubs
367
+ `CC`, `CFLAGS` and the other build variables from every run and test and sets
368
+ those in `config.json` `build_env`, so exporting one changes nothing. The
369
+ harness is hashed when step 2 closes; a run refuses once it differs
370
+ (`autoopt.py harness`). A new binary is flagged by content, not suffix, so a
371
+ build's output committed by accident is refused too: ignore build outputs in
372
+ the repository's `.gitignore`. A changed build file, a binary or library, a
373
+ vendored tree and an assembly file are refused whatever the answer is, unless
374
+ `config --set allow_build_changes=yes` (tuning the build is the task).
375
+
376
+ **Constants fit to this machine.** A number you chose by timing here (a block
377
+ or tile size, a thread count, a buffer length, a prefetch distance, the cutoff
378
+ between two code paths) is derived at run time from the input or a query of the
379
+ machine, or the README gives its value, the sizes and core counts you timed
380
+ and what the other values did. A value timed at one size only is a guess on
381
+ another machine: time a second size before you keep it.
382
+
383
+ ## Keep the branch to the code change
384
+
385
+ `git diff <parent>..<yours>` should be the idea and nothing else. Probes,
386
+ sweeps, asm dumps and scratch variants go in `$DIR/probe/`, which git never
387
+ commits: the plain-mode exclude list ignores `probe/`, and in repository mode
388
+ `$DIR` is outside the worktree. Anything written elsewhere in a plain-mode
389
+ worktree is committed by the runner. Do not edit `repo.git/info/exclude`; it
390
+ is every iteration's ignore list at once.
391
+
392
+ ## When a run fails
393
+
394
+ `status: error` means a run crashed, timed out, or wrote no usable
395
+ `metrics.json`. The runner names the seed and the reason, and the run's
396
+ `log.txt` is in its directory. Two errors come from the bookkeeping:
397
+ `<dir> has no meta.json` means the directory was made by hand instead of by
398
+ `new`; `iteration N has no result.json` means the iteration never finished,
399
+ and re-running `run_iteration.py` on it resumes from the seeds already on
400
+ disk.
401
+
402
+ | Cause | Do |
403
+ |---|---|
404
+ | A bug in your edit | fix it and `--rerun`; the iteration is not measured until it runs |
405
+ | Out of memory | if the idea is inherently larger, that is the result: record it; if another job contended, re-run |
406
+ | A missing dependency | install nothing: every iteration shares one environment, and an install can upgrade what the others run. Write the README, name the package in report item 2, and stop. An idea that adds a dependency to the package itself also declares it in the diff (`pyproject.toml`, `requirements.txt`) |
407
+ | The idea cannot work at all | stop, write the README saying why, report back |
408
+
409
+ **Never weaken the idea to make a gate pass.** Shrinking the prefetch buffer
410
+ until it fits the latency gate turns your iteration into a different idea with
411
+ the same title. A reduced form that fits is a separate iteration with its own id and
412
+ title.
413
+
414
+ ## What to report back
415
+
416
+ Exactly this, in this order, and nothing more:
417
+
418
+ 1. The block `finish` printed (`$DIR/report.txt`).
419
+ 2. At most two sentences: a false premise in the brief first, then an idea
420
+ that should be split, then anything else surprising.
421
+ 3. Only when writing a `.md` file was refused: your `notes.md` text and your
422
+ ledger entries, so the orchestrator can save them.
423
+
424
+ A number not in `result.json` is not a result; everything else goes in your
425
+ README.
426
+
427
+ ## Rules
428
+
429
+ - **Use `wait` for anything over four minutes** (`SKILL.md`): the runner when
430
+ your brief says so, a sweep, a long probe:
431
+
432
+ ```bash
433
+ (python3 $DIR/probe/sweep.py; echo "exit $?") > $DIR/probe/sweep.log 2>&1 &
434
+ python3 $AO/autoopt.py wait $DIR/probe/sweep.log
435
+ ```
436
+ - Work only inside `$DIR`, apart from appending to `knowledge.md` and adding
437
+ to `tools/`. Never edit another iteration, `config.json`, `state.json`, or
438
+ the parent's worktree.
439
+ - Scratch (exported copies, sweeps, caches, probes) goes in a new directory
440
+ under `$DIR/probe/`, never under `/tmp`, which the OS may clean mid-run;
441
+ the search's one shared compiler cache in `tools/` is the exception.
442
+ - Export code rather than copying the worktree, which carries a `.git`
443
+ pointer back into `repo.git`: `python3 $AO/autoopt.py variant $WORK --id A7
444
+ v1` writes your edit as it stands (before the runner commits, `HEAD` is the
445
+ parent's code) to `$DIR/probe/v1/`, and `--parent` the parent's code. In a
446
+ search with `checks.build` it also builds the copy as the harness builds a
447
+ worktree (log `probe/v1.build.log`), so no build flags need finding.
448
+ - **Never search the filesystem** with `find /` or over a home directory:
449
+ on a large or network filesystem such a scan outlives the iteration. Locate a jar or library through the build tool's cache or your
450
+ brief.
451
+ - **Delete nothing**: no `rm -rf` on your worktree, scratch copies,
452
+ `__pycache__` or compiler caches, and never on a path built from a
453
+ variable. To force a recompile, point `NUMBA_CACHE_DIR` (or the Triton or
454
+ Inductor cache) at a new directory; to start a copy over, export to a new
455
+ directory. Removing a worktree is `git worktree remove`, and the
456
+ orchestrator's call.
457
+ - **Compare outputs by hash, not by saving them.** Hash each output's bytes
458
+ (`hashlib.blake2b(numpy.ascontiguousarray(a).tobytes())`) in the process
459
+ that made it, or compare two outputs in one process. Arrays saved per
460
+ variant and per check soon fill the search directory; save one only to look
461
+ inside it, and only a slice.
462
+ - In every probe that imports the code, assert the path before timing:
463
+ `assert sys.modules['<pkg>.<module>'].__file__.startswith(<copy dir>)`.
464
+ Name the submodule: a package that re-exports a function under the same
465
+ name (`from .score import score`) makes `<pkg>.score` the function.
466
+ - `runs/`, `result.json`, `README.md`, `notes.md` and saved arrays are
467
+ excluded from git on purpose; do not add them.
@@ -0,0 +1,67 @@
1
+ # By symptom: an error, a refusal, or something that looks wrong
2
+
3
+ | Symptom | Read |
4
+ |---|---|
5
+ | `commits …, which the unit tests create`; a test's output file (an index, a cache) left in a worktree | `references/repo-mode.md`, *The unit-test gate* (Artifacts) |
6
+ | `CUDA_VISIBLE_DEVICES is unset, so this run holds no GPU lease` | `references/step2-baseline.md`, *GPU leases* |
7
+ | `metrics.json has no numeric value for the gate "…"` | `references/layout.md`, *metrics.json — the contract every benchmark meets* |
8
+ | `config.json "command" must contain both {seed} and {out}`, `has {…}, which is not a placeholder` | `references/layout.md`, *config.json* |
9
+ | `copied file(s) match the plain-mode exclude list` at `init` | `references/layout.md`, *The git model* |
10
+ | `… is not valid JSON … repair it or move it aside` | `references/layout.md`, *The `autooptimize/` tree* |
11
+ | `this search was made by the … skill` | `references/layout.md`, *Version fields*: read that search with the skill it names |
12
+ | `fewer than 2 untried ideas`; `stage S<n> of the idea miner is still open` | `references/step3-rounds.md`, *Keeping the ideas* |
13
+ | `refusing to start step 2` or `refusing to start the idea miner: the interview is not written down`; `step 2 is still with the setup subagent`; `step 2 is already with a setup subagent`; `no setup is open`; `setup (step 2): waiting for the user`; `first iteration: waiting for …` | `references/step0-interview.md`, *Handing off step 2*; for a question waiting, `references/main-session.md` |
14
+ | `step 2 is not finished` | `references/step2-baseline.md`, *Closing step 2* |
15
+ | `has no passing check`; a `check:` line reading `compare differ` or `error`; `failed_check` | `references/subagent.md`, *Checks beyond the runner* |
16
+ | `compare could not cache A0's outputs`, `wrote nothing into`, `does not pass A0 against its own cached outputs` | `references/step2-baseline.md`, *Write the checks* |
17
+ | `refusing to fork an iteration` / `refusing to run A0: step 0 is not finished` | `references/step0-interview.md`, *Writing it down*; for `Gate proof` and `Width measured`, `references/step2-baseline.md`, *In this order* |
18
+ | A question for the user while iterations are in flight; the search stops while the user is away | `references/step3-rounds.md`, *Questions while the search runs* |
19
+ | `parent … is gate-failed` | `references/step3-rounds.md`, *Ids, parents and briefs* |
20
+ | `brief` refuses: `is taken`, `` this search uses GPUs and records no `gpu_command`: pass --gpus `` | `references/writing-briefs.md` |
21
+ | `finish` or `readme` refuses: `placeholder`, `lacks`, `no …notes.md`, `a checker must pass`, `(corrects: …)" matches` | `references/subagent.md`, *Before you stop* |
22
+ | `status` shows `STALLED`, `no README:` or `summary overdue`; `summary` says `no settled iteration … carries round N` | `references/step3-rounds.md`, *A subagent that goes quiet*; *The round summary* |
23
+ | `promote` refuses: `is gate-failed`, `does not descend from the root`, `passed only the unit tests for the modules it changed` | `references/promotion.md`, *Promotion follows the keep rule* |
24
+ | The frontier moved tenfold and the keep rule's margin cannot be met, or the timed call fell below 10 ms | `references/step3-rounds.md`, *When the objective moves by an order of magnitude* |
25
+ | `validate` refuses: `has not been approved` | `references/external-validation.md` |
26
+ | `iteration N has no result.json`, `has no meta.json` / an iteration never finished | `references/subagent.md`, *When a run fails* |
27
+ | The dashboard is empty, shows another search's numbers, reads **publisher stopped** or **re-run the cell**, or is stuck on `Loading the dashboard…` | `references/dashboard.md`, *When it looks wrong* |
28
+ | `status` says `dashboard: no publisher is running` | iterations are in flight and nothing publishes: run the `--start` command it prints (`references/dashboard.md`) |
29
+ | The user asks for the dashboard's URL or port | there is none: they open `$WORK/dashboard.ipynb` in the JupyterLab they already reach and run its cell, or you send them an `--export` file (`references/dashboard.md`) |
30
+ | Share a finished search as one HTML file | `references/dashboard.md`, *Managing publishers* (`--export`) |
31
+ | The external validation reads **needs attention** | `references/external-validation.md` |
32
+ | Timings jumped between rounds, or an unchanged control got slower | `references/step3-rounds.md`, *The machine during the search* |
33
+ | Runs inside one iteration read slower than one run alone | `references/step2-baseline.md`, *Measure what concurrency does to the objective* |
34
+ | A run takes several times one call's cost | `references/step2-baseline.md`, *One run is a warmup and one timed call* |
35
+ | A run's `log.txt` ends `no reference for seed …` | `references/step2-baseline.md`, *A gate that compares against the baseline's output* |
36
+ | A tolerance nothing can satisfy, or one nothing can fail | `references/step2-baseline.md`, *Compute a numeric tolerance against real data* |
37
+ | The same edit measured two values on two roots, a change came in short of its prediction, or a gain was predicted in percent | `references/promotion.md`, *Predicting what a change is worth* |
38
+ | A timing harness or an in-process sweep gives a different answer each time | `references/subagent.md`, *Timing variants*; `references/measuring.md` for `paired.py` |
39
+ | A brief aimed at a kernel that does not dominate the profile | `references/measuring.md`, *Profile the root you are actually on* |
40
+ | A variant is suspiciously fast | `references/measuring.md`, *A suspiciously large speedup is usually dead code* |
41
+ | Assembly-instruction counts read 0 for everything, on both branches | `references/measuring.md`, *Reading the generated code* |
42
+ | A numba error or warning: `TypingError`, `missing Environment`, `Cannot cache compiled function`, a segfault with no message | `references/algorithm.md`, *Numba* |
43
+ | A brief's premise turns out false | `references/subagent.md`, *Check your brief before you follow it* |
44
+ | A change passes every run here but breaks the package | `references/subagent.md`, *Off-benchmark callers of the code you are changing* |
45
+ | `has uncommitted changes to tracked files`, `detached HEAD` at `init --repo` | `references/repo-mode.md`, *Setting it up* |
46
+ | Every iteration matches the baseline to the last digit | `references/repo-mode.md`, *Import from the worktree, never the installed package* |
47
+ | `unit tests: FAIL`; a `tests` column reading `FAIL` or `pass sub`; `promote` refuses `passed only the unit tests for the modules it changed` | `references/repo-mode.md`, *The unit-test gate* |
48
+ | `fatal: … already registered worktree`, `a branch named autoopt/N already exists` | `references/repo-mode.md`, *Common errors* |
49
+ | `init` refuses `commits ahead of its base: the unit-test suite is one commit` | `references/step1-unit-tests.md`, *Where it lives*, step 2 |
50
+ | A unit test that passes here and fails in the repository's CI (`--runxfail`, macOS, another Python, an older Cython) | `references/step1-unit-tests.md` |
51
+ | `no gpu_command`, or `CUDA_VISIBLE_DEVICES is unset … no gpu_command is recorded` | `references/step2-baseline.md`, *GPU leases* |
52
+ | `the root reached the floor` (`stages.py next`) | `references/step3-rounds.md`, *When to stop*: end, a new search on a larger input, or `config --set floor=<lower, or 0>` |
53
+ | `the task names N workers and A0's runs never had more than M thread(s) running` (`setup --done`) | `references/step2-baseline.md`, *The price of the base*: the worker count is not in effect in the benchmark |
54
+ | `timed out` from the paired timing: one run hung and was killed | read `final/paired.log` and run that side's timing command by hand; `end` again once it returns |
55
+ | `over the cap` or `over cap` from the paired timing in `end` or `final` | `references/step4-final.md`, *What it does, in order* |
56
+ | `readme` or `finish`: `notes.md lacks ## Change` / `## Commit message` | an iteration whose `keep:` line reads `promoted` or `passes` writes both: `references/subagent.md`, *The README* |
57
+ | `promote`: `fails the preflight` | `references/promotion.md`, *The preflight* |
58
+ | `config --set after.X=V` refuses: `'after.X' cannot be set here` for a key this skill does not define; a search with no `after` block | `references/layout.md`, *config.json*, `after` row: `config --set` creates the block, never `init --force` for it; a key this skill does not define is kept as it is |
59
+ | `has uncommitted changes that were never measured` naming a file the build writes (`configure.log`, a stamp) | `after.build_outputs`: `references/step0-interview.md`, *The questions* |
60
+ | `ship.py` refuses (`apply`, `branch`, `rehearse`, `post`) | `references/step5-ship.md`, *Refusals* |
61
+ | `end --reopen`: `the search cannot be reopened` | `references/step4-final.md`, *Reopening* |
62
+ | `stages.py next` prints `` `end` failed and the search has not ended `` | `references/step4-final.md` |
63
+ | `the search ended on …: only an iteration made after the end`; `refusing to fork an iteration` after `end` | `references/step4-final.md`, *An iteration made after the end* |
64
+ | A search is running and this session knows nothing about it | `references/resume.md` |
65
+ | `has no git checkout: it was pruned, or made by hand`; the search directory has grown to tens of GB | `references/step6-finish.md`, *3. Reclaim the disk* |
66
+ | `the harness changed since …`, `relies on a compiler decision` | `references/subagent.md`, *Portability* (Toolchain); `autoopt.py harness --accept --reason` for a change that is meant |
67
+ | Start the ideas over without re-running the baseline | `references/changes.md`, *Starting the ideas over, keeping the baseline* |
@@ -0,0 +1,117 @@
1
+ # Writing a brief
2
+
3
+ The brief is everything a subagent knows about the search. `autoopt.py brief`
4
+ writes it from the record; the orchestrator supplies only what the record
5
+ cannot know.
6
+
7
+ ## `brief --next`, the usual call
8
+
9
+ ```bash
10
+ python3 $AO/autoopt.py brief $WORK --next # a brief when the slot is free
11
+ python3 $AO/autoopt.py brief $WORK --next --gpus 2 --note '…' # the same, with a note
12
+ ```
13
+
14
+ It prints `status --brief`, then the table of each round summary written
15
+ since the last call, then a brief and its spawn prompt when the one slot is
16
+ free: one iteration runs at a time, so the slot is free when no iteration is
17
+ still worked on (a STALLED one included) and no brief is waiting to start.
18
+ It takes the next untried line of `ideas.md`, the latest miner stage first
19
+ and top to bottom. Leave out `--count` (or give 0, below): a count above the
20
+ free slot briefs ideas that wait unspawned, each counted against
21
+ `after.budget_iterations`. It fills:
22
+
23
+ | Flag | From |
24
+ |---|---|
25
+ | `--id` | the next free id |
26
+ | `--idea-line`, `--category` | the line, and its tag |
27
+ | `--title` | the line's function and the first clause of what it changes, cut to 70 characters |
28
+ | `--tried` | every iteration whose diff changed any file the line's *where* names: its median against its parent's, and whether it is in the root, passed the keep rule but is not in the root, was not kept and why, or is in flight. Past 15, it lists the root path, the latest 15 whose title names the line's function and the latest 15 overall, and counts the rest by fate in one line. The files each change touched are cached in `autooptimize/touched.json` |
29
+ | `--sections` | `code:<the file's name>` when the ledger has that tag, and `harness`, `machine` and `closed` when it has them |
30
+
31
+ A flag given beside `--next` replaces what it would fill; `--note`, `--checks`, `--gpus`,
32
+ `--validate` and `--predict` pass through. `--count 0` prints the status and
33
+ the new summaries and briefs nothing. Add a `--note` for what the records
34
+ do not hold, such as a premise a report corrected.
35
+
36
+ ## Every flag
37
+
38
+ ```bash
39
+ python3 $AO/autoopt.py brief $WORK --id A7 \
40
+ --title 'prefetch the next block in read_blocks' \
41
+ --category CACHE_MISS --topic io \
42
+ --idea @$WORK/scratch/idea-7.md \
43
+ --tried 'A3 (larger read buffer): -0.002 s, inside the band. Nothing else touched read_blocks.' \
44
+ --sections code:reader,closed \
45
+ --gpus 2
46
+ ```
47
+
48
+ It writes the brief to `autooptimize/briefs/7.md`, and what `new --brief 7`
49
+ creates the iteration from to `briefs/7.json`. It prints a short prompt that
50
+ has the subagent read the brief, `references/subagent.md` and the ledger in
51
+ its first turn, so the brief never enters your context. Spawn the subagent
52
+ with that prompt, unedited, and the description and model on the stderr line.
53
+ `brief --prompt <id>` prints the prompt of an existing brief again, for a
54
+ subagent that takes the iteration over.
55
+
56
+ ## What it fills in
57
+
58
+ | From | In the brief |
59
+ |---|---|
60
+ | the skill and the search | absolute `AO`, `WORK`, `DIR`, `SRC`; the prompt gives the paths of the brief, `references/subagent.md`, the ledger, `tools/README.md` and `tools/checkers/README.md` |
61
+ | the flags | label, parent (the current root by default), category, topic, title, prediction; `briefs/<id>.json` holds them for `new --brief` |
62
+ | the parent's `result.json` | how long its runner call took, and whether the subagent runs the runner in the foreground or the background |
63
+ | `config.json` and `status` | the objective and its direction, where the search stands (the root and its median, the keep rule's reference, and any better median outside the root's path), every gate with its threshold, the observers, the runs per iteration, the unit-test command, the GPUs (for every command that runs the code) or "needs no GPU" |
64
+ | `spec.md`, verbatim | the keep rule, the off-limits line, the thread counts timed, the portability line, every rule under *Rules added during the search*, and the path of `spec.md` itself |
65
+ | the mode and the code | a *Checks* section: what the runner runs, when the search has the task's checks, and the checks the subagent owes (`references/subagent.md`, *Checks beyond the runner*); with `promote: auto`, a *Promotion* section; the repository-mode limits; a numba note when the parent's branch imports numba |
66
+ | `config.json`'s `subagent_model` | not in the prompt: a stderr line naming the Agent call's description and model |
67
+
68
+ It makes `new`'s checks before writing anything (the parent exists and is
69
+ `ok`) and refuses:
70
+
71
+ | Refusal | Do |
72
+ |---|---|
73
+ | `id N is taken (an iteration, a branch, or a directory set aside)` | use the next free id it names; `status` prints it too |
74
+ | `id N is taken (a brief not yet started …)` | another brief holds that id: take the next one, or pass `--replace` to rewrite that brief |
75
+ | `this search uses GPUs and records no \`gpu_command\`: pass --gpus …` | give the indices this iteration holds, or the command that allocates them on this machine |
76
+ | `parent … is gate-failed` | `references/step3-rounds.md`, *Ids, parents and briefs* |
77
+ | `refusing to brief an iteration: step 0 is not finished` | `references/step0-interview.md`, *Writing it down* |
78
+
79
+ ## What the orchestrator supplies
80
+
81
+ | Flag | Holds |
82
+ |---|---|
83
+ | `--idea-line` | the `ideas.md` line the idea comes from, by text only that line holds or by number: the line is the idea when `--idea` is not given, and the subagent's `finish` strikes it with its label and outcome |
84
+ | `--idea` | required without `--idea-line`: two or three sentences, what to change, in which file and function, and why it might help; with it, the text that replaces the line's |
85
+ | `--tried` (required) | the iterations that already touched this code and what each measured, or "none" |
86
+ | `--sections` | the ledger tags that matter for this idea (`code:trunk`, `closed`) |
87
+ | `--checks` | checks owed beyond that table, such as a guard path on an input the compare lacks |
88
+ | `--predict`, `--predict-basis` | the expected change against the parent, in the objective's units, and where the number came from (`references/promotion.md`) |
89
+ | `--gpus` | required unless `"gpu"` is false or `gpu_command` is set, which it then takes |
90
+ | `--validate` | ask for the approved external validation on this iteration |
91
+ | `--note` | one more line; repeatable |
92
+
93
+ `--idea`, `--tried`, `--checks` and `--note` take text, or `@file`.
94
+
95
+ ## What makes the supplied parts survive contact
96
+
97
+ - **State premises as things to confirm.** `references/subagent.md`, *Check
98
+ your brief before you follow it*, lists premises that turned out false.
99
+ - **List what was already tried, with its measurement.** Naming the
100
+ iterations that touched this code, and lost, buys exploration instead of
101
+ repetition.
102
+ - **Point at the ledger rather than retyping it.** `--sections` names the
103
+ entries; a fact the ledger lacks (this root's per-case medians, say) goes in
104
+ `--idea`.
105
+ - **Give the reason for each extra limit.** "No `fastmath`" is followed; with
106
+ the reason ("it reassociates the accumulation and the gate is bitwise"), it
107
+ is also generalized to the next temptation.
108
+ - **Do not quote a stale *Gain*.** Profile shares go stale within a few
109
+ roots: for a line whose *Gain* was taken on an older root, pass `--idea`
110
+ with the line's text minus the *Gain*.
111
+ - **Ask for the license notice with any translation.** A brief that lets the
112
+ subagent port a routine from another project (numpy, scipy, a C library)
113
+ adds a `--note` that the project's notice goes above the result
114
+ (`references/promotion.md`, *Code from another project*). Subagents leave it out otherwise.
115
+ - **Ask for findings in the reply when the subagent cannot write them.** Some
116
+ environments refuse a subagent's write to a `.md` file; a `--note` asks it
117
+ to return the text in its reply, for the orchestrator to save.