Appearance
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). WhenrunIdB/sourceBis 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--baselinemode.minEfficiencyPctmeasures 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.maxFailedTaskRatePctmeasures 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. SamerunId/sourceshape, resolved the same way. Omit both to skip regression budgets.maxRegressionPct,regressionMetric: fail ifregressionMetric(defaultwallClock; see Regression metric keys for the full list) regressed by more thanmaxRegressionPct% between the first run (baseline) and the second run (candidate). RequiresrunIdB/sourceB.regressionMetricwithoutmaxRegressionPctfails the call. A volume key (inputBytes,outputBytes,taskCount,executorsAdded), which has no regression direction, reportsinconclusive. 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 likemaxRegressionPctand reports its ownmax-regressionresult. A metric can be budgeted once across this list and themaxRegressionPct/regressionMetricpair (which counts as one budget); a repeat fails the call. RequiresrunIdB/sourceB, asmaxRegressionPctdoes.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>.metricis one ofexecutorRunTime,executorCpuTime,memoryBytesSpilled,diskBytesSpilled,shuffleReadBytesandshuffleWriteBytes. The budget fails when any paired stage's metric grew by more thanmaxPct% against its baseline stage; growth from a zero baseline always exceeds it. The detail names the worst pairs bypairId(the same idcompare_runsreturns instagePairs). Each metric gets its ownmax-stage-regressionresult, and a metric can be budgeted once. RequiresrunIdB/sourceB. It reportsinconclusivewhen no stage pair is eligible or the metric is missing on every eligible pair.inputBytesandoutputBytesare workload volume with no regression direction, so the call fails if either is named.stageQualities: the pair qualitiesstageRegressionBudgetsread, fromexact,structuralandaligned(defaultexactandstructural). Analignedpair was matched on similarity or position and may compare different work, so it is left out unless named. RequiresstageRegressionBudgets. 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). RequiresrunIdB/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
}