Skip to content

evaluate_budgets ​

Reference for the evaluate_budgets tool of the SparkForensics MCP server.

Evaluate a run against pass/fail thresholds: the MCP equivalent of the CLI's --max-runtime/--max-spill/etc. budget flags, thin-wrapped over the same evaluateBudgets() the sparkforensics-analyze CLI uses.

Parameters (all optional):

  • source / runId: identify the run to evaluate (see Common parameters). When runIdB/sourceB is also given, this run is the regression baseline instead.
  • maxRuntimeMs, maxSpillGb, maxSkewRatio, maxFailedTaskRatePct, minEfficiencyPct: absolute budgets, each evaluated only if provided. Each is a non-negative number; a negative value fails schema validation. With two runs they apply to the candidate (runIdB/sourceB), the same as the CLI's --baseline mode. minEfficiencyPct measures busy core time, the share of executor core time that ran tasks (100 minus the dashboard's Unused core time), not the dashboard's Efficiency tile. maxFailedTaskRatePct measures failed task attempts over all task attempts, retried attempts and earlier stage attempts included, so a failure a retry recovered still counts. A run with no task data is inconclusive.
  • runIdB / sourceB: a candidate run to compare against the first, so regression budgets can be evaluated. Same runId/source shape, resolved the same way. Omit both to skip regression budgets.
  • maxRegressionPct, regressionMetric: fail if regressionMetric (default wallClock; see Regression metric keys for the full list) regressed by more than maxRegressionPct% between the first run (baseline) and the second run (candidate). Requires runIdB/sourceB. regressionMetric without maxRegressionPct fails the call. A volume key (inputBytes, outputBytes, taskCount, executorsAdded), which has no regression direction, reports inconclusive. A key that is not a regression metric key fails schema validation.
  • regressionBudgets: further regression budgets, an array of { "metric": "<key>", "maxPct": <number> }, the MCP form of the CLI's repeated --regression-budget <metric>:<pct>. Each is checked like maxRegressionPct and reports its own max-regression result. A metric can be budgeted once across this list and the maxRegressionPct/regressionMetric pair (which counts as one budget); a repeat fails the call. Requires runIdB/sourceB, as maxRegressionPct does.
  • stageRegressionBudgets: per paired stage budgets, an array of { "metric": "<key>", "maxPct": <number> }, the MCP form of the CLI's repeated --stage-regression-budget <metric>:<pct>. metric is one of executorRunTime, executorCpuTime, memoryBytesSpilled, diskBytesSpilled, shuffleReadBytes and shuffleWriteBytes. The budget fails when any paired stage's metric grew by more than maxPct% against its baseline stage; growth from a zero baseline always exceeds it. The detail names the worst pairs by pairId (the same id compare_runs returns in stagePairs). Each metric gets its own max-stage-regression result, and a metric can be budgeted once. Requires runIdB/sourceB. It reports inconclusive when no stage pair is eligible or the metric is missing on every eligible pair. inputBytes and outputBytes are workload volume with no regression direction, so the call fails if either is named.
  • stageQualities: the pair qualities stageRegressionBudgets read, from exact, structural and aligned (default exact and structural). An aligned pair was matched on similarity or position and may compare different work, so it is left out unless named. Requires stageRegressionBudgets. Stages a re-plan left over are not paired and are not read.
  • failOnIntroduced: fail if the second run introduces any finding in the given impact band ("all" or one of the impact band names). Requires runIdB/sourceB. A finding the first run also has, with the same type, rule and location, is not introduced, even when its impact band differs, unless its band worsens to exactly the given band: that counts as introduced (never under "all", and an improvement never does). A band name it doesn't recognize fails schema validation.

A budget whose required evidence is missing (e.g. no runIdB/sourceB for a regression budget, or a run with no trustworthy task-level evidence) reports inconclusive, not a false pass. The tool has no redact input: the budgets read figures and impact bands, never the stage text redaction rewrites, so a redacted comparison gives the same results. Independent of which budgets you pass, an evaluated run with no ApplicationEnd event adds a run-complete result with status inconclusive, the same check that makes the CLI exit 3. A run whose parser skipped malformed or invalid log lines adds a parse-incomplete result with status inconclusive the same way, since its totals cover only the lines that parsed. With two runs, run-complete applies to the candidate, and parse-incomplete checks both runs: its detail names the run that lost lines and how many (for example baseline 6 lines).

Each result's name is one of max-runtime, max-spill, max-skew, max-failed-task-rate, min-efficiency, max-regression, max-stage-regression, fail-on-introduced, run-complete and parse-incomplete. A max-regression or max-stage-regression result also carries metric, the key it checked. candidateRunId is the run the budgets were evaluated on, and baselineRunId is present with two runs.

Example call:

json
{
  "name": "evaluate_budgets",
  "arguments": {
    "source": { "path": "baseline.zstd" },
    "sourceB": { "path": "candidate.zstd" },
    "maxRegressionPct": 10,
    "failOnIntroduced": "critical"
  }
}

The response names the runs it covers: candidateRunId is the run the budgets were evaluated on, and baselineRunId is present with two runs.

Example response:

json
{
  "baselineRunId": "aaaa1111-...",
  "candidateRunId": "bbbb2222-...",
  "results": [
    {
      "name": "max-regression",
      "metric": "wallClock",
      "status": "violation",
      "detail": "Metric \"wallClock\" regressed 100.0%, exceeding budget 10%."
    },
    {
      "name": "fail-on-introduced",
      "status": "pass",
      "detail": "No introduced findings match \"critical\"."
    }
  ],
  "violated": true,
  "inconclusive": false
}