Appearance
Evidence report and finding identity
The portable evidence report and the stable identity every finding carries.
Portable evidence report
packages/core/src/evidence-report.ts's buildEvidenceReport(appModel, { redact }) returns { markdown, json }: a self-contained, byte-stable document that runs the detectors over an appModel and serializes the result for sharing outside the tool. Raw task records are never included; identifier redaction (app id + host names → app-1/host-1 pseudonyms via packages/core/src/redact.ts, with the app name and spark.app.name replaced by the app id's pseudonym) is opt-in with { redact: true }. The JSON is pinned by EVIDENCE_SCHEMA_VERSION (packages/core/src/evidence-report.ts, surfaced as json.schemaVersion) and has this fixed top-level key order:
text
schemaVersion, summary, verdict, evidenceAvailability, detectors, findings, writeTargets, recommendations, cleanChecks, notRunCheckssummaryis the run header:{ app: { id, name, sparkVersion }, stageCount, jobCount, sqlExecutionCount, skippedLines, findingCount, impactBandCounts, actionableFindingCount, actionableImpactBandCounts, clean, outcome, runShape }.findingCountcounts every row infindings; theactionable*counts leave out evidence caveats, theincompleteRunrow and info findings (actionableImpactBandCounts.infois always 0), so they count the critical and warning findings to act on.cleanisisCleanRunfrompackages/core/src/check-coverage.ts, andoutcomeis{ failedJobs, totalJobs, failureReason, failureReasonStageId }fromsummarizeRunOutcome(packages/core/src/run-outcome.ts), the job results the dashboard verdict leads with; the Markdown prints it as an- Outcome:header line.runShape(computeRunShape,packages/core/src/run-shape.ts) is the Scorecard's wall-clock, Efficiency and Unused core time with theircritical/warningflags, the ETL phases' summed stage time and Core Locality's peak busy cores, eachnullwhere the dashboard shows none; MCPget_run_summaryreturns it too.verdictis the dashboard's run verdict frombuildRunVerdict(packages/core/src/run-verdict.ts):{ title, summary, steps, costSteps, idle, remainingPlaces, copyText }.stepsholds the first three places to look in the verdict card's order, each{ key, stageId, type, tag, leadFindingId, actionLabel, recommendation, impact, impactMeaning, relatedTypes, text }, wheretextis that step's line of the "Copy next steps" checklist andcopyTextis the whole checklist.stepsrank by cluster time, then wall-clock savings, asrecommendationsdo: the stage task time (impactEstimate.stageTaskMs), or for the app-levelutilizationfinding its idle core time (impactEstimate.idleCoreTimeMs), both in core time.costStepsis a second lane ranked by busy core time (impactEstimate.coreTimeMs.high), each{ stageId, type, tag, leadFindingId, actionLabel, coreTimeMs, coreTime }: a finding with no core-time figure (an idle capacity, assumed-constant or bytes-only figure) is in neither lane.idleis the run's allocated core time that ran no task,{ coreHours, allocatedCoreHours, pct, text }, ornullwithout an allocation; no single finding's idle figure exceeds it. The Markdown opens with it as## Verdict, the two lanes labeled "By cluster time (task-hours)" and "By core time". Therecommendationsrollup stays alongside: it ranks fix types, the verdict ranks places.evidenceAvailabilityis the ledger above (ornullwhen absent).detectorsisdetectorCatalog()output: one{ type, version, scope, thresholds, docAnchor }per detector, inDETECTORSorder, so the exact threshold set that produced each finding travels with the evidence. On a tuned run (see the tuned-run paragraph below) a tuned row'sthresholdsare the ones the run used, plustunedThresholds.findingsare deterministically sorted rows (impact band → type → stage → id), each with anid(a hash of the finding, so it matches within one run), akey(findingKeyer()inpackages/core/src/run-comparison.ts: type, rule and location, where a stage is itsstageIdentityfingerprint, the key ofmetrics.stages, and an SQL execution is a digest of its stages' fingerprints, so it matches across reruns of one job),tag, core columns, an always-presentactionLabel, and anevidencesub-object holding that finding type's declared evidence fields (see the per-type evidence paragraph below);confidence/validationRequired/docAnchorappear only when the detector emitted them.writeTargetsisextractWriteTargetsoutput (packages/core/src/write-targets.ts): every SQL write command with its path or table. The field contract is in the user guide's Write targets.recommendationsis the impact-rankedbuildRecommendationRollupoutput (packages/core/src/recommendation-rollup.ts), andcleanCheckslists every detector type that fired zero findings this run and could run: see the rollup and clean-checks paragraph below.notRunCheckslists the zero-finding types the log lacked the data to run, each with areason: see the not-run checks paragraph below.
Determinism holds because detector order, finding sort, and object key order are all fixed, so a given appModel serializes identically across calls.
Redaction enumerates hosts two ways: by walking the findings tree for every string value under a key literally named host (evidence.host, evidence.failedTaskDetails[].host, evidence.retriedTaskDetails[].host, and any nested host field, all covered without enumerating paths), and by scanning every string value for EC2-style hostnames, bare IPv4 tokens and the host of any URL authority (scheme://[userinfo@]host[:port]). The run-tree redaction (HTML export, run blocks) also reads each stage's hostStats[].host and every config value that is a list of host:port entries. So identifiers that surface only in free text (recommendation copy, a stageFailed failure reason in valueText) are pseudonymized too. Pseudonym numbering uses a numeric-aware sort, so re-redacting an already-redacted report is a no-op even past host-10: a token that is already a pseudonym is never numbered again. Replacement is one pass per string over a single alternation of the collected identifiers, longest first, so its cost does not grow with the number of hosts times the number of strings. A host from a host field, and a URL or host:port host shaped as an FQDN or IP, is replaced only as a whole token: a short host such as master leaves metadata and masters alone. A single-word URL host, such as a bucket named data in s3a://data/logs, and a single-word host from a config host:port value, such as shuffle in shuffle:18080, are replaced only in URL authority or host:port position. The same word in prose or in a finding field such as type or impactBand stays as written. A nested-scheme URL such as k8s://https://host:6443 yields the inner host, never the inner scheme.
User names have no list to look up, so scrubUserNames in redact.ts replaces them where they are recognizable (URL credentials, the segment after /user/, /home/ or /Users/, user= values) with the fixed redacted-user. A fixed value keeps the scrub idempotent and never replaces a common word elsewhere in the text. The user guide's What --redact covers lists the gaps.
Failed-task error text is dropped rather than pseudonymized, since a message or stack trace can carry file paths and data values that no host pattern matches: every array under a key named failureGroups or retryFailureGroups (a stage record's retried-attempt failures) has its message replaced and the message text stripped from its stackExcerpt (redactTaskFailureGroup in task-failure.ts). That covers the evidence report and both the findings and the stage records of the HTML export. A stage's failure reason is replaced outright with [redacted] wherever it appears: a stageFailed finding's valueText, a stage record's stageFailureReason, a job's exception and the report's failureReason (redactStageFailureReasons in redact.ts). An executor's removal reason (executors.removed[].reason in the HTML export's run model) is also replaced with [redacted], by field and not through the failure-reason keys (withoutExecutorRemovalReasons in redact.ts). No surface displays it.
Text a log controls reaches the Markdown through mdInline (markdown-inline.ts): the app name, Spark version, failure messages, finding recommendations and metric text, verdict lines, evidence values and the comparison section's labels and property keys. It prints the text on one line and escapes \, [, ], <, >, | and a leading block marker, so no log text adds a heading, a link or an HTML tag to a report pasted into a pull request. Backticks and parentheses stay as written, since the report's own prose uses code spans, and the [redacted] placeholder is kept. A new line in the renderer that prints log-derived text goes through mdInline.
The Markdown rendering mirrors the JSON's field set: each finding block prints its detector version, its sorted evidence entries (byte-magnitude keys humanized), and the report ends with a ## Detectors catalog carrying the version + threshold set. A finding's impactEstimate prints as its own - impact: line worded as the dashboard's "Potential savings": the wall-clock range, or the raw waste only when there is no range, followed by what it counts ("of run time", "of unused executor memory", "of task time (modeled)") and estimateMethod, and nothing for an informational or zero estimate. A - estimate: line carries the Advanced view's provenance sentence (estimateProvenance). Both come from packages/core/src/impact-format.ts, the formatters every dashboard surface uses, so memory reads in GB-h from 0.1 GB-h up, core time in core-s or core-h, and a time figure has no "Estimated" prefix. JSON finding rows carry the same figure as impact/impactMeaning when there is one, plus the provenance sentence as estimateProvenance (with the model's assumptions), and each recommendations row an impactMeaning next to its impact, which is null for a resource figure that rounds to zero. EvidenceExport names downloads evidence-<appId>[-redacted].<md|json|html>, taking the app id from the (already pseudonymized when redacting) report so a redacted file never leaks the real id and is never name-identical to a raw export.
A finding row carries impactEstimate when the finding has one, with the full contract documented in Impact estimation (basis, wallClock, estimateMethod, rawWaste, coreTimeMs, stageTaskMs, and on utilization idleCoreTimeMs). It appears after the pinned core columns (id, key, type, impactBand, stageId, metric, value, recommendation, detectorVersion, plus optional but pinned confidence, validationRequired, docAnchor) without displacing any of them. The full row shape is FindingRowColumns in evidence-report.ts, which also carries name, tag, valueText, remediation, actionLabel, impact/impactMeaning, estimateProvenance and, on a tuned run, tunedThresholds.
The report carries the same recommendation data the dashboard's "Fix These First" view shows, so the CLI (packages/cli/bin/sparkforensics-analyze.mjs) and the MCP tool (diagnoseRun in packages/core/src/mcp-tools.ts) get it too, not just the web markdown/JSON download. FindingRow.actionLabel is always present (a short imperative label like "Reduce shuffle size"), from findingActionLabel (packages/core/src/finding-action-label.ts), which reads the type's actionLabel in its folder's presentation.ts and falls back to the type's name. The dashboard, the run verdict and the report rows all call it. EvidenceReportJson.recommendations is the same impact-ranked buildRecommendationRollup grouping (packages/core/src/recommendation-rollup.ts) that FixTheseFirst.tsx renders, so CLI/MCP/download consumers get the same "what's the highest-impact fix" ranking the dashboard shows, without changing the findings array's own impact-band-sorted order at all. EvidenceReportJson.cleanChecks lists every detector type that fired zero findings this run, each with getThresholdSummary's one-line "what would have tripped it" sentence; unlike the dashboard's Alerts.tsx clean-checks table, it deliberately includes the one "always-mounted" reference type (coreLocality) even when it has no findings, since a flat evidence report has no separate always-visible surface for it to already appear on the way that widget does on the board.
A check the log could not run is not listed as clean. packages/core/src/check-coverage.ts holds the one rule, shared with the dashboard's verdict, top bar and Clean checks: a type whose only finding is an evidence caveat, every scope: 'stage' type on a log where no stage recorded an end, and the run-span types (RUN_SPAN_CHECK_TYPES) on a log with no ApplicationEnd. Those types are listed in notRunChecks instead of cleanChecks, each { type, tag, thresholdSummary, reason }, where reason is the caveat's own recommendation (it names the setting to turn on) or the log-wide sentence. The Markdown has a ## Not checked on this log section above ## Clean checks, and a Findings to act on header line. Its ## Findings section lists the slowHost rows of one host (or, for a per-executor row, one executor) as one entry with a line per stage (groupSlowHosts); the JSON rows stay one per stage.
Finding is a union discriminated on type, one member per emitted finding type (packages/core/src/finding-types.ts, assembled from the detector folders), and a finding row's evidence is an explicit per-type projection. Each type's <Type>Evidence interface names its public fields, and the folder's evidenceKeys (assembled into EVIDENCE_KEYS in finding-meta.ts) lists the same keys, checked both ways at compile time, so a field a detector adds only for another core module does not become report contract. Rows leave out these fields: stageShape's totalCores; utilization's utilizationFraction, appDurationMs, totalCores and allocatedCoreMs; memoryUtilization's idleRateFraction, allocatedMBSeconds, allocatedMB, peakExecutors, appDurationMs and allocatedBytes; retryWaste's extended display copy. The impact estimator reads them on the finding. value is always numeric or null: the text-valued findings (stageFailed's failure reason, configAudit's current setting, incompleteRun's missing) carry their text in a valueText column, present only on those rows, and the Markdown prints it where value would go. Renaming or removing an evidence field is a breaking change and needs a schema bump. cleanChecks/notRunChecks list emitted finding types, the set the dashboard's Clean checks shows: overBroadcast and underBroadcast in place of the broadcastSizing detector entry. A finding row's actionLabel for a (type, discriminant) combination with no label of its own is the type's name, the same fallback the verdict step uses.
buildEvidenceReport(appModel, { thresholds }) runs the detectors with a user's validated overrides (the CLI's and MCP server's --thresholds; see Tuning thresholds). Only a tuned run adds keys: tunedThresholds ({ <name>: { value, default } }) on each finding row and each cleanChecks/notRunChecks entry from a detector an override moved off its defaults (or whose suppressedBy or threshold-source detector it moved), on that detector's detectors row, and as summary.tunedThresholds keyed by detector type. The Markdown adds a - Tuned thresholds: header line, a - tuned thresholds: line per affected finding, and marks tuned catalog rows and clean checks. A default run's report carries none of these keys, and every one is optional. The report caches key on the overrides object as well as the appModel, so one model's default and tuned reports never mix. Finding ids ignore thresholds: a finding a tuned run still emits keeps the id it has in a default run.
Finding identity
Every finding analyzer.ts emits carries a stable id (push()'s findingId() choke point, FNV-1a hash over type | location | metric | value | discriminators) and a detectorVersion (from the emitting DETECTORS entry). The two are deliberately decoupled: id is derived only from a finding's evidence tuple, never from detectorVersion, so a threshold or logic tweak that bumps a detector's version does not change the id of findings it still emits at the same location/metric. A saved reference (dashboard bookmark, exported report row) keeps pointing at the same logical finding across detector revisions; detectorVersion is separate provenance metadata for "which ruleset produced this," not part of identity. See packages/core/test/analyzer-finding-identity.test.js for the decoupling proof.
The discriminators are declared per finding type (ID_DISCRIMINATORS in finding-meta.ts, from each folder's idDiscriminators, each key checked against that type's fields) and joined in the fixed DISCRIMINATOR_SLOTS order. The APPENDED_SLOTS follow, only for the types that list them, so a new one leaves every other id unchanged (joinKeyCast lists planNodeIds). The value slot takes value, else valueText.
id stability holds for equivalent reruns of the same schema/analyzer version on the same input. Changing the id-derivation rule itself (the hash algorithm, or which fields feed the location key/discriminators) is an intentional breaking change and must bump EVIDENCE_SCHEMA_VERSION (packages/core/src/evidence-report.ts); there is no separate id-scheme version.