Files
Pavlo Ratushnyi ff6cb3dcbf STRA-338 S21: leleka-gateway-domain (layer L2): the pure gateway domain leaves strata-control
New crate crates/gateway-domain, the first member of layer L2 in architecture.json (L2 is now a pure layer: tokio, axum,
reqwest, libc and the other adapter crates are forbidden dependencies there). It depends on serde, serde_json,
leleka-sampler-ref and leleka-tokenizer only. Moved out of control-plane/src with git mv, content unchanged apart from
paths: sampling (request sampling extensions, validation) and EngineTune (was in wire.rs), reasoning_budget (the budget
driver and its tests), codec (Family, TextCodec, TokenDecoder, QwenCodec), json_order, and the Chat Completions
translation (chat_completions: Request -> Responses request, reply fields; the axum handlers stay in chat.rs).
strata-control re-exports codec, json_order, reasoning_budget and sampling under their old paths, and wire.rs re-exports
EngineTune, so no caller and no test outside the moved modules changed. 4 new tests cover the chat translation.

Architecture gate: layer entry added; dyn-trait:leleka-gateway-domain = 5 appears because the five dyn in the moved
code (Box<dyn TokenDecoder>, Box<dyn Iterator> in the budget driver, &dyn Fn, ...) change crate; dyn-trait:strata-control
fell 21 -> 16 in the same step, so the total is unchanged (--allow-increase was needed for the new per-crate key only).
Test outcomes: 597 ok / 2 ignored before, 615 ok / 2 ignored after (18 new tests); the 13 moved tests keep their ids in the
new crate and their outcome.
2026-11-05 20:42:48 +01:00

100 lines
4.8 KiB
Python

#!/usr/bin/env python3
"""Per-test outcomes from a `cargo test` log, and a comparison of two logs (STRA-338 gateway track).
test-outcomes.py extract LOG print "<binary> :: <test> :: <outcome>" lines, sorted
test-outcomes.py compare BEFORE AFTER list tests whose outcome changed, tests only in one log, and the totals
A "binary" is the `Running ...` / `Doc-tests ...` header the test came from. Pure stdlib.
"""
import re
import sys
def extract(path):
outcomes = {}
binary = "?"
unresolved = []
with open(path, encoding="utf-8", errors="replace") as log:
for line in log:
line = line.rstrip("\n")
running = re.match(r"\s*Running (?:unittests )?(.+?)(?: \((.*)\))?$", line)
if running:
source = running.group(1).replace(chr(92), "/")
artifact = (running.group(2) or "").replace(chr(92), "/").split("/")[-1]
artifact = re.sub(r"(-[0-9a-f]{16})?(\.exe)?$", "", artifact)
binary = f"{artifact} [{source}]"
continue
doc = re.match(r"\s*Doc-tests (.+)", line)
if doc:
binary = "doc:" + doc.group(1)
continue
result = re.search(r"(?:^|\s)test (\S+) \.\.\. (ok|FAILED|ignored)", line)
if result:
outcomes[(binary, result.group(1))] = result.group(2)
continue
# A test that prints (an engine's stderr, a log line) puts its verdict somewhere else in the stream.
# The name is kept as unresolved and settled by the binary's `test result:` summary line.
started = re.match(r"test (\S+) \.\.\. ", line)
if started:
unresolved.append(started.group(1))
continue
summary = re.match(r"test result: (ok|FAILED)\. (\d+) passed; (\d+) failed", line)
if summary:
for name in unresolved:
verdict = "ok" if summary.group(3) == "0" else "UNRESOLVED"
outcomes[(binary, name)] = verdict
unresolved = []
return outcomes
def main(argv):
if len(argv) == 2 and argv[0] == "extract":
for (binary, name), outcome in sorted(extract(argv[1]).items()):
print(f"{binary} :: {name} :: {outcome}")
return 0
if len(argv) == 3 and argv[0] == "compare":
before, after = extract(argv[1]), extract(argv[2])
changed = [(k, before[k], after[k]) for k in before if k in after and before[k] != after[k]]
only_before = sorted(set(before) - set(after))
only_after = sorted(set(after) - set(before))
# A test moved into a child module keeps its function name: pair such tests by (binary, last segment) when the
# pairing is unique on both sides, and compare their outcomes.
moved = []
for key in list(only_before):
tail = key[1].split("::")[-1]
old_same = [k for k in only_before if k[0] == key[0] and k[1].split("::")[-1] == tail]
new_same = [k for k in only_after if k[0] == key[0] and k[1].split("::")[-1] == tail]
if len(old_same) == 1 and len(new_same) == 1:
moved.append((key, new_same[0]))
only_before.remove(key)
only_after.remove(new_same[0])
# A test that moved to another crate keeps its full module path: pair those when unique too.
for key in list(only_before):
same = [k for k in only_after if k[1] == key[1]]
if len([k for k in only_before if k[1] == key[1]]) == 1 and len(same) == 1:
moved.append((key, same[0]))
only_before.remove(key)
only_after.remove(same[0])
for old_key, new_key in moved:
if before[old_key] != after[new_key]:
changed.append((old_key, before[old_key], after[new_key]))
else:
print(f"MOVED {old_key[0]} :: {old_key[1]} -> {new_key[0]} :: {new_key[1]} ({after[new_key]})")
for key, was, now in changed:
print(f"CHANGED {key[0]} :: {key[1]}: {was} -> {now}")
for key in only_before:
print(f"MISSING {key[0]} :: {key[1]} (was {before[key]})")
for key in only_after:
print(f"NEW {key[0]} :: {key[1]} ({after[key]})")
count = lambda d, o: sum(1 for v in d.values() if v == o)
print(f"before: {count(before, 'ok')} ok, {count(before, 'FAILED')} failed, {count(before, 'ignored')} ignored")
print(f"after: {count(after, 'ok')} ok, {count(after, 'FAILED')} failed, {count(after, 'ignored')} ignored")
print(f"changed={len(changed)} missing={len(only_before)} new={len(only_after)}")
return 1 if changed or only_before or any(after[k] == "FAILED" for k in only_after) else 0
print(__doc__)
return 2
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))