Every ticket as the root of its provenance graph — goal, patch, approval, runs and (as the ticket-class build lands) mandate, manifestations, guarantees, journey, artifacts and children. Rendered through the <<<TicketGraphList>>> tag.
goal
Create tools/test_wire.py: an INTEGRATION suite that proves CLI flags actually reach the
request body on the wire. Ticket #470 fixed a dead --num-ctx parameter that a green
180-check selftest never caught, because the suite tested the FUNCTION and nothing tested
the WIRE between the flag and the function:
ck("--num-ctx overrides the sizing", num_ctx_for("fake:test", 100, override=16384) == 16384)
num_ctx_for() honoured `override` perfectly the whole time. The flag never reached it. The
check's NAME made a claim about the flag while its BODY verified a claim about the function.
This file exists to close that class of gap: every check here reads the ACTUAL request body
handed to the transport.
THE STANDARD: every check ships its NEGATIVE CONTROL, marked NEG. A check that cannot fail
proves nothing. Each NEG asserts the property FAILS when the mechanism is disabled -- that is
what proves the positive check would go RED if the wiring were removed.
HOW TO READ THE WIRE. Monkeypatch the transport and capture the body, restoring it after:
import sys, os, time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import ollama_agent as OA
seen = []
_real = OA._ollama
OA._ollama = lambda path, body, timeout=600: (
seen.append(body) or {"message": {"content": '{"tool":"finish","args":{}}'}})
try:
...checks...
finally:
OA._ollama = _real
REQUIRED CHECKS -- three sections:
1. --num-ctx REACHES options.num_ctx (the #470 regression guard)
POS: OA.constrained("gemma-coder", [{"role":"user","content":"x"}], {"type":"object"},
0, time.time()+60, num_ctx=32768)
-> seen[-1]["options"]["num_ctx"] == 32768
NEG: the same call WITHOUT num_ctx -> options.num_ctx is SIZED to the payload (8192),
and is NOT 32768. Assert both "is not None" and "!= 32768".
Name these checks after what they VERIFY, not after the flag alone -- that naming habit
is what hid #470.
2. --temperature REACHES options.temperature
POS: OA.chat("gemma-coder", [{"role":"user","content":"x"}], temperature=0.1)
-> seen[-1]["options"]["temperature"] == 0.1
NEG: OA.chat(...) with no temperature -> options.temperature == OA.DEFAULT_TEMPERATURE,
so the flag is what changes it.
NEG: the ollama flavor NEVER carries top_p -- assert "top_p" not in seen[-1]["options"].
This is load-bearing: it is why a Modelfile `PARAMETER top_p` is the only way to set
top_p, and why a Modelfile `PARAMETER temperature`/`num_ctx` is NOT in force (the
agent overrides both on every request).
3. reasoning_params() sends EXACTLY ONE dialect key, never both
NOTE the local signature: reasoning_params(kind) takes ONE argument. It does NOT
discriminate on model family. Do not write a model-family test -- read the function
before you test it.
POS: reasoning_params("cheap") == {"reasoning_effort": "none"}
POS: reasoning_params("agentic") == {"clear_thinking": False}
NEG: for BOTH kinds, exactly one of {"reasoning_effort", "clear_thinking"} is present --
never both, never neither. That is the function's stated contract.
STRUCTURE. Mirror the repo's existing selftest idiom: a ck(name, ok) helper that appends to
PASS/FAIL and prints " PASS <name>" / " FAIL <name>", a summary line at the end, and
sys.exit(1 if FAIL else 0) so CI can see red. Runs with a bare `python3 tools/test_wire.py`.
NO network, NO Ollama, NO api key, NO server -- the transport is monkeypatched, and the base
repo and db must never be written.
VERIFY BEFORE REPORTING DONE, all three:
(a) `python3 tools/test_wire.py` passes, and report the observed count (e.g. 8/8).
(b) Prove the suite can go RED: temporarily revert the #470 threading in your worktree copy
(change `num_ctx_for(model, chars + 2000, override=num_ctx)` back to
`num_ctx_for(model, chars + 2000)`), re-run, and confirm section 1's POS check FAILS.
THEN PUT IT BACK and confirm green again. Report both observations. A suite you never
saw fail is a suite you have not tested.
(c) `python3 tools/ollama_agent.py --selftest` still passes 180/180 (you must not have left
the revert from (b) in place).
SCOPE. The harness commits tools/test_wire.py and NOTHING else. Do not modify
tools/ollama_agent.py -- #470 already landed the fix and any edit you leave there is a stray
that is NOT committed and does not survive the reap. Revert step (b) completely.