Files
leleka/scripts/e2e/evidence/engine_meta_lines.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 7736b2ced9 STRA-325: engine start-up metadata lines (leleka-serve meta:)
The serving engine now prints, once at start-up on stderr, a stable machine-parsable
line set beside the unchanged cpu:/gpu: kernel lines:
  meta: build  (git commit, dirty flag, target triple, cargo features, profile name,
                profile file hash if the launcher passes it, hash of the effective values)
  meta: model  (the RECORDED model digest, file size and mtime; nothing is hashed)
  meta: config (context, chunk, prefix block/tail, cpu_workers, KV mode, expert tier,
                speculation)
  meta: cache  (prefix-cache entries/bytes, EMPTY/WARM)
New: crates/leleka-runtime/build.rs, src/serve_meta.rs (pure formatting + unit tests
pinned to scripts/e2e/evidence/golden/engine_meta_sample.txt), two call sites in
backend_original_serve.rs, one Run field set in backend.rs. No behaviour or inference
change; no engine/strata, PTX or provenance change.

capture.py reads build/model/config from either the older run-facts lines or the meta
lines and cross-checks an engine meta cache line; engine_meta_lines.md documents the
fields; test_capture.py gains TestEngineMetaLines.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 21:54:35 +01:00

85 lines
5.4 KiB
Markdown

# Engine start-up lines `leleka-serve meta:` (STRA-325)
The serving engine (`leleka-inference`, crate `leleka-runtime`) prints these lines once at start-up on stderr, beside the `leleka-serve cpu:` and `gpu:` kernel lines
(which are unchanged). They are the engine's side of the run-facts that `capture.py` (STRA-251) needs for an END_TO_END record. Stdout/stderr only, no endpoint.
Source of truth for the format: `crates/leleka-runtime/src/serve_meta.rs`. The golden sample `golden/engine_meta_sample.txt` is pinned byte for byte by a Rust unit test
(`serve_meta::tests::the_meta_lines_match_the_golden_sample_byte_for_byte`) and parsed by `test_capture.py` (`TestEngineMetaLines`).
## Shape
```
leleka-serve meta: <section> v=1 key=value key=value ...
```
One line per section, tokens separated by one blank, a value never contains a blank or `=` (they become `_`, an empty value is `-`). `v=` is raised when a key or its meaning
changes; `capture.py` refuses a version it does not know (exit 3). Order of printing: `build`, `model`, `config` before the serve stack opens (so they appear even when the
open fails), `cache` after it opened. They are printed on the first open only, not on a run-time reconfigure.
## Sections and fields
`build` - what the binary is, and which profile it was started with.
| Key | Meaning |
| --- | --- |
| `commit` | `git rev-parse HEAD` of the build (build.rs); env `LELEKA_BUILD_COMMIT` overrides it for a build from an archive; `unknown` when neither exists |
| `dirty` | `0` tracked files equal HEAD, `1` they differ, `unknown`; env `LELEKA_BUILD_DIRTY` (0/1) overrides |
| `target` | target triple (`TARGET`) |
| `features` | cargo features of `leleka-runtime`, sorted, `-` when none (`sm86` is the only one; an sm_120 default build prints `-`) |
| `cargo_profile` | `release` or `debug` |
| `profile` | profile name from env `LELEKA_PROFILE`, else `none` |
| `profile_sha256` | SHA-256 of the profile FILE, from env `LELEKA_PROFILE_SHA256` (64 lower-case hex), else `unset` |
| `values_sha256` | SHA-256 over `key=value\n` of every field of the `config` section in the printed order (computed by the engine) |
`model` - the digest is the one RECORDED in this build (the pinned constant; the engine hashes nothing for this line).
| Key | Meaning |
| --- | --- |
| `digest` | `sha256:<hex>` of the pinned two-shard IQ3_S model |
| `mapping` | how `digest` is made: `pinned-constant:sha256(shard0.raw32\|\|shard1.raw32)` |
| `verify` | `recorded-no-rehash`: nothing is hashed for this line |
| `files` | number of model files, then `file0=`, `file1=` ... each `<file name>:<bytes>:<mtime_unix_s>` (stat only; `-` when unreadable) |
`config` - the effective tuning values.
| Key | Meaning |
| --- | --- |
| `context_tokens` | served context |
| `kv` | KV storage name (`int8`) |
| `slots` | concurrent requests (1: the serve stack takes one at a time) |
| `batch` | prompt batch = the prefill chunk |
| `speculation` | `mtp` |
| `spec_min_p` | draft-probability floor |
| `chunk` | prefill chunk (`--original-prefill-capacity`) |
| `prefix_cache`, `prefix_block`, `prefix_tail` | prefix cache configured `on`/`off`, tokens per block (`-` off), request-end checkpoints `off`/`prompt`/`reply`/`none` |
| `cpu_workers` | CPU expert workers |
| `kv_resident` | resident KV cells per layer |
| `expert_tier` | `off`, `auto` or the slot count; `expert_per_layer`, `expert_profile` (1/0, a profile file is set), `pcie_frac` |
`cache` - the engine's own caches right after the stack opened.
| Key | Meaning |
| --- | --- |
| `engine_state` | `EMPTY` (no prefix entries) or `WARM` |
| `prefix_cache` | `on` / `off` after the budget was resolved |
| `prefix_entries`, `prefix_blocks`, `prefix_used_bytes`, `prefix_budget_bytes` | contents and budget of the prefix cache |
| `os_page_cache` | always `not-probed`: the OS page cache is the runner's measurement (`cache_state.py`, STRA-288), not the engine's |
## How `capture.py` uses them
`capture.py` reads `build`, `model` and `config` from either form: the older run-facts lines (`leleka-serve build: ...`) or these `meta:` lines; lines of both forms must agree.
| Record field | From |
| --- | --- |
| `ours_build_id_observed` {commit, target_triple, cargo_features, profile_value_sha256} | `build` commit, target, features, `profile_sha256` (when it is `unset`: `values_sha256`, with a warning on stderr) |
| `software.leleka_commit` | `build` commit |
| `model.digest`, `model.digest_mapping` | `model` digest, mapping |
| `configuration` {context_tokens, kv, slots, batch, speculation} | `config` |
| `cache` | still the runner's `leleka-serve cache:` line (state, metric, value, unit); an engine `meta: cache` line is cross-checked: `WARM-OS/EMPTY-ENGINE` requires `engine_state=EMPTY` and `prefix_entries=0` (else exit 3) |
Not carried into the record (the schema has no field): `dirty` (a warning on stderr when not `0`), `cargo_profile`, `values_sha256` beyond the fallback, the model file sizes and mtimes.
Limits, stated: `profile_sha256` is only the hash of the profile file when the launcher passes `LELEKA_PROFILE_SHA256` (no launcher does yet, `crates/deploy` is unchanged); a run that
passes the profile's values as engine arguments (the wave-1 server shape) prints `unset` and `values_sha256`, which is NOT the hash of a profile file, so comparing it with a frozen
`profile_value_sha256` is only meaningful when the freeze (STRA-304/322) hashes the same thing. The git facts are those of the moment build.rs ran.