diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d5158f..85c0e48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Protocol case A15 as a corpus fixture (plan cut R0b): `approval/17-provider-fails-after-approval` (approved effect fails at the provider after the approval was spent; reported, request terminal, second continuation refused). Mock `execute_raises` on T1/T2; on T4 a real write into a missing directory, rejected by the AIEN write provider. Corpus 106 rows, gate I 60 cases, T4 subset 32; T3 unchanged at 43. - Trust run tooling (plan cut R1a): both conformance runners write `.inputs.json` (full input ledger) next to `.results.json` under `--dump`, byte-identical across Rust and Python (the Rust results dump now nulls `duration_ms` like Python). `bench/tools/trust_run.py` runs every offline leg of PROTOCOL-0.3 (T1, T2, both negative-control matrices, validator, TRUST-DIGEST, T3, T4) and computes gates P, X, I, E, A, N from the raw files. The dev run found a spec-versus-protocol conflict: results the pipeline synthesizes after a raising or foreign-result `execute` carried null `content_kind` and `trust` (CORE.md said so), which gate P2 counts as missing. Both pipelines now label them `tool_result` + `unknown`, the schema reading of a null label, so behaviour is unchanged. - Streamed responses (plan 19.7 item 6, streaming half): Lenshift dialect `openai_stream` in Rust and Python takes a streamed `/v1/chat/completions` body (Server-Sent Events) exactly as sent, assembles the fragments into one assistant message and parses it with the `openai` rules (`spec/LENSHIFT.md`). A stream without `finish_reason` `stop`, `tool_calls` or `function_call` rejects every call as "truncated tool call"; malformed streams (conflicting id or name, second choice, fragment without index, data after `[DONE]`, non-JSON chunk) are rejected whole. 23 dialect fixtures, six of them the real Ollama, llama.cpp and SGLang stream captures byte for byte. Both dialect fixture runners now also compare every digest a fixture records. +- Lenshift `openai` cross-language fix: Rust accepted an already-decoded `arguments` object and reported a non-string value as "arguments is not an object"; it now rejects every non-string `arguments` as "arguments is not valid JSON", as Python and `spec/LENSHIFT.md` do. Only Ollama's own `/api/chat` sends decoded objects (capture `05e`); all 29 OpenAI-compatible captured calls send strings. Fixtures `openai/arguments_decoded_object` and `openai/arguments_not_string` fail on the old Rust code. ## Unreleased (0.2, CrossAxis lane) diff --git a/README.md b/README.md index 05271fa..419dd1d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ and execution. INTERPLANE only standardizes what crosses between them and makes | **Crossveil** | the authority-boundary contract: two runtime callbacks, a lifecycle with fail-closed invariants, trust classes | see `STATUS.md` | | **CrossAxis** | explicit, versioned capability mapping; a deterministic domain selector with a before/after receipt | minimal in 0.1 | | **Interplane Probe** | measured capability qualification of an OpenAI-compatible endpoint | see `STATUS.md` | -| **Conformance** | 106 conformance cases plus 54 dialect fixtures; Rust and Python runners must agree byte for byte | see `STATUS.md` | +| **Conformance** | 106 conformance cases plus 56 dialect fixtures; Rust and Python runners must agree byte for byte | see `STATUS.md` | | Vectorveil | the envelope and canonical JSON; no transport framework | envelope only | | RelayLine | the event vocabulary for multi-round exchanges | contract only | diff --git a/STATUS.md b/STATUS.md index f532bdd..fc10f5f 100644 --- a/STATUS.md +++ b/STATUS.md @@ -8,7 +8,7 @@ byte-identical) ยท `qualified` (measured against a real model/backend). |---|---|---|---|---| | Core schemas | specified | specified | validated | 10 schemas under spec/schemas, JSON Schema 2020-12 | | Core types + validation + JCS | conformant | conformant | 27 cases + digest/jcs-01 | verdict files byte-identical | -| Lenshift openai | conformant | conformant | 8 dialect fixtures | | +| Lenshift openai | conformant | conformant | 10 dialect fixtures | | | Lenshift openai_stream | conformant | conformant | 23 dialect fixtures (6 real streams from Ollama, llama.cpp, SGLang) | SSE body assembled into one message; incomplete streams rejected, never guessed; digests compared across languages | | Lenshift qwen35 | conformant, qualified | conformant, qualified | 10 dialect fixtures + real captures | real Qwen3.5-9B captures under qualification/captures | | Lenshift aien_legacy | tested | tested | 13 dialect fixtures, JCS-identical | aien-cli textual `` JSON (client.rs:381-419); unterminated calls rejected | diff --git a/conformance/runners/validate_fixtures.py b/conformance/runners/validate_fixtures.py index 07c46ca..d594098 100644 --- a/conformance/runners/validate_fixtures.py +++ b/conformance/runners/validate_fixtures.py @@ -345,7 +345,8 @@ for p in sorted(glob.glob(os.path.join(ROOT, "dialects", "fixtures", "*", "*.jso if it["provenance"].get("source_digest") is not None: fail("%s: source_digest must be null" % where) if V_INTENT.is_valid({**e["intents"][0], "kind": "result"}) if e.get("intents") else False: fail("negative control: wrong kind validated") -req = {"openai": {"single","multiple","arguments_not_json","arguments_not_object","missing_name","reasoning_content_present","plain_answer","legacy_function_call"}, +req = {"openai": {"single","multiple","arguments_not_json","arguments_not_object","missing_name","reasoning_content_present","plain_answer","legacy_function_call","arguments_decoded_object","arguments_not_string"}, + "openai_stream": {"assembled-arguments-not-json","capture-llamacpp-no-reasoning","capture-llamacpp-reasoning","capture-ollama-no-reasoning","capture-ollama-reasoning","capture-sglang-no-reasoning","capture-sglang-reasoning","crlf-comments-no-space","cut-after-complete-arguments","cut-mid-arguments","error-chunk-not-json","error-conflicting-name","error-event-after-done","error-fragment-without-index","error-input-not-text","error-second-choice","finish-length","fragmented-call","plain-text-cut","plain-text-stop","sglang-null-repeats","two-calls-interleaved","unterminated-last-event"}, "qwen35": {"valid_single_call","multiple_calls","malformed_unclosed_function","reasoning_plus_call","plain_answer","unknown_tool_name","partial_truncated_call","multiline_parameter","json_typed_parameter","hermes_json"}, "aien_legacy": {"valid_single_call","multiple_calls","reasoning_plus_call","repaired_bracket","repaired_missing_braces","trailing_comma_rejected","single_quotes_rejected","unterminated_rejected","fenced_json_fallback","placeholder_name_rejected","missing_arguments","arguments_not_object","plain_answer"}} for dia, names in req.items(): diff --git a/dialects/fixtures/openai/arguments_decoded_object.json b/dialects/fixtures/openai/arguments_decoded_object.json new file mode 100644 index 0000000..c372dc8 --- /dev/null +++ b/dialects/fixtures/openai/arguments_decoded_object.json @@ -0,0 +1,43 @@ +{ + "dialect": "openai", + "name": "arguments_decoded_object", + "description": "arguments as an already-decoded object (Ollama /api/chat form) is not the OpenAI-compatible string form.", + "input": { + "role": "assistant", + "content": null, + "tool_calls": [ + { + "id": "call_o", + "type": "function", + "function": { + "name": "read_file", + "arguments": { + "path": "README.md" + } + } + } + ] + }, + "model": "mock-model", + "trace_id": "trace-dialect", + "turn": 0, + "parser_version": "1.0.0", + "reasoning_present": false, + "expected": { + "text": "", + "intents": [], + "rejected": [ + { + "index": 0, + "code": "malformed_tool_call", + "message": "arguments is not valid JSON" + } + ], + "partial": false, + "dialect_version": "1" + }, + "expected_digests": { + "reasoning_digest": null, + "source_digests": [] + } +} diff --git a/dialects/fixtures/openai/arguments_not_string.json b/dialects/fixtures/openai/arguments_not_string.json new file mode 100644 index 0000000..f19aaf8 --- /dev/null +++ b/dialects/fixtures/openai/arguments_not_string.json @@ -0,0 +1,41 @@ +{ + "dialect": "openai", + "name": "arguments_not_string", + "description": "arguments as a JSON number is not a string.", + "input": { + "role": "assistant", + "content": null, + "tool_calls": [ + { + "id": "call_o", + "type": "function", + "function": { + "name": "read_file", + "arguments": 7 + } + } + ] + }, + "model": "mock-model", + "trace_id": "trace-dialect", + "turn": 0, + "parser_version": "1.0.0", + "reasoning_present": false, + "expected": { + "text": "", + "intents": [], + "rejected": [ + { + "index": 0, + "code": "malformed_tool_call", + "message": "arguments is not valid JSON" + } + ], + "partial": false, + "dialect_version": "1" + }, + "expected_digests": { + "reasoning_digest": null, + "source_digests": [] + } +} diff --git a/rust/crates/interplane-lenshift/src/openai.rs b/rust/crates/interplane-lenshift/src/openai.rs index 7ad91fe..2a2e280 100644 --- a/rust/crates/interplane-lenshift/src/openai.rs +++ b/rust/crates/interplane-lenshift/src/openai.rs @@ -99,16 +99,12 @@ impl Dialect for OpenAi { continue; } }, - // Some servers hand back an already-decoded object; accept it. - Some(Value::Object(m)) => m.clone(), - Some(Value::Null) | None => { + // `arguments` must be a JSON string (spec/LENSHIFT.md). An already-decoded object is + // what Ollama's own /api/chat sends, not an OpenAI-compatible endpoint. + _ => { reject(&mut turn, "arguments is not valid JSON"); continue; } - Some(_) => { - reject(&mut turn, "arguments is not an object"); - continue; - } }; turn.intents.push(make_intent( "openai", diff --git a/rust/crates/interplane-lenshift/tests/dialect_fixtures.rs b/rust/crates/interplane-lenshift/tests/dialect_fixtures.rs index 0bd6667..a3f162c 100644 --- a/rust/crates/interplane-lenshift/tests/dialect_fixtures.rs +++ b/rust/crates/interplane-lenshift/tests/dialect_fixtures.rs @@ -102,5 +102,5 @@ fn dialect_fixtures_match() { n += 1; } } - assert!(n >= 54, "expected the 54 dialect fixtures, ran {n}"); + assert!(n >= 56, "expected the 56 dialect fixtures, ran {n}"); } diff --git a/spec/LENSHIFT.md b/spec/LENSHIFT.md index 7d3fe90..e2b907b 100644 --- a/spec/LENSHIFT.md +++ b/spec/LENSHIFT.md @@ -37,8 +37,10 @@ by an OpenAI-compatible `/v1/chat/completions` (non-streamed, or streamed and as caller; dialect `openai_stream` below assembles a stream). - `tool_calls[i].function.name` -> raw_name; `tool_calls[i].id` -> source_call_id. -- `function.arguments` is a JSON string: parse; must be an object. Not JSON -> `malformed_tool_call` - "arguments is not valid JSON". JSON but not an object -> `malformed_tool_call` "arguments is not an object". +- `function.arguments` is a JSON string: parse; must be an object. Not JSON, absent, or not a string + (an already-decoded object, as Ollama's own `/api/chat` sends, is not the OpenAI-compatible form) + -> `malformed_tool_call` "arguments is not valid JSON". JSON but not an object -> + `malformed_tool_call` "arguments is not an object". - Missing or empty name -> `malformed_tool_call`. - `content` -> text (null -> ""). `reasoning_content` / `reasoning` -> reasoning_digest. - Legacy `function_call` (single) is accepted as one call with no id. @@ -217,7 +219,8 @@ Required qwen35 fixtures: valid single call; multiple calls; malformed (unclosed reasoning plus call; plain answer with no tool; unknown tool name (parses fine); partial/truncated call; multi-line parameter value; JSON-typed parameter; hermes_json form. Required aien_legacy fixtures: valid single call; multiple calls; reasoning plus call; repaired bracket; repaired missing braces; trailing comma (rejected); single quotes (rejected); unterminated (rejected, partial); fenced json fallback; placeholder name (rejected); missing arguments; arguments not object; plain answer. Required openai fixtures: single; multiple; arguments not JSON; arguments not object; missing name; reasoning_content present; -plain answer; legacy function_call. +plain answer; legacy function_call; arguments as a decoded object (rejected); arguments not a string +(rejected). Fixture provenance: inputs are constructed from the official template grammar, not captured from a live model, until the qualification run under `qualification/` captures real outputs and pins them.