@miller-tech/uap 1.136.2 → 1.137.1
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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/benchmarks/paired/report.d.ts +13 -0
- package/dist/benchmarks/paired/report.d.ts.map +1 -1
- package/dist/benchmarks/paired/report.js +29 -3
- package/dist/benchmarks/paired/report.js.map +1 -1
- package/dist/benchmarks/paired/types.d.ts +59 -0
- package/dist/benchmarks/paired/types.d.ts.map +1 -1
- package/dist/benchmarks/paired/types.js +60 -0
- package/dist/benchmarks/paired/types.js.map +1 -1
- package/dist/bin/cli.js +30 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/cli/deliver.d.ts.map +1 -1
- package/dist/cli/deliver.js +111 -7
- package/dist/cli/deliver.js.map +1 -1
- package/dist/cli/react.d.ts.map +1 -1
- package/dist/cli/react.js +18 -0
- package/dist/cli/react.js.map +1 -1
- package/dist/cli/self-tuning.d.ts +33 -0
- package/dist/cli/self-tuning.d.ts.map +1 -0
- package/dist/cli/self-tuning.js +139 -0
- package/dist/cli/self-tuning.js.map +1 -0
- package/dist/cli/tune-adapter.d.ts +8 -0
- package/dist/cli/tune-adapter.d.ts.map +1 -0
- package/dist/cli/tune-adapter.js +26 -0
- package/dist/cli/tune-adapter.js.map +1 -0
- package/dist/config/settings-registry.d.ts.map +1 -1
- package/dist/config/settings-registry.js +10 -0
- package/dist/config/settings-registry.js.map +1 -1
- package/dist/coordination/adaptation-signal.d.ts +19 -0
- package/dist/coordination/adaptation-signal.d.ts.map +1 -0
- package/dist/coordination/adaptation-signal.js +36 -0
- package/dist/coordination/adaptation-signal.js.map +1 -0
- package/dist/delivery/agentic-executor.d.ts +16 -1
- package/dist/delivery/agentic-executor.d.ts.map +1 -1
- package/dist/delivery/agentic-executor.js +45 -4
- package/dist/delivery/agentic-executor.js.map +1 -1
- package/dist/delivery/decompose.d.ts +27 -0
- package/dist/delivery/decompose.d.ts.map +1 -1
- package/dist/delivery/decompose.js +31 -1
- package/dist/delivery/decompose.js.map +1 -1
- package/dist/delivery/repair-escalation.d.ts +49 -0
- package/dist/delivery/repair-escalation.d.ts.map +1 -0
- package/dist/delivery/repair-escalation.js +83 -0
- package/dist/delivery/repair-escalation.js.map +1 -0
- package/dist/delivery/verifier-ladder.d.ts +47 -0
- package/dist/delivery/verifier-ladder.d.ts.map +1 -1
- package/dist/delivery/verifier-ladder.js +87 -1
- package/dist/delivery/verifier-ladder.js.map +1 -1
- package/dist/self-harness/mods.d.ts +20 -1
- package/dist/self-harness/mods.d.ts.map +1 -1
- package/dist/self-harness/mods.js +41 -0
- package/dist/self-harness/mods.js.map +1 -1
- package/dist/self-harness/orchestrator.js +4 -0
- package/dist/self-harness/orchestrator.js.map +1 -1
- package/dist/self-harness/transfer.d.ts.map +1 -1
- package/dist/self-harness/transfer.js +2 -0
- package/dist/self-harness/transfer.js.map +1 -1
- package/dist/self-tuning/flag-writer.d.ts +48 -0
- package/dist/self-tuning/flag-writer.d.ts.map +1 -0
- package/dist/self-tuning/flag-writer.js +102 -0
- package/dist/self-tuning/flag-writer.js.map +1 -0
- package/dist/self-tuning/flags.d.ts +88 -0
- package/dist/self-tuning/flags.d.ts.map +1 -0
- package/dist/self-tuning/flags.js +189 -0
- package/dist/self-tuning/flags.js.map +1 -0
- package/dist/self-tuning/index.d.ts +25 -0
- package/dist/self-tuning/index.d.ts.map +1 -0
- package/dist/self-tuning/index.js +25 -0
- package/dist/self-tuning/index.js.map +1 -0
- package/dist/self-tuning/judge.d.ts +66 -0
- package/dist/self-tuning/judge.d.ts.map +1 -0
- package/dist/self-tuning/judge.js +145 -0
- package/dist/self-tuning/judge.js.map +1 -0
- package/dist/self-tuning/llm-tuner.d.ts +83 -0
- package/dist/self-tuning/llm-tuner.d.ts.map +1 -0
- package/dist/self-tuning/llm-tuner.js +191 -0
- package/dist/self-tuning/llm-tuner.js.map +1 -0
- package/dist/self-tuning/orchestrator.d.ts +90 -0
- package/dist/self-tuning/orchestrator.d.ts.map +1 -0
- package/dist/self-tuning/orchestrator.js +126 -0
- package/dist/self-tuning/orchestrator.js.map +1 -0
- package/dist/self-tuning/paired-validator.d.ts +50 -0
- package/dist/self-tuning/paired-validator.d.ts.map +1 -0
- package/dist/self-tuning/paired-validator.js +78 -0
- package/dist/self-tuning/paired-validator.js.map +1 -0
- package/dist/self-tuning/profiles/index.d.ts +11 -0
- package/dist/self-tuning/profiles/index.d.ts.map +1 -0
- package/dist/self-tuning/profiles/index.js +15 -0
- package/dist/self-tuning/profiles/index.js.map +1 -0
- package/dist/self-tuning/profiles/opus48.d.ts +11 -0
- package/dist/self-tuning/profiles/opus48.d.ts.map +1 -0
- package/dist/self-tuning/profiles/opus48.js +27 -0
- package/dist/self-tuning/profiles/opus48.js.map +1 -0
- package/dist/self-tuning/profiles/qwen36.d.ts +11 -0
- package/dist/self-tuning/profiles/qwen36.d.ts.map +1 -0
- package/dist/self-tuning/profiles/qwen36.js +33 -0
- package/dist/self-tuning/profiles/qwen36.js.map +1 -0
- package/dist/self-tuning/quality-scorer.d.ts +90 -0
- package/dist/self-tuning/quality-scorer.d.ts.map +1 -0
- package/dist/self-tuning/quality-scorer.js +180 -0
- package/dist/self-tuning/quality-scorer.js.map +1 -0
- package/dist/self-tuning/realtime-adaptor.d.ts +78 -0
- package/dist/self-tuning/realtime-adaptor.d.ts.map +1 -0
- package/dist/self-tuning/realtime-adaptor.js +127 -0
- package/dist/self-tuning/realtime-adaptor.js.map +1 -0
- package/dist/self-tuning/run.d.ts +61 -0
- package/dist/self-tuning/run.d.ts.map +1 -0
- package/dist/self-tuning/run.js +122 -0
- package/dist/self-tuning/run.js.map +1 -0
- package/dist/self-tuning/search-reducer.d.ts +76 -0
- package/dist/self-tuning/search-reducer.d.ts.map +1 -0
- package/dist/self-tuning/search-reducer.js +349 -0
- package/dist/self-tuning/search-reducer.js.map +1 -0
- package/dist/self-tuning/tuning-profile.d.ts +72 -0
- package/dist/self-tuning/tuning-profile.d.ts.map +1 -0
- package/dist/self-tuning/tuning-profile.js +134 -0
- package/dist/self-tuning/tuning-profile.js.map +1 -0
- package/dist/telemetry/session-telemetry.d.ts +25 -0
- package/dist/telemetry/session-telemetry.d.ts.map +1 -1
- package/dist/telemetry/session-telemetry.js +32 -0
- package/dist/telemetry/session-telemetry.js.map +1 -1
- package/dist/types/config.d.ts +13 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -1
- package/docs/design/LLM_SELF_TUNING_ANALYSIS.md +617 -0
- package/docs/guides/SELF_TUNING.md +137 -0
- package/package.json +1 -1
- package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
- package/tools/agents/scripts/__pycache__/toolcall_path_normalizer.cpython-312.pyc +0 -0
- package/tools/agents/scripts/anthropic_proxy.py +355 -29
- package/tools/agents/scripts/confidence_escalation.py +60 -4
- package/tools/agents/tests/test_confidence_escalation.py +77 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# LLM Self-Tuning
|
|
2
|
+
|
|
3
|
+
Raise a small model (e.g. qwen3.6) toward Opus-level output by tuning UAP's own
|
|
4
|
+
flag surface with a closed, benchmark-validated loop. Where **Self-Harness**
|
|
5
|
+
(`uap self-harness`) mines failure traces and rewrites proxy/scaffold knobs to
|
|
6
|
+
fix *correctness* bugs, **Self-Tuning** (`uap tune`) optimizes the first-class
|
|
7
|
+
settings surface — recipes, hands-free, memory, concurrency, proxy guardrails —
|
|
8
|
+
against a *quality* signal.
|
|
9
|
+
|
|
10
|
+
> Design: [`docs/design/LLM_SELF_TUNING_ANALYSIS.md`](../design/LLM_SELF_TUNING_ANALYSIS.md).
|
|
11
|
+
|
|
12
|
+
## The idea
|
|
13
|
+
|
|
14
|
+
A small model can't reliably judge its own output, and pass/fail on a task suite
|
|
15
|
+
doesn't tell you how *good* the output is. Self-tuning adds:
|
|
16
|
+
|
|
17
|
+
1. **A quality signal** (P0) — a multi-dimensional `QualityScore` (correctness,
|
|
18
|
+
quality, efficiency, tool-reliability, planning → composite 0-100), scored by
|
|
19
|
+
a stronger **judge model** when configured, or deterministically from the run
|
|
20
|
+
metrics otherwise.
|
|
21
|
+
2. **An LLM-guided tuner** (P1) — a stronger model proposes small, interpretable
|
|
22
|
+
flag changes given the quality history; when no judge is available a real
|
|
23
|
+
**Gaussian-process Bayesian optimizer** (ARD kernel over the mixed
|
|
24
|
+
numeric/enum/bool flag space, Expected-Improvement acquisition) picks the next
|
|
25
|
+
config instead.
|
|
26
|
+
3. **A closed loop** (P2) — every proposal is applied, validated by a paired A/B
|
|
27
|
+
benchmark (candidate config vs current, quality-scored), and accepted only on
|
|
28
|
+
a statistically-supported quality lift with no held-out regression.
|
|
29
|
+
4. **Model profiles** (P3) — the best-known config per model family, persisted
|
|
30
|
+
and reused; bundled starters for qwen3.6 and Opus ship in the box.
|
|
31
|
+
5. **Real-time adaptation** (P4) — per-session flag adjustments emitted from live
|
|
32
|
+
signals (tool-failure spikes, quality dips, context pressure, RECON loops)
|
|
33
|
+
over the one live channel the proxy honors mid-session.
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Dry-run a tuning loop over the real-gate suite with a local model (GP-only,
|
|
39
|
+
# no judge). Reports the best config it found without committing.
|
|
40
|
+
uap tune --model qwen36-a3b --adapter opencode
|
|
41
|
+
|
|
42
|
+
# Same, but let a stronger judge model both SCORE quality and PROPOSE changes.
|
|
43
|
+
uap tune --model qwen36-a3b --adapter opencode --judge opus-4.8
|
|
44
|
+
|
|
45
|
+
# Commit the tuned config to .uap.json / .uap/proxy.env and save the profile.
|
|
46
|
+
uap tune --model qwen36-a3b --adapter opencode --judge opus-4.8 --apply
|
|
47
|
+
|
|
48
|
+
# Offline smoke test (deterministic mock adapter — no live model needed):
|
|
49
|
+
uap tune --adapter mock --max-iterations 3 --json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`uap self-harness tune` is an alias of `uap tune`.
|
|
53
|
+
|
|
54
|
+
### Key flags
|
|
55
|
+
|
|
56
|
+
| Flag | Meaning |
|
|
57
|
+
|------|---------|
|
|
58
|
+
| `--model <id>` | Executor model family to tune (default `qwen36-a3b`). |
|
|
59
|
+
| `--adapter <name>` | `mock \| opencode \| claude \| mini \| raw \| deliver`. |
|
|
60
|
+
| `--judge <id>` | Judge/tuner model. Falls back to `recipes.judge.model`, then GP-only. |
|
|
61
|
+
| `--phase <name>` | Force one search phase: `coarse \| medium \| fine \| combinatorial`. |
|
|
62
|
+
| `--max-iterations <n>` | Tuning-loop budget (default 6). |
|
|
63
|
+
| `--apply` | Commit accepted configs + save the profile (default: dry-run). |
|
|
64
|
+
| `--json` | Machine-readable result. |
|
|
65
|
+
|
|
66
|
+
## What gets tuned
|
|
67
|
+
|
|
68
|
+
The tunable surface (`src/self-tuning/flags.ts`) is a curated subset of the
|
|
69
|
+
settings registry, each with a search domain and a **dependency** so the
|
|
70
|
+
optimizer never wastes trials on an inactive knob (e.g. `recipes.fusionN` only
|
|
71
|
+
matters when `recipes.recipe` is `fusion`/`auto`, which itself needs
|
|
72
|
+
`recipes.enabled`):
|
|
73
|
+
|
|
74
|
+
- **recipes**: `enabled`, `recipe`, `confidenceThreshold`, `fusionN`, `allowSelfJudge`
|
|
75
|
+
- **hands-free**: `enabled`, `intensity`, `UAP_HANDSFREE_STAGNATION_LIMIT`
|
|
76
|
+
- **concurrency**: `modelConcurrency.slots`, `modelConcurrency.adaptive`
|
|
77
|
+
- **memory**: `memory.shortTerm.maxEntries`, `memory.patternRag.enabled`
|
|
78
|
+
- **verification**: `delivery.runtimeVerify`
|
|
79
|
+
- **proxy guardrails**: `PROXY_RECON_CONVERGENCE_THRESHOLD`, `PROXY_LOOP_BREAKER`, `PROXY_STUCK_BREAK`
|
|
80
|
+
|
|
81
|
+
All writes go through the same validation as `uap config set`, so an
|
|
82
|
+
out-of-range proposal is clamped — it can never corrupt `.uap.json`. Rejected
|
|
83
|
+
trials are rolled back to the exact prior bytes.
|
|
84
|
+
|
|
85
|
+
## Profiles
|
|
86
|
+
|
|
87
|
+
Accepted configs advance a versioned `TuningProfile` under
|
|
88
|
+
`.uap/self-tuning/<model>.json`. Bundled starter profiles seed a fresh run and
|
|
89
|
+
act as cross-model transfer priors:
|
|
90
|
+
|
|
91
|
+
- **qwen3.6** — guardrail-heavy, judge-backed fusion, aggressive hands-free.
|
|
92
|
+
- **Opus 4.8** — the quality upper bound (most guardrails relaxed).
|
|
93
|
+
|
|
94
|
+
The runtime source of truth is the typed constants in
|
|
95
|
+
`src/self-tuning/profiles/*.ts`; the sibling `*.json` files are human-readable
|
|
96
|
+
reference artifacts.
|
|
97
|
+
|
|
98
|
+
## Real-time adaptation (auto-on)
|
|
99
|
+
|
|
100
|
+
The proxy freezes `PROXY_*` at startup and has no reload endpoint, so mid-session
|
|
101
|
+
tuning rides a per-session **adaptation signal** file — the same mechanism as the
|
|
102
|
+
recipe signal. It is **on by default** and conservative: a signal is emitted only
|
|
103
|
+
when a live signal actually breaches a threshold, so a nominal session behaves
|
|
104
|
+
exactly as before.
|
|
105
|
+
|
|
106
|
+
Live signals map to hot-reloadable adjustments:
|
|
107
|
+
|
|
108
|
+
| Signal | Adjustment |
|
|
109
|
+
|--------|-----------|
|
|
110
|
+
| tool-failure rate ↑ / turn-quality ↓ | escalate this turn to the judge (fusion) |
|
|
111
|
+
| context-window utilization ↑ | converge sooner (lower recon threshold) |
|
|
112
|
+
| RECON no-write streak ↑ | force synthesis / deliver now |
|
|
113
|
+
|
|
114
|
+
### Turning it off
|
|
115
|
+
|
|
116
|
+
The reactor emitter is the effective master switch — with it off, no signal is
|
|
117
|
+
written, so the proxy has nothing to honor. Any of these opts out:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
uap config set realtimeAdapt.enabled false # persistent, project-level (recommended)
|
|
121
|
+
export UAP_REALTIME_ADAPT=0 # per-shell override (wins over config)
|
|
122
|
+
uap config set PROXY_REALTIME_ADAPT false # also make the proxy ignore signals
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Precedence for the emitter: explicit call arg → `UAP_REALTIME_ADAPT` env →
|
|
126
|
+
`.uap.json realtimeAdapt.enabled` → default **on**.
|
|
127
|
+
|
|
128
|
+
## How it relates to Self-Harness
|
|
129
|
+
|
|
130
|
+
| | Self-Harness (`uap self-harness`) | Self-Tuning (`uap tune`) |
|
|
131
|
+
|---|---|---|
|
|
132
|
+
| Input | failure traces (HALO + proxy log) | quality-scored benchmark A/B |
|
|
133
|
+
| Optimizes | correctness (proxy/llama env, scaffold, middleware) | quality (first-class settings) |
|
|
134
|
+
| Proposer | heuristic + transfer | LLM tuner or GP-BO |
|
|
135
|
+
| Signal | pass/fail + McNemar | composite quality delta |
|
|
136
|
+
| Shared | the paired-bench validation pipeline, the Mod DSL (now incl. `ConfigMod`), and the versioned-profile pattern |
|
|
137
|
+
```
|
package/package.json
CHANGED
|
Binary file
|