@miller-tech/uap 1.217.0 → 1.219.0

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 (38) hide show
  1. package/config/llama-patches/dflash2-pr27342.patch +1365 -0
  2. package/config/llama-profiles/qwen38-27b-dflash2.env +211 -0
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/cli/deliver.js +16 -0
  5. package/dist/cli/deliver.js.map +1 -1
  6. package/dist/cli/guided-setup.d.ts.map +1 -1
  7. package/dist/cli/guided-setup.js +8 -6
  8. package/dist/cli/guided-setup.js.map +1 -1
  9. package/dist/cli/hooks.d.ts.map +1 -1
  10. package/dist/cli/hooks.js +32 -0
  11. package/dist/cli/hooks.js.map +1 -1
  12. package/dist/cli/wizard-config.d.ts +2 -2
  13. package/dist/cli/wizard-config.d.ts.map +1 -1
  14. package/dist/config/settings-registry.d.ts.map +1 -1
  15. package/dist/config/settings-registry.js +22 -7
  16. package/dist/config/settings-registry.js.map +1 -1
  17. package/dist/coordination/reactor.d.ts +8 -0
  18. package/dist/coordination/reactor.d.ts.map +1 -1
  19. package/dist/coordination/reactor.js +43 -12
  20. package/dist/coordination/reactor.js.map +1 -1
  21. package/dist/mcp-router/tools/deliver.js +1 -1
  22. package/dist/mcp-router/tools/deliver.js.map +1 -1
  23. package/dist/types/config.d.ts +40 -16
  24. package/dist/types/config.d.ts.map +1 -1
  25. package/dist/types/config.js +10 -2
  26. package/dist/types/config.js.map +1 -1
  27. package/docs/guides/QWEN36_LLAMACPP.md +96 -37
  28. package/docs/reference/CONFIGURATION_REFERENCE.md +44 -8
  29. package/package.json +1 -1
  30. package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
  31. package/src/policies/enforcers/delivery_enforcement.py +226 -8
  32. package/templates/hooks/__pycache__/deliver_autoroute.cpython-312.pyc +0 -0
  33. package/templates/hooks/deliver_autoroute.py +2 -2
  34. package/templates/hooks/escalation_tracker.py +252 -0
  35. package/templates/hooks/stop.sh +10 -0
  36. package/templates/hooks/uap-policy-gate.sh +5 -5
  37. package/tools/agents/scripts/__pycache__/toolcall_path_normalizer.cpython-312.pyc +0 -0
  38. package/tools/agents/scripts/anthropic_proxy.py +112 -4
@@ -0,0 +1,211 @@
1
+ # =====================================================================
2
+ # Qwen 3.8 27B (dense, UD-IQ4_XS) @ 131072 ctx/slot / 2 slots, DFlash2
3
+ # speculative decoding -- 2026-08-20. THIS IS THE DEFAULT PROFILE.
4
+ # Service: uap-llama-server.service -> scripts/run-llama-server-continuity.sh
5
+ # Install: cp to ~/.config/uap/llama-server.env
6
+ #
7
+ # Supersedes qwen38-27b-mtp.env (kept alongside as the fallback). Same model,
8
+ # same context, same slot count -- ONLY the speculative-decoding config differs.
9
+ #
10
+ # MEASURED, not assumed (RTX 3090 24 GiB, sm_86, temp 0, 4 prompts,
11
+ # 1032 tokens/arm, same binary across arms so spec config is the only variable):
12
+ #
13
+ # arm aggregate tok/s accept tok/verify step
14
+ # draft-mtp --parallel 1 59.3 93.6% 2.68
15
+ # DFlash2 n4 --parallel 1 68.7 67.4% 3.68 1.16x
16
+ # draft-mtp --parallel 2 66.0 92.5% 2.67
17
+ # DFlash2 n4 --parallel 2 89.8 66.5% 3.66 1.36x
18
+ #
19
+ # The --parallel 2 row is two GENUINELY CONCURRENT requests, i.e. the
20
+ # production shape. Note this CONTRADICTS the upstream PR thread, whose
21
+ # reviewers report DFlash2 degrading at -np>=2; on this card the advantage
22
+ # GROWS under concurrency. Re-measure before trusting it on other hardware.
23
+ #
24
+ # WHY n-max 4 AND NOT 7: n-max 7 was measured too and was SLOWER (69.8 vs
25
+ # 76.7 tok/s in the first pass) despite accepting a longer block (4.86 vs
26
+ # 3.87 tokens/step). Acceptance falls from 72% to 55% as the block lengthens,
27
+ # so the extra drafting work outruns what it buys. The drafter card's
28
+ # published acceptance length of 5.39 is real but is not the throughput
29
+ # optimum here.
30
+ #
31
+ # VRAM -- THE REAL COST. Peak in this exact shape (262144 total ctx,
32
+ # --parallel 2, both slots driven concurrently) is 23449 / 24576 MiB, i.e.
33
+ # ~1.1 GiB free. The drafter's weights are the obvious cost, but the MARGINAL
34
+ # cost vs draft-mtp is NOT measured: no paired probe of the mtp profile was ever
35
+ # taken with the same harness, and docs/guides/QWEN36_LLAMACPP.md reports ~0.95
36
+ # GiB free for draft-mtp at this same tier -- which cannot both be true and
37
+ # leave DFlash2 roomier. Do not quote a delta until both are re-measured with
38
+ # one harness. The 23449 figure is also a 1 s nvidia-smi sample over a ~10 s run
39
+ # whose longest prefill was 540 tokens; it never saw a long-context prefill on
40
+ # two slots, which is the actual peak event at 131072/slot.
41
+ #
42
+ # KNOWN DEFECT OF THIS BUILD -- SHUTDOWN HANGS. The PR-27342 binary can deadlock
43
+ # in __futex_wait after printing "cleaning up before exit...", so SIGTERM does
44
+ # not always complete. Under systemd this is contained: TimeoutStopSec=20 then
45
+ # SIGKILL, and the cgroup releases the VRAM. Started OUTSIDE systemd it is not:
46
+ # observed 2026-08-20 leaving an orphaned llama-server holding 21362 MiB with no
47
+ # listening socket, which starves the real service on load. Always drive this
48
+ # profile through `systemctl --user {start,stop,restart} uap-llama-server`, and
49
+ # if a load fails with an allocation error check
50
+ # `nvidia-smi --query-compute-apps=pid,used_memory --format=csv` for an orphan
51
+ # first. This card has a history of GLOBAL kernel
52
+ # OOM events selecting this service for its RSS (see the --cache-ram note
53
+ # below), and the GPU side is now thinner too. If the server starts dying or
54
+ # failing to load, switch back to qwen38-27b-mtp.env FIRST -- that is the
55
+ # whole reason it is kept.
56
+ #
57
+ # ENGINE IS AN UNMERGED UPSTREAM PR. LLAMA_BIN below is built from
58
+ # ggml-org/llama.cpp#27342 ("support DFlash2", commit 5ecbe1ac1) cherry-picked
59
+ # onto f466cfa38 with zero conflicts. The patch is vendored at
60
+ # config/llama-patches/dflash2-pr27342.patch so the build is reproducible if
61
+ # that worktree is lost -- create a detached llama.cpp worktree at f466cfa38,
62
+ # apply that patch to it, then configure with CUDA on, arch 86, native on,
63
+ # shared libs on, Release, and build the llama-server target.
64
+ # The merged draft-dflash v1 engine CANNOT substitute: a v2 checkpoint declares
65
+ # the same general.architecture="dflash", so auto-detect picks draft-dflash and
66
+ # then fails on the 23 conv/selector tensors and dflash.conv_*/selector_* keys
67
+ # v1 has no loader for. Return to plain master once #27342 lands upstream.
68
+ # =====================================================================
69
+ LLAMA_BIN=/home/cogtek/llama.cpp/.worktrees/dflash2-trial/build-cuda/bin/llama-server
70
+ LLAMA_MODEL=/home/cogtek/Downloads/Qwen3.8-27B-UD-IQ4_XS.gguf
71
+ # CONFIRMED INCOMPATIBLE 2026-08-20: mmproj-BF16.gguf crashed the server on
72
+ # load -- "mismatch between text model (n_embd = 5120) and mmproj
73
+ # (n_embd = 2048)". It was built for a different, smaller model's vision
74
+ # tower, not Qwen3.8-27B (n_embd 5120). Same applies to mmproj-F16.gguf
75
+ # (same family of file, unverified for this model). Do not re-enable either
76
+ # without a projector confirmed to report n_embd=5120 for its text side.
77
+ # "none" is a real opt-out (added to the continuity script 2026-08-20); an
78
+ # empty value is NOT equivalent -- it still falls through to auto-detect,
79
+ # which is how this got picked up in the first place.
80
+ LLAMA_MMPROJ=none
81
+
82
+ LLAMA_HOST=0.0.0.0
83
+ LLAMA_PORT=8080
84
+ LLAMA_CTX_SIZE=262144
85
+ LLAMA_PARALLEL=2
86
+ # UAP RAILS -- KEEP IN SYNC WITH THESE TWO LINES (~/.config/uap/anthropic-proxy.env).
87
+ # --ctx-size is the TOTAL across slots; /props reports the PER-SLOT figure.
88
+ # 262144 / 2 slots = 131072 per slot, so the proxy rails must read:
89
+ # PROXY_CONTEXT_WINDOW=131072 (== per-slot ctx, NOT the total)
90
+ # PROXY_CONCURRENCY_LIMIT=2 (== LLAMA_PARALLEL, the slot count)
91
+ # Over-stating either one makes the proxy admit work the server cannot hold and
92
+ # turns a queue into context-overflow errors. Re-derive from /props after any
93
+ # change here. LLAMA_PORT below must match the proxy's LLAMA_CPP_BASE port; the
94
+ # proxy auto-discovers a live server if its pin is stale, but the pin should
95
+ # still be correct so a cold boot does not depend on discovery.
96
+ LLAMA_THREADS=16
97
+ LLAMA_GPU_LAYERS=99
98
+
99
+ LLAMA_CACHE_TYPE_K=q4_0
100
+ LLAMA_CACHE_TYPE_V=q4_0
101
+
102
+ LLAMA_BATCH_SIZE=512
103
+ LLAMA_UBATCH_SIZE=512
104
+
105
+ # DFlash2 speculative decoding. Unlike draft-mtp this needs a SEPARATE drafter
106
+ # file -- z-lab/Qwen3.8-27B-DFlash2-GGUF Q4_K_M, trained for this exact target.
107
+ # Q8_0 (2.0 GB) does NOT fit at this context tier; Q4_K_M (1.1 GB) does.
108
+ #
109
+ # The drafter carries its OWN 2048-token sliding window, so its KV cache is
110
+ # ~80 MiB at f16 regardless of the target's 131072/slot -- which is why this
111
+ # fits without cutting context or slots. Do not "fix" that by setting
112
+ # LLAMA_DRAFT_CTX_SIZE; leaving it unset is what keeps the KV small.
113
+ #
114
+ # n-min and p-min are pinned to 0 DELIBERATELY. The measurement above was taken
115
+ # with llama.cpp's defaults for a dflash drafter (n_min=0, p_min=0.00, per the
116
+ # server's own startup line). The continuity script always passes both flags, so
117
+ # leaving the draft-mtp values (1 / 0.75) here would gate the block-diffusion
118
+ # drafter on a per-token probability it was never measured with, and the numbers
119
+ # above would no longer describe what runs.
120
+ LLAMA_ENABLE_SPEC_DECODING=true
121
+ LLAMA_SPEC_TYPE=draft-dflash
122
+ LLAMA_DRAFT_MODEL=/home/cogtek/Downloads/Qwen3.8-27B-DFlash2-Q4_K_M.gguf
123
+ LLAMA_DRAFT_GPU_LAYERS=99
124
+ LLAMA_DRAFT_MAX=4
125
+ LLAMA_DRAFT_MIN=0
126
+ LLAMA_DRAFT_P_MIN=0
127
+
128
+ # Sampling requested for this profile (llama-server defaults are top-p 0.95,
129
+ # top-k 40, temp 0.8 when unset -- see scripts/run-llama-server-continuity.sh).
130
+ LLAMA_TEMP=0.7
131
+ LLAMA_TOP_P=0.8
132
+ LLAMA_TOP_K=20
133
+
134
+ LLAMA_REPEAT_PENALTY=1.0
135
+ # LLAMA_CACHE_REUSE stays unset here (carried over from the previous Qwen3.6
136
+ # profile, where it never took effect). --cache-reuse (in-slot prompt PREFIX
137
+ # reuse) is disabled at load time in server-context.cpp whenever
138
+ # llama_kv_cache::get_can_shift() is false, which holds on three architectural
139
+ # conditions, none of them a flag: arch==STEP35; n_pos_per_embd()>1 (M-RoPE);
140
+ # or any layer with k_idx ("shifting would leave k_idx stale" -- the GDN
141
+ # linear-attention layers). qwen35-arch models (3.6, 3.8) trip the latter.
142
+ # The host-side prompt cache (--cache-ram) and --ctx-checkpoints are the
143
+ # mechanisms that DO run here.
144
+ LLAMA_SLOT_SAVE_PATH=/home/cogtek/.cache/inference/kv-slots
145
+ LLAMA_LOG_FILE=/home/cogtek/llama.cpp/llama-server.log
146
+ LLAMA_N_PREDICT=32768
147
+
148
+ # CHAT TEMPLATE (2026-08-20): switched from qwen3.5-enhanced.jinja to
149
+ # qwen-sharp.jinja -- peculiar-ragdoll/Qwen-Sharp-Chat-Templates
150
+ # (template_version qwen3.8-froggeric-v22.1), vendored verbatim at
151
+ # tools/agents/config/qwen-sharp.jinja. It targets Qwen 3.5/3.6/3.8 and is the
152
+ # template for ALL qwen models here. Pinned artifact -- both are asserted in
153
+ # test/chat-template-system-message.test.ts so a silent re-vendor fails CI:
154
+ # upstream revision 3dc34df52c63dd22ada21f96435e069deaa8d7da (2026-08-18)
155
+ # file sha256 d1f22a89eac3609dcfaa7b471b1f7d23bee2f084d275d26f4f8231d1d7908f4e
156
+ #
157
+ # WHAT IT FIXES: qwen3.5-enhanced.jinja hard-raised
158
+ # 'No user query found in messages.' -- a server-side failure for the whole
159
+ # request -- whenever no user turn survived its backwards scan, i.e. when every
160
+ # user turn was a <tool_response> or when the transcript was system+assistant
161
+ # only. Both shapes occur in normal agent loops. qwen-sharp renders them.
162
+ #
163
+ # WHAT STAYS COMPATIBLE (rendered and compared, not assumed):
164
+ # * the tool-call contract the model is told to EMIT is unchanged:
165
+ # <tool_call><function=NAME><parameter=K>V</parameter></function></tool_call>.
166
+ # anthropic_proxy.py's _HERMES_FUNCTION_RE / _TOOL_CALL_XML_RE parse it
167
+ # unchanged. The default is selected at render time by `_tool_format`, so
168
+ # the test asserts on RENDERED output -- the file contains a JSON emitter
169
+ # too, and a grep cannot tell which one is live.
170
+ # * the generation prompt matches the old template in BOTH enable_thinking
171
+ # states, so --reasoning auto --reasoning-format deepseek is unaffected.
172
+ # * a mid-conversation system message renders inline in both templates.
173
+ #
174
+ # WHAT ACTUALLY DIFFERS -- known and accepted:
175
+ # * HISTORY rendering of prior tool calls differs in whitespace only: with
176
+ # string-form `arguments` (the proxy's path -- it json.dumps them) the old
177
+ # template emitted "}\n</function>", the new one "}</function>"; and the
178
+ # separator between two tool calls in one assistant turn went "\n" ->
179
+ # "\n\n". Neither changes what the parsers accept.
180
+ # * the injected tool-calling instruction block was rewritten upstream: it now
181
+ # requires a <think> block before each tool call and forbids prose before
182
+ # the call. Behavioural, deliberate, not a wire change.
183
+ # * a system message containing an IMAGE now raises. Unreachable via the
184
+ # proxy, which flattens system to a text string before dispatch
185
+ # (anthropic_proxy.py ~4709). Direct-to-:8080 OpenAI clients can hit it.
186
+ # * unknown message roles no longer raise; they render as "[role]: content".
187
+ # * prior <think> blocks are retained across turns. Upstream sells this as a
188
+ # prompt-cache win; on the PROXY path it is a no-op, because the proxy
189
+ # already strips <think> from prior assistant turns on purpose
190
+ # (anthropic_proxy.py ~4725: "Stripping breaks the copy cycle"). On the
191
+ # direct path it re-introduces exactly that cycle -- pass
192
+ # chat_template_kwargs.preserve_thinking=false there if it shows up.
193
+ #
194
+ # chat_template_kwargs.reasoning_effort accepts
195
+ # none|minimal|low|medium|high|xhigh|max. NOTE: 'none' forces thinking OFF,
196
+ # overriding enable_thinking=true.
197
+ # Do NOT switch this to "embedded" -- the model's own baked-in template still
198
+ # carries the 'System message must be at the beginning.' raise.
199
+ LLAMA_CHAT_TEMPLATE_FILE=/home/cogtek/dev/miller-tech/universal-agent-protocol/tools/agents/config/qwen-sharp.jinja
200
+
201
+ # --cache-ram sizing inherited unchanged from the previous profile (measured
202
+ # working set was for a different model, but the host-RAM cache mechanism
203
+ # and its OOM history apply regardless of which model is loaded on the GPU
204
+ # side). Re-measure with the eviction grep in qwen36-35b-a3b.env's history
205
+ # if this model's prefill/eviction pattern differs materially.
206
+ #
207
+ # FLAG DRIFT: upstream renamed --checkpoint-every-n-tokens (old b8780
208
+ # spelling) to --checkpoint-min-step. An unknown flag makes llama-server
209
+ # exit 1, and systemd then burns its restart budget looping on it. Re-check
210
+ # every flag here against `llama-server --help` whenever LLAMA_BIN moves.
211
+ LLAMA_EXTRA_ARGS=--metrics --jinja --prio 2 --reasoning auto --reasoning-format deepseek --reasoning-budget 8000 --ctx-checkpoints 64 --checkpoint-min-step 2048 --cache-ram 16384