--- name: wf-improve description: Workflow that improves the detectors on a range of data where they perform poorly, given labels as the truth on that range — the upgrader fixes, the validator judges; the result, detectors a little better on the range without going back elsewhere (benchmark on a reference truth), or unchanged. The caller gives the range, the labels, the reference truth, the output folder and any specific context. /detectors:wf-improve . argument-hint: "" --- # wf-improve: improve the detectors on a range You are the orchestrator. The detectors (this plugin's repository, below `DETECTORS`: `scripts/`, `thresholds.md`) perform poorly on a range of data of a station; labels give the truth on this range. You run the upgrader, which fixes the detectors, then the validator, which judges the fixes against overfitting, and you return detectors **a little better on the range without going back elsewhere**, or unchanged. **You judge nothing yourself**: you only read the verdict lines. **You ask no question**: the workflow runs alone to the end. ## Inputs Given by the caller, in the request; any other context or rule it gives (files to read, git rules, where to commit, names) applies to this run and is passed on to the agents as it is (`Caller's context: …`), before their instructions but not before their file scope. - `DETECTORS`: the path of this repository (default: `detectors/`). - `STATION`: the station's data folder (read by `DETECTORS/scripts/data.py`). - `FROM`, `TO`: the range, UTC days (YYYY-MM-DD, `TO` excluded). - `LABELS`: the station's labels file (JSONL: `id`, `debut`, `fin`, `categorie` = the family, `description`), the truth on the range. - `REFERENCE`: the reference truth for the non-regression, `--labels .jsonl> --data />`. - `FAMILIES`: the document defining the families and their boundaries (one detector per family). - `CONTEXT` (optional): documents explaining the range's labels (an analyst's report, for example). - `OUT`: the output folder of this run. A required input missing, or `DETECTORS` not a git repository: say so and stop, changing nothing. ## Commands - events: `python3 /scripts/categories.py --from --to ` - sensors: `python3 /skills/wf-improve/scripts/sensors.py --from --to ` - range score (the goal): `python3 /skills/wf-improve/scripts/score.py --labels --from --to `; it exits with an error if no label touches the range: note it in the summary and stop without touching the detectors. - benchmark (the non-regression, about 3 min): `python3 /skills/wf-improve/scripts/regression.py ` The measures of a step: ` > /range-.txt 2>&1` and ` > /benchmark-.txt 2>&1`. ## Git The fixes are commits in `DETECTORS`, one per fix, so that the validator can have one removed. Note the **base**: `git -C rev-parse HEAD`. Files already modified (`git -C status --porcelain`) stay as they are, neither committed nor reverted; list them in the summary and pass them to the upgrader. Always commit by path (`git -C commit -m "" -- `), never `git add -A`, `git stash` or `git checkout` outside your paths: another session may be working there. Each message ends with an empty line then `Co-Authored-By: Claude Opus 5.5 `. Nothing is pushed. The rest (branch, committing `OUT`, another repository) is the caller's. ## Steps Each agent is called with the Agent tool, its `subagent_type` (`detectors:upgrader`, `detectors:validator`) and the request below, plus the caller's context. A verdict is read by `grep '^\*\*Verdict\*\*:' `. 1. **Measures before**: step `before`. 2. **Upgrader**, a single pass: `Detectors: . Station: , range → (UTC). Labels: . Families: . Context: . Events command: <…>. Sensors command: <…>. Range score command: <…> (before: /range-before.txt). Benchmark command: <…> (before: /benchmark-before.txt). Base: . Files already modified: . Output folder: . Write /modification.md.` It commits each fix it keeps, message `wf-improve: S`, with its benchmark `/benchmark-S.txt`. Verdict `nothing to change`, or no fix commit (`git -C log --format=%h --grep ': S[0-9]*$' ..HEAD` empty): go to the summary. 3. **Measures after**: step `after`. 4. **Validator**, which reads neither the diagnosis nor the detail of the modification: `Detectors: . Families: . Modification: /modification.md. Range score: /range-before.txt → /range-after.txt. Benchmark: /benchmark-before.txt → /benchmark-after.txt, after each fix: /benchmark-S*.txt; command: <…>. Events command for any station: python3 /scripts/categories.py --from --to . Base: . Write /validation.md.` - `keep`: go to the summary. - `remove`: for each fix of the `**Remove**:` line, its commits (`git -C log --format=%h --grep ': S$' ..HEAD`), from the most recent: `git -C revert --no-edit `, then `git -C commit --amend -m "wf-improve: S removed" -m "Co-Authored-By: Claude Opus 5.5 "`. A conflict: `git -C revert --abort`, and do as for `cancel`. - `cancel`, or anything else: `git -C checkout -- 'scripts/*.py' thresholds.md` (without the files already modified), commit of these paths, message `wf-improve: modification cancelled`. An output missing or without a readable verdict: note it, put the detectors back as for `cancel` if they changed, go to the summary. Do not rerun an agent. ## Summary Measures, step `end` (unless nothing changed: then `end` = `before`). Then `/summary.md`: ```markdown # wf-improve: , → **Result**: modification kept | kept without S… | cancelled | none | error ## The range the range score, before → end, one line per family (found, correct) ## Elsewhere the `Total` line of each family, before → end; then the other changed lines (station, family), before → end ## What changed ; the upgrader's verdict, the validator's ## For the user to decide ## Not fixed <"Not fixed" of the modification; none> ## Errors log --oneline ..HEAD`> ``` ## Answer In 4 lines at most: the `**Result**` line, the range score before → end (changed families), the `Total` before → end if it changed, the path of the summary.