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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
const data = window.REPORT_DATA;

const groupDefinitions = [
  {
    id: "kimi-k2",
    label: "Kimi-K2.5 / K2.6",
    members: ["moonshotai/Kimi-K2.5", "moonshotai/Kimi-K2.6"],
    note: "Shared TypeScript-style tool declaration output across K2.5 and K2.6.",
  },
  {
    id: "minimax-m2",
    label: "MiniMax-M2.5 / M2.7",
    members: ["MiniMaxAI/MiniMax-M2.5", "MiniMaxAI/MiniMax-M2.7"],
    note: "Same XML/tag-style tool rendering; model-name boilerplate differs.",
  },
  {
    id: "qwen-3",
    label: "Qwen3.5 / Qwen3.6",
    members: ["Qwen/Qwen3.5-397B-A17B", "Qwen/Qwen3.6-35B-A3B"],
    note: "Shared XML/tag-style tool rendering in the sampled cases.",
  },
];

const modelByName = new Map(data.models.map((model) => [model.model, model]));
const groupedNames = new Set(groupDefinitions.flatMap((group) => group.members));
const modelGroups = [
  ...data.models
    .filter((model) => !groupedNames.has(model.model))
    .map((model) => ({
      id: model.model,
      label: shortModel(model.model),
      members: [model.model],
      note: "",
    })),
  ...groupDefinitions,
]
  .map((group) => ({
    ...group,
    models: group.members.map((name) => modelByName.get(name)).filter(Boolean),
  }))
  .filter((group) => group.models.length)
  .sort((a, b) => a.label.localeCompare(b.label));

const state = {
  page: location.hash === "#matrix" ? "matrix" : "overview",
  group: modelGroups[0]?.id,
  caseId: "minimal_string_required",
  examplePath: "",
  dialect: "all",
  view: "output",
};

const featuredCases = [
  "minimal_string_required",
  "nested_arrays_enums",
  "nullable_anyof_refs",
  "oneof_allof_constraints",
];

const caseLabels = {
  minimal_string_required: "Simple required string",
  nested_arrays_enums: "Nested arrays + enums",
  nullable_anyof_refs: "Refs + nullable anyOf",
  oneof_allof_constraints: "oneOf/allOf stress",
};

const featureNames = [
  "tool_name",
  "description",
  "parameters",
  "properties",
  "required",
  "array",
  "enum",
  "anyOf",
  "oneOf",
  "ref",
  "default",
  "additionalProperties",
];

function $(id) {
  return document.getElementById(id);
}

function label(value) {
  return String(value ?? "—").replaceAll("_", " ");
}

function shortModel(model) {
  return model.split("/").pop();
}

function family(model) {
  return model.split("/")[0] || model;
}

function selectedModel() {
  return selectedGroup().models[0] || data.models[0];
}

function selectedGroup() {
  return modelGroups.find((group) => group.id === state.group) || modelGroups[0];
}

function caseInfo(id) {
  return data.cases.find((item) => item.id === id) || data.cases[0];
}

function isGood(status) {
  return typeof status === "string" && (status.startsWith("present") || status.startsWith("transformed"));
}

function statusClass(status) {
  if (status === "not_applicable") return "na";
  return isGood(status) ? "good" : "warn";
}

function dialectLabel(dialect) {
  const labels = {
    typescript: "TypeScript-style declarations",
    xml: "XML/tag-style instructions",
    json: "JSON tool block",
    "custom-channel": "Custom channel syntax",
    "message-json": "Message functions JSON",
    builtin: "Builtin tool block",
    other: "Other",
  };
  return labels[dialect] || label(dialect);
}

function supportCoverage(model) {
  if (model.support_variant === "tools_argument") return `${model.standard_supported}/${model.case_count}`;
  if (model.support_variant === "message_functions_json") return `${model.message_supported}/${model.case_count}`;
  if (model.support_variant === "special_modes") return `${model.special_supported}/${model.special_total}`;
  if (model.support_variant?.startsWith("custom_")) return `${model.custom_supported}/${model.case_count}`;
  return `${Math.max(model.standard_supported, model.custom_supported, model.message_supported)}/${model.case_count}`;
}

function filteredModels() {
  return modelGroups.filter((group) => {
    return state.dialect === "all" || group.models.some((model) => model.dialect === state.dialect);
  });
}

function renderModelList() {
  $("model-list").innerHTML = filteredModels()
    .map((group) => {
      const model = group.models[0];
      return `
      <button class="model-card ${model.dialect} ${state.page === "matrix" && group.id === state.group ? "active" : ""}" type="button" data-group="${group.id}">
        <strong>${group.label}</strong>
        <span>${dialectLabel(model.dialect)}</span>
      </button>
    `;
    })
    .join("");
}

function chooseDefaultExample(model) {
  const current = model.cases[state.caseId]?.[model.support_variant]?.rendered_path;
  if (current) return current;
  for (const variant of Object.values(model.cases[state.caseId] || {})) {
    if (variant.rendered_path) return variant.rendered_path;
  }
  if (model.representative_paths?.length) return model.representative_paths[0];
  for (const variants of Object.values(model.cases)) {
    for (const variant of Object.values(variants)) {
      if (variant.rendered_path) return variant.rendered_path;
    }
  }
  return Object.keys(data.snippets)[0];
}

function availableExamples(model) {
  const paths = [];
  const variants = model.cases[state.caseId] || {};
  if (variants[model.support_variant]?.rendered_path) {
    paths.push(variants[model.support_variant].rendered_path);
  }
  for (const variant of Object.values(variants)) {
    if (variant.meaningful && variant.rendered_path) paths.push(variant.rendered_path);
  }
  return [...new Set(paths)];
}

function renderHeader(group) {
  const model = group.models[0];
  $("active-family").textContent = group.models.length > 1 ? family(model.model) : family(model.model);
  $("active-model").textContent = group.label;
  $("active-summary").textContent =
    `${dialectLabel(model.dialect)}. ${group.note || model.support_detail} This view shows one representative rendered prompt; evidence packets for each grouped model are kept below.`;
  $("active-summary").style.borderLeftColor = `var(--${model.dialect})`;
  $("active-dialect").textContent = dialectLabel(model.dialect);
  $("active-path").textContent = model.support_path;
  $("active-coverage").textContent = group.models.length > 1 ? `${supportCoverage(model)} each` : `${supportCoverage(model)} cases`;
}

function renderExamples(model) {
  const paths = availableExamples(model);
  if (!paths.length) {
    state.examplePath = "";
    $("rendered-output").innerHTML = unsupportedMessage(model);
    renderViewMode();
    return;
  }
  if (!paths.includes(state.examplePath)) state.examplePath = paths[0];
  renderOutput(model);
}

function renderCases(model) {
  $("case-tabs").innerHTML = featuredCases
    .filter((id) => model.cases[id])
    .map((id) => {
      const supported = hasMeaningfulOutput(model, id);
      const title = supported ? "Rendered output available" : "Input example only; no meaningful rendered output for this model/path";
      return `<button type="button" class="${id === state.caseId ? "active" : ""} ${supported ? "" : "unsupported"}" data-case="${id}" title="${title}">${caseLabels[id] || caseInfo(id).label}</button>`;
    })
    .join("");
  $("case-description").textContent = caseInfo(state.caseId).description;
  $("case-title").textContent = caseLabels[state.caseId] || caseInfo(state.caseId).label;
  renderInputSchema();
}

function hasMeaningfulOutput(model, caseId) {
  const variants = model.cases[caseId] || {};
  return Object.values(variants).some((variant) => variant.meaningful && variant.rendered_path);
}

function renderInputSchema() {
  const item = caseInfo(state.caseId);
  $("input-schema").innerHTML = highlightInputJson(JSON.stringify(item.schema.tools, null, 2));
}

function renderOutput(model) {
  if (!state.examplePath) {
    $("rendered-output").innerHTML = unsupportedMessage(model);
    return;
  }
  const text = data.snippets[state.examplePath] || "No rendered prompt available for this selection.";
  $("rendered-output").innerHTML = highlightRendered(text, caseInfo(state.caseId));
}

function unsupportedMessage(model) {
  const variant = model.cases[state.caseId]?.[model.support_variant];
  const reason = variant?.error ? ` Renderer error: ${escapeHtml(variant.error)}.` : "";
  return `<span class="empty-render">No meaningful model-visible output was produced for <strong>${escapeHtml(caseLabels[state.caseId] || caseInfo(state.caseId).label)}</strong> using ${escapeHtml(model.support_path)}.${reason} Use <strong>Tool Definition</strong> to inspect the JSON schema that failed this renderer.</span>`;
}

function renderViewMode() {
  const isOutput = state.view === "output";
  $("rendered-output").hidden = !isOutput;
  $("input-schema").hidden = isOutput;
  for (const button of document.querySelectorAll("[data-view]")) {
    const active = button.dataset.view === state.view;
    button.classList.toggle("active", active);
    button.setAttribute("aria-selected", String(active));
  }
}

function renderPage() {
  const isOverview = state.page === "overview";
  $("overview-panel").hidden = !isOverview;
  $("matrix-view").hidden = isOverview;
  $("overview-link").classList.toggle("active", isOverview);
  if (location.hash !== (isOverview ? "#overview" : "#matrix")) {
    history.replaceState(null, "", isOverview ? "#overview" : "#matrix");
  }
}

function highlightInputJson(text) {
  return escapeHtml(text).replace(
    /(&quot;(name|description|parameters|properties|required|type|enum|items|anyOf|oneOf|allOf|\$defs|\$ref|default|additionalProperties|minimum)&quot;)/g,
    '<span class="schema-token">$1</span>',
  );
}

function highlightRendered(text, item) {
  const boilerplatePattern = /knowledge cutoff|current date|general guidelines|multimodal|you are |system_prompt|reasoning mode|today date|user<|<\|user|accurately answer|be very attentive/i;
  return highlightRenderedTokens(text, item, boilerplatePattern);
}

function highlightRenderedTokens(text, item, boilerplatePattern) {
  let escaped = escapeHtml(text);
  for (const name of item.tool_names || []) {
    escaped = escaped.replaceAll(escapeHtml(name), `<span class="tool-token">${escapeHtml(name)}</span>`);
  }
  escaped = escaped.replace(
    /\b(parameters|properties|required|enum|anyOf|oneOf|allOf|additionalProperties|tool_call|AVAILABLE_TOOLS|namespace functions|DSML|tool_declare)\b/g,
    '<span class="schema-token-output">$1</span>',
  );
  escaped = escaped
    .split("\n")
    .map((line) => (boilerplatePattern.test(line) ? `<span class="boilerplate-token">${line}</span>` : line))
    .join("\n");
  return escaped;
}

function currentVariant(model) {
  const variants = model.cases[state.caseId] || {};
  return variants[model.support_variant] || Object.values(variants).find((variant) => variant.meaningful) || Object.values(variants)[0];
}

function renderFeatures(model) {
  const variant = currentVariant(model);
  if (!variant) {
    $("feature-list").innerHTML = `<p class="muted">No feature packet for this case.</p>`;
    return;
  }
  $("feature-list").innerHTML = featureNames
    .map((name) => {
      const status = variant.features?.[name] || "not_applicable";
      return `
        <div class="feature-row">
          <strong>${label(name)}</strong>
          <span class="status ${statusClass(status)}">${label(status)}</span>
        </div>
      `;
    })
    .join("");
}

function renderSpecialModes(model) {
  const modes = model.special_modes || [];
  const notes = model.highlighted_notes || [];
  if (!modes.length && !notes.length) {
    $("special-list").innerHTML = `<p class="muted">No special/builtin probes or highlighted special-tool notes in this evidence set.</p>`;
    return;
  }
  const modeHtml = modes
    .map((mode) => `
      <button class="special-row" type="button" data-path="${mode.rendered_path || ""}">
        <strong>${label(mode.probe_id)}</strong>
        <span class="status ${mode.meaningful && mode.counts_as_special_tool ? "good" : "warn"}">${label(mode.category || mode.style_family)} · ${mode.token_count ?? "—"} tokens</span>
        <small>${escapeHtml(mode.description || "")}</small>
      </button>
    `)
    .join("");
  const notesHtml = notes
    .map((note) => `
      <div class="special-row note-row">
        <strong>${escapeHtml(note.title)}</strong>
        <span class="status warn">${escapeHtml(note.category)}</span>
        <small>${escapeHtml(note.detail)}</small>
        ${note.evidence ? `<small class="evidence-path">${escapeHtml(note.evidence)}</small>` : ""}
      </div>
    `)
    .join("");
  $("special-list").innerHTML = modeHtml + notesHtml;
}

function stringifyEvidence(item) {
  if (item.snippet) return item.snippet;
  if (item.observation) return item.observation;
  if (item.artifact) return item.artifact;
  return JSON.stringify(item, null, 2);
}

function renderClaims(group) {
  const sections = group.models.map((model) => {
    const claims = model.findings_packet?.claims || [];
    if (!claims.length) {
      return `<section class="packet-group"><h4>${model.model}</h4><p class="muted">No findings JSON packet found for this model.</p></section>`;
    }
    return `
      <section class="packet-group">
        <h4>${model.model}</h4>
        ${claims
          .map((claim, index) => `
            <details class="claim" ${index === 0 ? "open" : ""}>
              <summary>
                <strong>${label(claim.evidence_class)} · ${claim.confidence || "confidence unknown"}</strong>
                <p>${escapeHtml(claim.claim)}</p>
              </summary>
              <div class="claim-body">
                ${(claim.evidence || []).map((item) => `<div class="evidence-item">${escapeHtml(stringifyEvidence(item))}</div>`).join("")}
              </div>
            </details>
          `)
          .join("")}
      </section>
    `;
  });
  $("claims").innerHTML = sections.join("");
}

function escapeHtml(text) {
  return String(text)
    .replaceAll("&", "&amp;")
    .replaceAll("<", "&lt;")
    .replaceAll(">", "&gt;")
    .replaceAll('"', "&quot;");
}

function renderAll() {
  const group = selectedGroup();
  const model = group.models[0];
  renderPage();
  renderModelList();
  renderHeader(group);
  renderExamples(model);
  renderCases(model);
  renderFeatures(model);
  renderSpecialModes(model);
  renderClaims(group);
  renderViewMode();
}

function bindEvents() {
  $("overview-link").addEventListener("click", () => {
    state.page = "overview";
    renderAll();
  });

  $("dialect-filter").addEventListener("click", (event) => {
    const button = event.target.closest("[data-dialect]");
    if (!button) return;
    state.dialect = button.dataset.dialect;
    for (const item of $("dialect-filter").querySelectorAll("[data-dialect]")) {
      item.classList.toggle("active", item.dataset.dialect === state.dialect);
    }
    const visible = filteredModels();
    if (visible.length && !visible.some((group) => group.id === state.group)) {
      state.group = visible[0].id;
      state.examplePath = chooseDefaultExample(visible[0].models[0]);
      renderAll();
      return;
    }
    renderModelList();
  });

  $("model-list").addEventListener("click", (event) => {
    const button = event.target.closest("[data-group]");
    if (!button) return;
    state.page = "matrix";
    state.group = button.dataset.group;
    const model = selectedModel();
    state.examplePath = chooseDefaultExample(model);
    renderAll();
  });

  $("case-tabs").addEventListener("click", (event) => {
    const button = event.target.closest("[data-case]");
    if (!button) return;
    state.caseId = button.dataset.case;
    const model = selectedModel();
    const path = model.cases[state.caseId]?.[model.support_variant]?.rendered_path;
    if (path) state.examplePath = path;
    renderAll();
  });

  document.querySelector(".view-tabs").addEventListener("click", (event) => {
    const button = event.target.closest("[data-view]");
    if (!button) return;
    state.view = button.dataset.view;
    renderViewMode();
  });

  $("special-list").addEventListener("click", (event) => {
    const button = event.target.closest("[data-path]");
    if (!button?.dataset.path) return;
    state.examplePath = button.dataset.path;
    renderOutput(selectedModel());
  });

  window.addEventListener("hashchange", () => {
    state.page = location.hash === "#matrix" ? "matrix" : "overview";
    renderAll();
  });
}

function renderMarkdownSummary() {
  const md = data.overview?.summary;
  if (!md) return;
  let titleRewritten = false;
  const lines = md.split("\n");
  const parts = [];
  let paragraph = [];
  let list = [];

  const inline = (text) =>
    escapeHtml(text)
      .replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
      .replace(/`([^`]+)`/g, "<code>$1</code>");

  const flushParagraph = () => {
    if (!paragraph.length) return;
    parts.push(`<p>${inline(paragraph.join(" "))}</p>`);
    paragraph = [];
  };

  const flushList = () => {
    if (!list.length) return;
    parts.push(`<ul>${list.map((item) => `<li>${inline(item)}</li>`).join("")}</ul>`);
    list = [];
  };

  const isTableDivider = (line) => /^\|\s*[-:| ]+\s*\|$/.test(line);
  const cells = (line) => line.split("|").slice(1, -1).map((cell) => inline(cell.trim()));

  for (let index = 0; index < lines.length; index += 1) {
    const line = lines[index].trim();
    if (!line) {
      flushParagraph();
      flushList();
      continue;
    }

    if (line.startsWith("|") && lines[index + 1] && isTableDivider(lines[index + 1].trim())) {
      flushParagraph();
      flushList();
      const headers = cells(line).map((cell) => `<th>${cell}</th>`).join("");
      index += 2;
      const rows = [];
      while (index < lines.length && lines[index].trim().startsWith("|")) {
        rows.push(`<tr>${cells(lines[index].trim()).map((cell) => `<td>${cell}</td>`).join("")}</tr>`);
        index += 1;
      }
      index -= 1;
      parts.push(`<div class="table-wrap"><table><thead><tr>${headers}</tr></thead><tbody>${rows.join("")}</tbody></table></div>`);
      continue;
    }

    const heading = line.match(/^(#{1,3})\s+(.+)$/);
    if (heading) {
      flushParagraph();
      flushList();
      const level = heading[1].length;
      let text = heading[2];
      if (level === 1 && !titleRewritten) {
        text = "Tool Schema Rendering Atlas - Summary";
        titleRewritten = true;
      }
      const tag = level === 1 ? "h2" : level === 2 ? "h3" : "h4";
      parts.push(`<${tag}>${inline(text)}</${tag}>`);
      continue;
    }

    const date = line.match(/^_(.+)_$/);
    if (date) {
      flushParagraph();
      flushList();
      parts.push(`<p class="summary-date">${inline(date[1])}</p>`);
      continue;
    }

    const bullet = line.match(/^-\s+(.+)$/);
    if (bullet) {
      flushParagraph();
      list.push(bullet[1]);
      continue;
    }

    flushList();
    paragraph.push(line);
  }

  flushParagraph();
  flushList();
  const html = parts.join("");
  $("exec-summary").innerHTML = `<p class="eyebrow">Executive summary</p>${html}`;
}

renderMarkdownSummary();
bindEvents();
renderAll();