Skip to Content
Helm

Expert JDM Contract

Contract required by expert-managed JDM graphs.

Expert JDM mode lets you run a custom Gorules/ZenEngine decision graph while still using Helm's public input, output, validation, allocation, and audit contracts.

Use it when the generated graph from a custom definition is not enough and a team needs to manage the decision graph directly.

Expert JDM mode replaces the generated decision graph, not the public Helm contract. If your workflow needs different inputs, outputs, or result semantics, extend Helm at the package level instead.

How It Is Wired

The definition remains the source of truth for:

  • accepted question IDs and answer types,
  • profile IDs and labels,
  • allocation maps,
  • optional questions,
  • result validation,
  • audit metadata.

The JDM graph supplies the executable decision logic.

In code, pass both a definition and a loader:

import {
  createGraphLoader,
  RiskProfilerEngine,
} from "@zagvar/helm-core";

const engine = new RiskProfilerEngine({
  definition,
  loader: createGraphLoader({
    "risk-profiler": graph,
  }),
});

In the CLI, pass both files:

zagvar-helm evaluate --input applicant.json \
  --definition definition.json \
  --jdm-path risk-profiler.json \
  --output json

Graph Key

The default graph key is:

risk-profiler

Custom loaders must return the graph for that key unless the engine is configured with a different graphKey.

Input Fields

Public evaluation input uses camel-case definition question IDs:

{
  "answers": {
    "riskCapacity": 8,
    "needsEmergencyAccess": true
  }
}

Before execution, Helm validates those answers against the definition and maps question IDs to snake case for the JDM graph:

Definition question IDJDM input field
riskCapacityrisk_capacity
needsEmergencyAccessneeds_emergency_access
investmentHorizonYearsinvestment_horizon_years

Unknown answer keys are rejected before the graph runs.

Required Output Fields

The graph must return these fields:

Output fieldTypeNotes
profile_idstringMust match a profile ID declared in the definition.
raw_scorenumberNon-negative score before normalization.
normalized_scorenumberNumber from 0 to 100.

The graph may also return:

Output fieldTypeNotes
override_appliedbooleanDefaults to false when omitted.
override_idstringIncluded in the public result when present.

If profile_id does not match a declared profile, evaluation fails. Allocation is not supplied by the graph; Helm looks it up from the definition after the profile is resolved.

Score Fields

Generated graphs emit one score field per scored question:

Definition question IDJDM score field
riskCapacityrisk_capacity_score
investmentHorizonYearsinvestment_horizon_years_score

Expert graphs can emit these same fields. Helm populates the public scores object only when all expected score fields are present.

Checksum Behavior

Generated graphs receive a deterministic checksum at compile time. Custom JDM graphs are checksummed when the loader returns the graph.

You can pass an expected checksum:

const engine = new RiskProfilerEngine({
  definition,
  loader,
  graphChecksum: "sha256:...",
});

Evaluation fails if the loaded graph checksum does not match the expected checksum.

Validation Boundaries

engine.validate() and zagvar-helm validate ask ZenEngine to validate graph structure. To verify the Helm business contract, also run a sample evaluation with the same definition.

The contract check happens during evaluation:

  • answers are validated against the definition,
  • JDM output is checked for required fields,
  • profile_id is checked against declared profiles,
  • allocation is resolved from the definition,
  • the result is enriched with definition and checksum metadata.

Tested Guarantees

Current tests cover the core expert-JDM contract:

  • deterministic graph generation and checksums,
  • custom loader execution,
  • rejection when a graph returns an undeclared profile,
  • checksum mismatch rejection,
  • CLI loader behavior for --jdm-path.

The CLI command reference documents compile, validate, and --jdm-path; end-to-end CLI command tests can be added later if those workflows become a larger compatibility surface.

Last updated on

On this page