@@ -187,6 +187,58 @@ if ! echo "$OUTPUT" | grep -qE 'v?[0-9]+\.[0-9]+|dev'; then
187187fi
188188echo " OK"
189189
190+ echo " "
191+ echo " === Phase 1b: allocator override matches this platform's contract ==="
192+ # Asserts the SHIPPED binary's actual allocator wiring, per platform:
193+ #
194+ # Windows, Linux -> ordinary malloc MUST reach mimalloc (all size classes
195+ # owned). If it does not, every purge/reclaim option in
196+ # cbm_mem_init is decoration and freed pages stay committed
197+ # — that is #581, which hid in production for months
198+ # precisely because nothing asserted it on a real artifact.
199+ # macOS -> it MUST NOT. Enabling the override there aborts on the
200+ # first pointer crossing the two-level-namespace boundary
201+ # ("mi_free: invalid pointer"), so "owned" here would mean
202+ # we shipped a binary that crashes on index.
203+ #
204+ # Both directions fail. A silent flip either way is a release blocker, which is
205+ # why this lives in smoke (real artifact, all platforms) and not only in a unit
206+ # test built from source.
207+ ALLOC_LOG=$( " $BINARY " cli list_projects 2>&1 > /dev/null || true)
208+ case " $( uname -s) " in
209+ Darwin)
210+ if echo " $ALLOC_LOG " | grep -q ' mem.allocator.not_owned' ; then
211+ echo " FAIL: macOS emitted the not_owned WARNING; expected the by-design"
212+ echo " bound-populations INFO line (see #1360)"
213+ exit 1
214+ fi
215+ if echo " $ALLOC_LOG " | grep -q ' mem.allocator.owned' ; then
216+ echo " FAIL: macOS reports ordinary malloc as allocator-owned. The override"
217+ echo " must stay OFF here: under the two-level namespace it aborts"
218+ echo " with 'mi_free: invalid pointer' on the first crossing pointer."
219+ exit 1
220+ fi
221+ echo " OK: macOS serves ordinary malloc from the system allocator, no warning"
222+ ;;
223+ MINGW* |MSYS* |CYGWIN* |Linux)
224+ if echo " $ALLOC_LOG " | grep -q ' mem.allocator.not_owned' ; then
225+ echo " FAIL: ordinary malloc does NOT reach mimalloc on $( uname -s) ."
226+ echo " Allocator tuning is inert and freed pages will stay committed (#581/#1360)."
227+ echo " $ALLOC_LOG " | grep ' mem.allocator' | head -2
228+ exit 1
229+ fi
230+ if echo " $ALLOC_LOG " | grep -q ' mem.allocator.bound_populations_only' ; then
231+ echo " FAIL: $( uname -s) reports bound-populations-only; the global override"
232+ echo " is expected to be compiled in on this platform (#1360)."
233+ exit 1
234+ fi
235+ echo " OK: ordinary malloc reaches the allocator on $( uname -s) "
236+ ;;
237+ * )
238+ echo " SKIP: no allocator contract defined for $( uname -s) "
239+ ;;
240+ esac
241+
190242if [ " $SMOKE_MODE " != " --agent-config-only" ]; then
191243echo " "
192244echo " === Phase 2: index test project ==="
@@ -338,6 +390,64 @@ if [ "$TOTAL" -lt 1 ]; then
338390 echo " FAIL: search_graph for 'compute' returned 0 results"
339391 exit 1
340392fi
393+
394+ echo " "
395+ echo " === Phase 3z: no tool duplicates its payload into structuredContent (#1375) ==="
396+ # Asserts on the SHIPPED artifact what the unit suite asserts from source: a
397+ # non-JSON payload must travel ONCE. It used to appear twice — content[0].text
398+ # plus an identical structuredContent.text — costing 2.05x the bytes on a large
399+ # query_graph, i.e. half the 10 MiB transport budget and double the tokens billed
400+ # to every LLM caller.
401+ #
402+ # In smoke as well as the unit suite because this is a WIRE-FORMAT property: it
403+ # is what a real client actually receives from the real binary, and a from-source
404+ # test cannot prove the released artifact behaves the same way.
405+ DUP_TOOLS=0
406+ DUP_CHECKED=0
407+ for TOOL_ARGS in " search_graph --project $PROJECT --name-pattern compute" \
408+ " search_code --project $PROJECT --query compute" \
409+ " get_architecture --project $PROJECT " \
410+ " index_status --project $PROJECT " ; do
411+ # shellcheck disable=SC2086
412+ ENVELOPE=$( " $BINARY " cli $TOOL_ARGS --json 2> /dev/null || true)
413+ [ -z " $ENVELOPE " ] && continue
414+ VERDICT=$( printf ' %s' " $ENVELOPE " | python3 -c '
415+ import json,sys
416+ try:
417+ d = json.loads(sys.stdin.read())
418+ except Exception:
419+ print("skip"); raise SystemExit
420+ if d.get("isError"):
421+ print("skip"); raise SystemExit
422+ content = d.get("content") or []
423+ text = content[0].get("text", "") if content else ""
424+ sc = d.get("structuredContent")
425+ if not isinstance(sc, dict):
426+ print("no-structured"); raise SystemExit
427+ try:
428+ payload_is_object = isinstance(json.loads(text), dict)
429+ except Exception:
430+ payload_is_object = False
431+ if payload_is_object:
432+ print("skip"); raise SystemExit
433+ print("dup" if sc.get("text") == text and text else "ok")
434+ ' )
435+ case " $VERDICT " in
436+ dup) echo " FAIL: $( echo " $TOOL_ARGS " | cut -d" " -f1) repeats its payload in structuredContent (#1375)" ; DUP_TOOLS=$(( DUP_TOOLS+ 1 )) ;;
437+ ok) DUP_CHECKED=$(( DUP_CHECKED+ 1 )) ;;
438+ no-structured) echo " FAIL: $( echo " $TOOL_ARGS " | cut -d" " -f1) has no structuredContent object (outputSchema requires one)" ; DUP_TOOLS=$(( DUP_TOOLS+ 1 )) ;;
439+ esac
440+ done
441+ if [ " $DUP_TOOLS " -ne 0 ]; then
442+ echo " FAIL: $DUP_TOOLS tool(s) duplicate their payload on the shipped binary"
443+ exit 1
444+ fi
445+ if [ " $DUP_CHECKED " -eq 0 ]; then
446+ echo " FAIL: no tool produced a non-JSON payload — this check proved nothing"
447+ exit 1
448+ fi
449+ echo " OK: $DUP_CHECKED tool(s) deliver their payload exactly once"
450+
341451echo " OK: search_graph found $TOTAL result(s) for 'compute'"
342452
343453# 3b: trace_path — verify compute has callers
0 commit comments