All documents

ModelValidatorApp

spicegrinder-icon

© 2026 Obsvra. This document describes SpiceGrinder and is provided to help you evaluate and use it. It is not a license to reproduce, adapt, or use this material to build a competing product or service. Full terms: the SpiceGrinder EULA.

NAME

ModelValidatorApp — check whether one or more SpiceGrinder model files are valid

SYNOPSIS

java -cp spicegrinder.jar com.obsvra.spicegrinder.tools.ModelValidatorApp model.xml|model.json ...

On a jpackage install:

validate model.xml|model.json ...

DESCRIPTION

ModelValidatorApp loads one or more model files and reports every validate() failure found in each, plus file-level parse/load failures. It answers “is this model valid” (loadable, and every node’s own validate() passes) — a distinct question from ModelAnalyzerApp, which answers “how expensive is this already-valid model.”

Multiple files may be given on one invocation; each is checked independently and a full report is printed for each. One of them may be - instead of a path, meaning “read this model from stdin” (used once per invocation, not repeated). Content is sniffed as XML or JSON, matching Grind; Compact (.sgm) format needs a real file, since it has no content signature to sniff. Relative <Import>/<FlatFile> paths inside a piped model resolve as if the model were saved in the current working directory, or in the folder given with --model-dir DIR.

Available at any tier — validating a model file isn’t itself a licensed capability. A Free build attempting to load a model that references a Pro-only component still reports that as a load failure here, the same as any other file that fails to load.

Checks reported, per file:

  • File-level failures: malformed XML/JSON, unresolved <input> references, missing required attributes, a license-gated component referenced on a build that doesn’t have it — anything that prevents the model from loading at all.

  • Node-level failures: every node’s own validate() is checked, and all failures are collected in one pass, not just the first one found — e.g. a Mix whose inputs don’t all share one dimension, a Truncate with neither min nor max set.

  • A smoke run: when the checks above all pass, the model is run from its root for a bounded number of rows (1,000 by default, and no longer than about 3 seconds of wall-clock time), from the model’s own seed (a fixed seed of 1 for a model with none, so the same model gives the same report each time), and the rows are discarded. A run-time error is reported as a failure of its own kind, smoke run: row N: <message>, with the node type SmokeRun: for example a choose(class - 1, ...) in a ProcessFlow serviceScale whose class comes from a Categorical with one more category than the list, which no validate() can see and which would stop a real run at row 60. A model that ends itself during the smoke run (a ProcessFlow until or closes, a finite source) has not failed: the report says it ended after N rows. A smoke test can catch run-time errors, not prove there are none: it checks only the rows it generated, so an error that needs more rows, a rarer draw or a different seed gets past it.

    The validator has no side effects, so the smoke run is skipped, and the report says so (smoke run skipped: <node> calls a remote service (network) for every row), for a model that has a node that writes outside the process or reads something that may be missing or slow while generating. Today that is ServiceCall, found also inside an Imported library. A file or table read once while the model loads (FlatFile, Database, a word list) is not a reason to skip: that happened before the validator started. A single row that never returns is not stopped by the time limit, which is checked between rows.

OPTIONS

OptionMeaning
-h, --helpPrint usage and exit.
--versionPrint the version (e.g. 1.0.0 (Build 1)) and exit.
--smoke-rows NRows of the smoke run (default 1,000). The 3 second limit still applies.
--no-smokeStructural checks only: no smoke run, as before it existed.
--jsonEmit one JSON report to stdout instead of human-readable text. See OUTPUT (JSON) below.
--analyzeWith --json (required): add each model’s static analysis to its result as analysis, from the same process. See OUTPUT (JSON) below.
--local-root DIRUse DIR as the model’s local root for this run, ahead of project.root, a .spicegrinder-root marker and the Git work-tree top. A relative data file (a FlatFile file, an Email wordListFile) not beside the model is looked for there before the working directory, and a relative <Import> after the model’s folder; each must stay inside the folder it was found in. The desktop app passes its Local root setting this way. See FlatFile and the Model File Format Reference.
--model-dir DIRWith - (stdin): resolve the model’s relative paths (<Import> files and data files) as if it were saved in DIR. The desktop app passes an edited model’s own folder this way.

No other options exist.

The human-readable report has a smoke: line after nodes: (for example smoke: smoke run: 1000 rows generated without an error (a smoke test can catch run-time errors, not prove there are none)); the result: line and the failure lines keep their form, and a smoke failure is one more line under INVALID.

OUTPUT (JSON)

With --json, every file given is checked exactly the same way, but the results are collected into one JSON document printed to stdout instead of per-file human-readable text:

{
  "valid": true,
  "results": [
    {
      "model": "/abs/path/model.xml",
      "loaded": true,
      "loadError": null,
      "rootName": "root",
      "nodeCount": 12,
      "valid": true,
      "failures": []
    }
  ]
}

results[] has exactly one entry per file given, in order, regardless of whether that file loaded. loaded is false for a file that doesn’t exist or failed to parse/load, in which case loadError carries the reason and rootName/nodeCount are null; failures is always present as an array (empty when there’s nothing to report, never omitted). Each failures[] entry is {"nodeName": ..., "nodeType": ..., "message": ...} — one per node-level validate() failure. Each entry of results[] for a loaded file also has smoke: {"status": ..., "rows": N, "note": ...}, where status is passed, ended, failed, skipped, not run (the structural checks failed first) or off (--no-smoke). A smoke failure is also one of the failures[], with nodeName the root node, nodeType SmokeRun and a message that starts smoke run: row N: . Top-level valid is true iff every result’s own valid is true — the same condition exit code 0 checks.

With --analyze, every entry of results[] also has analysis: exactly the results[0] entry that analyze --json --no-write --no-throughput prints for that model (its complexity and rootName, throughput: null, written: false), or {"model": ..., "error": ...} when the model does not load. It is the analyzer’s own report, made in this process, so a caller that wants both reports starts one JVM instead of two (the desktop app does this when a model is opened or saved). It does not change valid, failures or the exit code.

--json only changes this payload. -h/--help/--version output and bad-argument errors (exit code 2) always stay plain text, unaffected by --json.

EXIT STATUS

CodeMeaning
0Every file given loaded and validated clean.
1At least one file failed to load, or had one or more validation failures.
2Bad arguments — unrecognized option, or no files given.

Suited to a check-in/CI validation step: validate, then analyze, before allowing a model file change to merge.

EXAMPLES

Validate a single model:

java -cp spicegrinder.jar com.obsvra.spicegrinder.tools.ModelValidatorApp model.xml

Validate every model in a directory as one CI step (shell glob expansion):

validate models/*.xml

Get a machine-readable report for a script or agent to parse:

validate --json models/*.xml

SEE ALSO

ModelAnalyzerApp(1), Grind(1), ComponentLibraryApp(1), McpServerApp(1)