#1 [high] Lens findings: Subtraction/Simplicity on PR #575
PR #575 head a0d9065, 3 files, +237/−10.
VERDICT: product code is lean; the bulk to subtract is test scaffolding, not logic.
S1 (highest value) — helios/src/grammar/strict.rs: the new test tml_strict_parser_preserves_30_digit_integers (:3819-3922) duplicates the existing qwen_and_glm_strict_parsers_preserve_30_digit_integers (:3723-3817) verbatim in its data setup:
let big = "123456789012345678901234567890";at :3726 and :3827 (and a third copy as a literal at :3022).- the 20-line
big_schemajson! block at :3727-3746 and :3828-3847 is identical (object with $defs/BigInt, top/via_any/via_ref/nested, required, additionalProperties:false). validate_strict_tool_schema(&compiler, "audit", &big_schema)at :3747 and :3848.- the "5 occurrences of big" assertion at :3811-3815 and :3917-3921.
Fix: hoist
fn big_integer_case() -> (String, Value)(constant + schema) plus validators into themod testshelper area next toaccepts_bytes(:2471) /decoded_args(:2781), and call it from both tests. Removes ~44 duplicated lines. Caveat for the report: TML cannot fold into the existingfor (kind, wire)loop at :3748 because that loop buildscfgwithcontrol_tokens: vec![]andOutputStart::Content(:3771-3779) while TML needsbyte_tokenizer_with(&CONTROL_MARKERS), real control_tokens andOutputStart::RecipientHeader(:3821-3825, :3856-3867) — so only the shared data/schema is collapsible, not the whole test.
S2 — tests/server/test_inkling2.py: the new test re-resolves the service and hand-rolls four requests instead of reusing its own module fixture (:29-68), which already resolves the URL/model and does POST + streaming + error handling:
- :122-123
url = os.environ[...]; model_id = json.load(urllib.request.urlopen(url + "/v1/models", timeout=10))["data"][0]["id"]duplicates the fixture body at :31-33. - :155-171, :176-192, :194-209 are four near-identical
urllib.request.Request(..., json.dumps(dict(model=model_id, ...)).encode(), {"Content-Type": "application/json"})+urlopenblocks (~54 lines) where a single localpost(path, body)helper would be ~8 lines. Precedent in the same file: the fixture already hangs an attribute off the closure (ask.chunk = chunkat :67); testify also created a Service object with.model/.open/.request(tests/server/test_muse_spark.py:55-66). Honest caveat: the truncation cases cannot reuseservice(...)itself because the fixture assertsfinish_reason in ("stop", "tool_calls")(:63), so only the URL/model lookup and the POST plumbing are collapsible, not the assertions.
S3 — tests/server/test_inkling2.py:141 assert list(parsed.keys()) == ["big_id", "city"] and parsed["city"] == "Paris" — the key-order half cannot fail for old or new code (preserve_order already on, so args.to_string() preserved order too); delete that clause, keep parsed["city"] == "Paris". Same reasoning as Dossier note 5.
NOT deletable (pre-empt the "delete the workaround" answer): the !args.starts_with('{') guard at helios/src/output/tml.rs:353 replaces the old .filter(|v| v.is_object()) and is required for non-strict TMLv0, where no grammar constrains the body; existing test :566-575 ({"name":"lookup","args":[]} → visible text) depends on it. Likewise .trim() at :352 is load-bearing for the starts_with check.
LEAN, no change needed: helios/src/output/tml.rs:342-376. The change removes branches (as_object(), object.len() != 2, filter(is_object), name.to_owned()) and adds no flag, knob, or fallback path; deny_unknown_fields on the 7-line local RawCall replaces the hand-rolled arity check. It follows the module's existing raw-token idiom (RawArguments/strict_nonstring_raw/container_parameter in helios/src/output/tagged.rs:871-972) rather than inventing a parallel helper. The new parser unit test helios/src/output/tml.rs:620-642 reuses the existing run(...) harness (:446) and is not bloated — nothing to subtract there.
Nothing found on removal-worthy config knobs, speculative generality, or dead code in product paths; no AGENTS.md structural violation (no model-specific branch, no env-var switch, no new parser).
#3 [high] Research summary
Reviewed PR #575 at head a0d9065 through the subtraction/simplicity lens (3 files, +237/−10), reading the changed hunks plus the existing helpers they could reuse (helios/src/output/tagged.rs raw-token helpers, helios/src/output/gemma_call.rs, helios/src/grammar/strict.rs test helpers, tests/server/test_inkling2.py's own module fixture) and the relevant AGENTS.md sections.
The product change is genuinely lean and I say so plainly: TmlOutput::call (helios/src/output/tml.rs:342-376) removes branches rather than adding them (the old as_object(), object.len() != 2, filter(is_object) and name.to_owned() all disappear), introduces no flag, knob, fallback layer or dead code, replaces a hand-rolled arity check with deny_unknown_fields, and follows the module's existing raw-token idiom in tagged.rs instead of inventing a parallel helper. I explicitly checked and rejected the "just delete the workaround" angle: the !args.starts_with('{') guard at :353 is the replacement for the removed .filter(|v| v.is_object()) and is required for non-strict TMLv0 (existing test :566-575 depends on args:[] becoming visible text), and the .trim() at :352 is load-bearing for it.
Where the diff can be cut is test scaffolding, not logic. Top finding: the new strict-grammar test in helios/src/grammar/strict.rs:3819-3922 repeats the 30-digit constant, the entire 20-line big_schema, the validate_strict_tool_schema(&compiler, "audit", &big_schema) call and the "5 occurrences" assertion from the test immediately above it (:3723-3817); hoisting a shared case builder next to accepts_bytes/decoded_args removes ~44 duplicated lines, though the TML test cannot fold into the existing for (kind, wire) loop because it needs a real control-token tokenizer and OutputStart::RecipientHeader. Second: the new Python test re-resolves the service (:122-123 duplicating the fixture at :31-33) and hand-rolls four near-identical urllib POST blocks (~54 lines) instead of one local post(path, body) helper, a pattern the repo already uses (test_muse_spark.py:55-66); the truncation cases cannot reuse the fixture's ask because it asserts finish_reason in ("stop","tool_calls"). Third, a small cut: the property-order assertion at test_inkling2.py:141 cannot distinguish old from new behaviour and should go. A fourth, low-priority note covers the module fixture parametrizing the new live test twice with identical truncation requests.
No config knobs, speculative generality, dead code or AGENTS.md structural violations (no per-model branch, no env-var switch, no second parser) were found. Details and verbatim citations are in scratchpad notes 1 and 2.
#4 [high] Verbatim quotes for each simplification (final report needs these)
Verbatim code for the report (lens requires 3-12 line quotes per suggestion). Head a0d9065.
S1a — helios/src/grammar/strict.rs:3725-3729 (existing test, qwen_and_glm_strict_parsers_preserve_30_digit_integers, :3723-3817):
let compiler = GrammarCompiler::new(&byte_tokenizer(), 320, &[256, 257], &[]).unwrap();
let big = "123456789012345678901234567890";
let big_schema = json!({
"type": "object",
"$defs": {"BigInt": {"type": "integer"}},
S1b — identical lines in the PR's new test, helios/src/grammar/strict.rs:3826-3833 (tml_strict_parser_preserves_30_digit_integers, :3819-3922):
let compiler = GrammarCompiler::new(&tokenizer, 320, &[256, 257], &controls).unwrap();
let big = "123456789012345678901234567890";
let big_schema = json!({
"type": "object",
"$defs": {"BigInt": {"type": "integer"}},
"properties": {
"top": {"type": "integer"},
(the whole big_schema object at :3828-3847 is byte-identical to :3727-3746; let validator = validate_strict_tool_schema(&compiler, "audit", &big_schema).unwrap(); at :3747 and :3848; assertion at :3811-3815 == :3917-3921).
Concrete replacement: add to mod tests beside accepts_bytes (:2471-2487) / decoded_args (:2781-2800):
/// 30-digit integers above `u64::MAX` plus the reference/anyOf/array shapes that carry them.
fn big_integer_case() -> (String, Value) { ... }
returning the constant and the schema, and have both tests call it, keeping each test's own compiler/tokenizer/pipeline setup. ~44 lines removed, no coverage lost.
S2 — tests/server/test_inkling2.py:121-123 (new test re-resolves what the fixture already resolved at :29-38):
def test_strict_tml_tool_calls_and_truncation(service):
url = os.environ["FLARE_INKLING2_TEST_URL"].rstrip("/")
model_id = json.load(urllib.request.urlopen(url + "/v1/models", timeout=10))["data"][0]["id"]
and tests/server/test_inkling2.py:155-169 (one of four near-identical POST blocks; the others are :176-189 and :194-207):
trunc_req = urllib.request.Request(
url + "/v1/chat/completions",
json.dumps(dict(
model=model_id,
messages=[dict(role="user", content=prompt)],
tools=chat_tools,
tool_choice="auto",
reasoning_effort="none",
max_tokens=10,
seed=1234,
)).encode(),
{"Content-Type": "application/json"},
)
with urllib.request.urlopen(trunc_req, timeout=120) as resp:
trunc = json.load(resp)
Concrete replacement: expose url/model from the fixture (it already hangs ask.chunk = chunk off the closure at :67) and add one module-level helper, e.g.
def post(url, path, body):
request = urllib.request.Request(url + path, json.dumps(body).encode(), {"Content-Type": "application/json"})
with urllib.request.urlopen(request, timeout=120) as response:
return json.load(response)
collapsing the four blocks to trunc = post(url, "/v1/chat/completions", dict(...)) etc. ~54 lines → ~20. Precedent for a service object: tests/server/test_muse_spark.py:55-66 (.open/.request). Caveat to state: the truncation cases cannot call the fixture's ask because it asserts finish_reason in ("stop", "tool_calls") (test_inkling2.py:63).
S3 — tests/server/test_inkling2.py:139-141:
assert big in call["function"]["arguments"]
parsed = json.loads(call["function"]["arguments"])
assert list(parsed.keys()) == ["big_id", "city"] and parsed["city"] == "Paris"
Replace with assert parsed["city"] == "Paris": the key-order clause cannot distinguish old from new behaviour (preserve_order is already enabled at helios/Cargo.toml:52, so the old args.to_string() preserved order too); only the big assertions exercise the fix, matching Rust :620-642.
LEAN — helios/src/output/tml.rs:342-360 in full (the whole change; quote in report to show it removes branches):
fn call(&mut self, body: &str) -> Option<Vec<Event>> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct RawCall<'a> {
name: String,
#[serde(borrow)]
args: &'a RawValue,
}
let parsed: RawCall<'_> = serde_json::from_str(body).ok()?;
let args = parsed.args.get().trim();
if !args.starts_with('{')
|| !self
Do-NOT-delete argument (verbatim proof it is load-bearing), helios/src/output/tml.rs:566-570 existing test:
for body in [
r#"{"name":"other","args":{}}"#,
r#"{"name":"lookup","args":[]}"#,
r#"{"name":"lookup","args":{},"extra":1}"#,
r#"{"name":7,"args":{}}"#,
args:[] must stay rejected-as-visible, which is exactly what !args.starts_with('{') preserves for non-strict TMLv0 where no grammar constrains the body. Existing raw-token idiom the PR follows: helios/src/output/tagged.rs:871 pub(super) struct RawArguments(Vec<(String, Box<serde_json::value::RawValue>)>); and :927 serde_json::from_str::<Box<serde_json::value::RawValue>>(raw.trim()).ok(). New tml.rs test :620-642 reuses the existing run(...) harness (:446-468) — nothing to subtract.
#2 [low] Optional: new live test is parametrized twice by module fixture
tests/server/test_inkling2.py:29 @pytest.fixture(scope="module", params=[None, "none"], ids=["default-effort", "zero-effort"]) parametrizes every test in the module twice. The new test_strict_tml_tool_calls_and_truncation (:121) therefore runs twice, ~10 live HTTP requests per run (5 per run: buffered, streamed, chat-truncation, responses buffered, responses truncation), each up to a 120 s timeout. Only the first two calls depend on the fixture's reasoning_effort param (:43-44); the three truncation/Responses calls pass reasoning_effort="none" / reasoning=dict(effort="none") explicitly (:162, :183, :200), so they are byte-identical between the two runs. The strict-TML behaviour under test (raw 30-digit args, truncation cleanup) does not vary with default reasoning effort, so the second pass adds live qualification time without covering a new contract. Optional simplification: give the new test its own non-parametrized fixture (or accept the duplicate) and document that in the PR's evidence, since the dossier already flags that live runs are never exercised in CI. Low priority; not a defect.