@barivia/barsom-mcp 0.20.3 → 0.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,6 +78,8 @@ export const TRAINING_INPUT_SCHEMA = {
78
78
  convergence: z.tuple([z.number(), z.number()]),
79
79
  })]).optional()),
80
80
  batch_size: z.number().int().optional(),
81
+ te_panel_size: z.number().int().optional()
82
+ .describe("Fixed evaluation-panel size for live topographic error during training (default clamp(grid_nodes*6, 500, 10000))"),
81
83
  quality_metrics: z.union([z.enum(["fast", "standard", "full"]), z.array(z.string())]).optional(),
82
84
  backend: z.enum(["auto", "cpu", "gpu", "gpu_graphs"]).optional().default("auto"),
83
85
  output_format: z.enum(["png", "pdf", "svg"]).optional().default("png"),
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { registerAppTool } from "@modelcontextprotocol/ext-apps/server";
3
3
  import { runMcpToolAudit } from "../audit.js";
4
4
  import { apiCall, getClientSupportsMcpApps, getVizPort, structuredTextResult, } from "../shared.js";
5
- import { lastEpochTeFromCurves, snapTeCurvesToMapTe } from "../training_monitor_curve.js";
5
+ import { lastEpochTeFromCurves } from "../training_monitor_curve.js";
6
6
  export const TRAINING_MONITOR_URI = "ui://barsom/training-monitor";
7
7
  export const TRAINING_MONITOR_REFRESH_MS = 5000;
8
8
  function hasCurveArrays(data) {
@@ -72,13 +72,13 @@ async function enrichWithTrainingLog(job_id, data) {
72
72
  if (status === "completed" || status === "failed" || status === "cancelled") {
73
73
  merged.topographic_error = mapTe;
74
74
  }
75
- return snapTeCurvesToMapTe(merged);
75
+ return merged;
76
76
  }
77
77
  catch {
78
78
  if (epochTe != null) {
79
- return snapTeCurvesToMapTe({ ...data, epoch_topographic_error: epochTe });
79
+ return { ...data, epoch_topographic_error: epochTe };
80
80
  }
81
- return data.kernel_complete === true ? snapTeCurvesToMapTe(data) : data;
81
+ return data;
82
82
  }
83
83
  }
84
84
  export function registerTrainingMonitorTool(server) {
@@ -16,25 +16,8 @@ export function isKernelTrainingComplete(data, status) {
16
16
  return true;
17
17
  return status === "completed";
18
18
  }
19
- /** Snap the last TE curve point to authoritative full-map TE when kernel training is done. */
20
- export function snapTeCurvesToMapTe(data) {
21
- const mapTe = data.map_topographic_error ??
22
- (data.kernel_complete === true ? data.topographic_error : null);
23
- if (mapTe == null || !Number.isFinite(Number(mapTe)))
24
- return data;
25
- const out = { ...data };
26
- for (const key of ["ordering_topographic_errors", "convergence_topographic_errors"]) {
27
- const arr = out[key];
28
- if (Array.isArray(arr) && arr.length > 0) {
29
- const copy = arr.slice();
30
- copy[copy.length - 1] = Number(mapTe);
31
- out[key] = copy;
32
- }
33
- }
34
- return out;
35
- }
36
- export function teCurveLabel(base, kernelComplete) {
37
- return kernelComplete ? `${base} (→ map TE)` : `${base} (sampled)`;
19
+ export function teCurveLabel(base, _kernelComplete = false) {
20
+ return `${base} (panel)`;
38
21
  }
39
22
  export function formatCurveSourceNote(data) {
40
23
  const src = data.training_curve_source_batches;
@@ -49,17 +32,20 @@ export function formatCurveSourceNote(data) {
49
32
  if (convTotal != null && convTotal > convShown) {
50
33
  parts.push(`${convShown} of ${convTotal.toLocaleString()} convergence batch samples`);
51
34
  }
52
- const mapTe = data.map_topographic_error;
53
- const epochTe = data.epoch_topographic_error;
54
- if (mapTe != null &&
55
- epochTe != null &&
56
- Number.isFinite(Number(mapTe)) &&
57
- Number.isFinite(Number(epochTe)) &&
58
- Math.abs(Number(epochTe) - Number(mapTe)) > 0.0005) {
59
- parts.push(`Live TE is a subsampled batch estimate during training; final point snaps to map TE ${Number(mapTe).toFixed(4)} (last sampled ${Number(epochTe).toFixed(4)})`);
35
+ const teEval = data.te_evaluation;
36
+ const panelM = teEval?.te_panel_size;
37
+ const panelN = teEval?.te_panel_n_train;
38
+ if (typeof panelM === "number" && typeof panelN === "number" && panelN > 0) {
39
+ const strat = teEval?.te_panel_stratified === true ? ", stratified by mesh" : "";
40
+ parts.push(`TE curve uses a fixed panel of ${panelM.toLocaleString()} of ${panelN.toLocaleString()} training rows${strat}`);
60
41
  }
61
- else if (mapTe != null && Number.isFinite(Number(mapTe))) {
62
- parts.push(`TE curve final point is full-map topographic error (${Number(mapTe).toFixed(4)}).`);
42
+ const panelTe = data.panel_topographic_error;
43
+ const mapTe = data.map_topographic_error;
44
+ if (panelTe != null &&
45
+ mapTe != null &&
46
+ Number.isFinite(Number(panelTe)) &&
47
+ Number.isFinite(Number(mapTe))) {
48
+ parts.push(`Panel TE ${Number(panelTe).toFixed(4)} · Map TE ${Number(mapTe).toFixed(4)} (full training set)`);
63
49
  }
64
50
  if (parts.length === 0)
65
51
  return null;
@@ -82,8 +68,7 @@ export function alignTeToQeAxis(te, qeLen) {
82
68
  return [...Array(pad).fill(null), ...te];
83
69
  }
84
70
  /**
85
- * Last sampled TE point from the (batch-aligned) live TE curve. This is the most
86
- * recent per-epoch TE estimate, distinct from the final trained-map TE in the summary.
71
+ * Last panel TE point from the (batch-aligned) live TE curve.
87
72
  */
88
73
  export function lastEpochTeFromCurves(data) {
89
74
  const conv = data.convergence_topographic_errors;