Commit Graph
12 Commits
Author SHA1 Message Date
Pavlo Ratushnyi 7b1922d116 gateway-text: prompt, response_tools and tool_output become one crate; desktop-core no longer compiles them twice (STRA-338 S8)
control-plane/src/{prompt,response_tools,tool_output}.rs (pure text logic: pinned chat template renderer, tool catalog, tool-call
parser) move by git mv to the new leaf crate crates/gateway-text. strata-control re-exports them under the same module paths
(crate::prompt, crate::tool_output keep working for tests and callers); strata-desktop-core replaces its three #[path] includes with
imports. The leleka-runtime GPU proof modules that hash prompt.rs follow the new location. The only text change in the moved files is
the relative include_str path to engine/strata. serde_json features (preserve_order + float_roundtrip) equal what both hosts already
got through unification.

Verified: cargo test strata-control + strata-desktop-core + gateway-text on the host: 504 tests, 0 failed; the 30 tests that vanish
are exactly the duplicate runtime_prompt/runtime_tool_catalog/runtime_tool_parser copies of the same 30 tests (11+2+17), which now run
once. WSL x86_64-linux cargo check --tests leleka-runtime: 62 warnings, unchanged. fmt clean on the new crate.
2026-11-05 13:32:35 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 ab54ae208f feat: experimental tool_call_recovery for drifted tool-call forms (default OFF)
Adds Options::recovery to tool_output and an opt-in setting, `tool_call_recovery` (config key) / STRATA_TOOL_CALL_RECOVERY=1
(environment, wins over the file; 0/false turns it off; anything else stops the start). It is off unless set, is read once at
start, logs "tool_call_recovery is ON (experimental)" at start, and logs every call it accepts. It is NOT part of the default
contract and has not passed a quality gate (docs/api-contract.md, "Tool-call recovery (experimental)").

With it on, a call for a DECLARED tool written next to the template form is read as the call (upstream 3fcb2106, #3441):
* <parameter=NAME> where <function=NAME> belongs; <=NAME>, <function:NAME>, <function =NAME> or <NAME> after <tool_call>;
* {"name": ..., "arguments": {...}} inside <tool_call>, also in a Markdown fence, arguments possibly a JSON string;
* a bare <function=NAME> ... </function> at the start of a line outside a code fence and inline code (a stray </tool_call>
  after it is dropped); the Markdown state is tracked over the text that has left the stream buffer, so streamed and whole
  readings agree;
* a second call in the same <tool_call>;
* for array/object arguments, brackets left open at the end and a bare string where an object member belongs (dropped).
An undeclared name stays an error in every form. Streaming: a batch is delivered when its </tool_call> arrives, a bare call when
the text after it shows it is over or at the end.

With the option off the reading is byte for byte the step-3 reading. The corpus test now reads every specimen twice (off and on)
and lists the failures of each; every streamed cut agrees with the whole reading in both. Recovery rate on the 41 Qwen specimens:
off 24/41 (58.5 %), on 30/41 (73.2 %); the 6 specimens that need recovery: off 0/6, on 6/6. That is code reach on upstream's
failure corpus, not a rate for real sessions. strata-control lib 339 passed (new: 3 recovery tests, 1 config test), corpus and the
quoted-value shapes pass with the option on and off.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 03:54:39 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 f528844ff9 fix: read the recoverable tool-call cases instead of failing the response
Four shapes that ended in response.failed (or 502 tool_call_parse_failed) are now calls, each logged on stderr as
"tool call accepted beyond the template form (closers supplied: N, arguments repaired: M, ...)":

* </function> left out: a </parameter> followed by </tool_call> ends the value and the call, but only when no </parameter>
  followed by <parameter= or </function> ends the value (upstream d7113273, #4427/#4077). A streamed response delivers such
  a call when the generation ends, not at its </tool_call>: only the end can tell it from </parameter></tool_call> quoted
  inside a value.
* </tool_call> left out: the call is whole when the next <tool_call><function=NAME> follows its </function>, or when its
  </function> ends a generation that stopped by itself (finish stop). A generation cut by the token limit never gets this.
* A call inside the reasoning (no </think>): a normal stop whose text ends on whole calls of declared tools, the first at
  the start of a line outside a code fence and inline code, is reasoning (completed) followed by those calls (upstream
  805ebe17/d7113273, #804). The calls' markup was already streamed as reasoning deltas; the final reasoning item ends before it.
* Damaged array/object arguments of a parameter declared array or object (not a union with string): a trailing or doubled
  comma, single quotes, Python True/False/None, extra closing brackets, and an array written as a JSON string of itself are read
  as written (upstream _Lenient, A4). Nothing is invented or dropped; open brackets and bare strings are not repaired here.

Undeclared tool names: upstream returns the call as text and counts it. That is NOT adopted. Text without a call ends an
agent's turn as if it were the answer, while a failed response is retried by the client (docs/e2e-run.md records a session that
survived one such failure), and native_tools_sdet / backend_worker_http pin the refusal. An undeclared tool is still an error;
it is never run and never published.

API: tool_output::{Options, Notes, Parsed, parse_with, calls_at_end}, Incremental::{with_options, finish_after, notes};
parse_complete and Incremental::new keep their strict default reading. Documented in docs/api-contract.md ("Tool-call
parsing") and docs/tool-call-corpus.md.

Corpus: 24 of 41 specimens read as upstream expects (13 before this commit). New unit tests cover each shape whole and
streamed; strata-control lib 334 passed, native_tools_sdet 14 passed, existing tests unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 03:48:29 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 b3274c1130 Merge claude/port-gpu-bringup (CUDA runtime port, upstream sync) into main
Linux / keyless-cuda-gate (push) Skipped
Rust port / port-typecheck (push) Failing after 8s
Desktop foundation / core (ubuntu-latest) (push) Failing after 11s
Rust port / port-oracles (push) Failing after 11s
Rust port / port-linux-tests (push) Failing after 14s
Rust port / port-fast (push) Failing after 9s
Linux / verify (push) Failing after 17s
Linux / keyless-cuda (push) Skipped
Linux / static-cuda-package (push) Skipped
Linux / hosted-cuda-package (push) Skipped
Linux / linux-static-cli (push) Skipped
Linux / linux-cli-container (push) Skipped
Linux / release-cli (push) Skipped
Brings the Rust/CUDA port of the Strata mode17 serve path together with the
CPU/iGPU/NPU gpt-oss runtime that main gained meanwhile.

Control plane: the Qwen tokenizer is the implementation behind the Qwen35
variant of codec::TextCodec (qwen(), encode_prompt() widen the trait; QwenCodec
derefs to the tokenizer), so control-token marks, images, chat template, the
runtime backend and vision keep their behavior, while the gpt-oss/Harmony path
and the worker pool keep main's. Config carries the union of fields; extra_workers
is rejected together with runtime, lazy_load, idle_unload_s and vision; the
gpt-oss family refuses top_k/min_p/penalties (its GEN line has no such keys).
leleka-kar-codec takes f16_bits_to_f32 from leleka-quant-core (identical code).
Workspace members and default-members are the union of both sides.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-27 08:32:33 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 1a77b2805c metrics: history is the last 60 health-tick samples, documented as such
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:57:51 +01:00
Pavlo Ratushnyi 75e7e47dcc control-plane: /api/requests monitor, the Python Monitor members of /metrics, Prometheus text exposition
Opt-in api_monitor keeps the last 100 requests of the chat, messages and responses dialects; /metrics gains engine, live, requests, totals, hardware, history; ?format=prometheus (or a scraper Accept) renders the same document as gauges and counters. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:18:32 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 6c26ccdbcd feat: prompt_date (utc | none | YYYY-MM-DD) for the gpt-oss system message; none is experimental (STRA-220)
The gpt-oss template writes "Current date: <UTC today>" into the system message, which is part of
the prefix a worker's KV cache is matched on, so every cache missed once a day at midnight UTC.
prompt_date in the config (STRATA_PROMPT_DATE) now selects: utc (default, unchanged), a fixed
YYYY-MM-DD, or none, which leaves the line out (RenderOptions::omit_date; the blank line after it
stays) for clients that give the date as a function tool. The control plane does not host tools;
the client supplies the tool.

Teacher-forced on four 770-957 token prompts the model is not indifferent: dropping the line
moves the next-token distribution by mean KL 0.034-0.056 (best token same at 89-90%), changing
only the date value by 0.023-0.040 (92-93%), numerical noise 0.005-0.023 (93-97%). Task quality
was not measured, so none is opt-in. Checked end to end through the control plane: 68 input
tokens for "Hi" with the date, 57 without, 68 with a fixed date; a bad value is refused at start.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 10:43:28 +02:00
Pavlo RatushnyiandClaude Opus 5.5 4821fc464b feat: worker pool in the control plane; two concurrent agent episodes on an iGPU and an NPU worker (STRA-220, experimental)
engine.extra_workers starts further supervised workers behind the one request channel
(control-plane/src/pool.rs). A dispatcher hands each request to an idle, ready worker,
preferring the one whose last prompt shares the longest prefix with it, so each conversation
keeps its cached prefix. It learns completion by relaying the result channel, so the worker
and its tests are unchanged. /ready and /status need every member ready. 4 dispatcher tests;
the 13 failing control-plane tests fail identically at 3ebcb3f (Windows).

Paired A/B, two scripted 4-turn episodes sent at once (Compare-ConcurrentEpisodes.ps1, 3
alternating pairs each), time until both are done:
- one iGPU worker, interleaved: 686-713 s; pool: 254-306 s, 2.33-2.73x. Mostly the second
  KV cache: the single worker re-prefilled every turn.
- one iGPU worker running the episodes in sequence: 317-342 s; pool: 292-303 s,
  1.05-1.14x. This is the second device's own share. Per-turn latency in the pool is higher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 20:56:46 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 494f74ccc9 docs: status, run recipe and contract notes for the API in front of the runtime
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 03:17:02 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 76d57a549c feat(control): MCP hub (stdio + Streamable HTTP), config keys and GET /mcp
Port of serve/mcp.py: server config validation, background start, paged
tools/list, <server>__<tool> namespacing, error-as-text results with the
character cap, restart on demand, cancellation, GET /mcp. Tested against the
Original's fake MCP server. The server-side tool loop is intentionally not
ported (documented).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:51:13 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 392037d83e feat(serving): port the operational HTTP surface of the Python server
control-plane serves /props, /slots, /v1/status, /api/health, /settings, /load, /unload,
/v1/load, /v1/unload, model aliases, CORS with the preflight ahead of authentication and the
own-page guard; replayed scenario by scenario against the real Python handlers. The worker
supervisor gains load/unload, lazy start, idle unload, reload gates (before_load, min free VRAM),
an outside stall watchdog and the reasoning-budget wrap-up (budget tracker golden-tested against
the Python Detokenizer/OutputParser loop). leleka-serving-policy adds CORS, idle, stall watchdog,
logits stride (golden vs the C++ header), request timings and alias rules.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:35:08 +02:00
Pavlo Ratushnyi 4013e0c9bd Import tracked Strata Next source snapshot
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
2026-10-05 18:15:08 +02:00