# @x12i/graphenix-case-format

> Deterministic case condition DSL: validation, evaluation, and case selection.

Latest version **2.17.0** (published 2026-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @x12i/graphenix-case-format
pnpm add @x12i/graphenix-case-format
yarn add @x12i/graphenix-case-format
bun add @x12i/graphenix-case-format
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.17.0 |
| Published | 2026-07-10 |
| First published | 2026-06-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 38.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | x12i |
| Keywords | graph, graphenix, case, deterministic |

## Links

- npm: https://www.npmjs.com/package/@x12i/graphenix-case-format
- Repository: https://github.com/x12i/graphenix-format
- Homepage: https://github.com/x12i/graphenix-format/tree/master/packages/case-format#readme
- Issues: https://github.com/x12i/graphenix-format/issues
- npm.io page: https://npm.io/package/@x12i/graphenix-case-format

## Dependencies (1)

- [@x12i/graphenix-executable-contracts](https://npm.io/package/@x12i/graphenix-executable-contracts.md) ^2.17.0

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 2.17.0 (latest) — 2026-07-10
- 2.16.0 — 2026-06-29
- 2.15.0 — 2026-06-29
- 2.14.0 — 2026-06-28
- 2.12.5 — 2026-06-28
- 2.12.4 — 2026-06-28
- 2.12.3 — 2026-06-27
- 2.12.2 — 2026-06-27
- 2.11.0 — 2026-06-24
- 2.10.0 — 2026-06-24
- 2.9.0 — 2026-06-23
- 2.8.1 — 2026-06-21
- 2.8.0 — 2026-06-21
- 2.7.3 — 2026-06-20
- 2.7.2 — 2026-06-20
- … 8 more at https://npm.io/package/@x12i/graphenix-case-format/versions

## README

# @x12i/graphenix-case-format

**Deterministic case condition DSL** for executable graphs: validate conditions, evaluate them against pre-run context, and select graph/node model cases.

Case evaluation is pure, deterministic, bounded, and non-AI. Forbidden selectors (`ai.*`, `node.output.*`, `semanticMatch`, etc.) are rejected at validation time.

**Canonical vocabulary:** [GLOSSARY.md](../../GLOSSARY.md) §4 — phase model profiles (`preActionModel`, `skillModel`, `postActionModel`).  
**Design brief:** [GRAPH-FORMAT-FINALIZATION.md](../../docs/GRAPH-FORMAT-FINALIZATION.md) · **Compile brief:** [COMPILE-FORMAT-FINALIZATION.md](../../docs/COMPILE-FORMAT-FINALIZATION.md).

Cases are selected at **compile time** only — the engine uses frozen `modelSlots` on the plan.

---

## Who should use this

| Role | Use this package? |
| ---- | ----------------- |
| Graph designer / Studio (case editor) | **Yes** |
| Compiler service | Usually via `@x12i/graphenix-plan-compiler` |
| Engine at runtime | **No** — cases are resolved at compile time |

---

## Content pipeline example (graph-level cases)

From `createContentPipelineReferenceGraph()` / `contentPipelineModelConfig()`:

```json
"cases": [
  {
    "id": "default",
    "modelConfig": {
      "preActionModel": { "kind": "profileChoice", "key": "cheap/default" },
      "skillModel": { "kind": "profileChoice", "key": "vol/default" },
      "postActionModel": { "kind": "profileChoice", "key": "cheap/default" }
    }
  },
  {
    "id": "rush",
    "when": { "path": "runtime.input.priority", "op": "eq", "value": "rush" },
    "modelConfig": {
      "preActionModel": { "kind": "profileChoice", "key": "vol/default" },
      "skillModel": { "kind": "profileChoice", "key": "deep/openai_deep" },
      "postActionModel": { "kind": "profileChoice", "key": "vol/default" }
    }
  }
]
```

When `runtime.input.priority === "rush"` at compile time, the `rush` case is selected and frozen on the plan.

---

## Node-level override example

Partial override of MAIN-phase model profile only:

```json
"taskConfiguration": {
  "modelConfig": {
    "inherit": true,
    "cases": [{
      "id": "high-risk",
      "when": { "path": "runtime.input.riskLevel", "op": "eq", "value": "high" },
      "modelConfig": {
        "skillModel": { "kind": "profileChoice", "key": "deep/openai_deep" }
      }
    }]
  }
}
```

---

## Install

```bash
npm install @x12i/graphenix-case-format
```

---

## Example (API)

```ts
import {
  validateCaseCondition,
  evaluateCaseCondition,
  selectGraphModelCase,
  selectNodeModelCase
} from "@x12i/graphenix-case-format";
import type { DeterministicCaseContext } from "@x12i/graphenix-executable-contracts";

const context: DeterministicCaseContext = {
  runtime: { mode: "live", input: { priority: "rush" } },
  graph: { id: "graph:content-pipeline" }
};

validateCaseCondition({
  path: "runtime.input.priority",
  op: "eq",
  value: "rush"
});

const matched = evaluateCaseCondition(
  { path: "runtime.input.priority", op: "eq", value: "rush" },
  context
);

const graphCase = selectGraphModelCase(
  {
    version: "graph-model-config/v1",
    cases: [
      { id: "default", modelConfig: { skillModel: { kind: "profileChoice", key: "vol/default" } } },
      {
        id: "rush",
        when: { path: "runtime.input.priority", op: "eq", value: "rush" },
        modelConfig: { skillModel: { kind: "profileChoice", key: "deep/openai_deep" } }
      }
    ]
  },
  context
);
// → "rush" when priority is rush, else "default"
```

---

## Key exports

| API | Purpose |
| --- | ------- |
| `validateCaseCondition` | Structural + security validation of a condition |
| `evaluateCaseCondition` | Evaluate a condition against deterministic context |
| `explainMatchedCondition` | Human-readable match explanation |
| `selectGraphModelCase` | Pick graph-level model case |
| `selectNodeModelCase` | Pick node-level model case |
| `isAllowedCasePath` / `isForbiddenCasePath` | Path guardrails |

---

## Allowed path roots

```txt
runtime.mode, runtime.environment, runtime.job.*, runtime.input.*,
runtime.variables.*, runtime.flags.*, runtime.context.*,
graph.id, graph.revision
```

**Forbidden:** `ai.*`, `node.output.*`, `semanticMatch`, LLM-based selectors.

---

## Critical rule

```txt
Cases may choose stronger or weaker AI profiles.
AI may not choose the case.
```

---

## Dependencies

- `@x12i/graphenix-executable-contracts` ^1.0.0

---

## Related packages

| Package | Role |
| ------- | ---- |
| [`@x12i/graphenix-authoring-format`](../authoring-format) | Validates cases inside authoring graphs |
| [`@x12i/graphenix-plan-compiler`](../plan-compiler) | Selects cases when compiling plans |
| [`@x12i/graphenix-executable-profile-format`](../executable-profile-format) | Phase model profile slots on extension |

---
_Source: https://npm.io/package/@x12i/graphenix-case-format · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
