# uip maestro case case-exit-conditions, stage-entry-conditions, stage-exit-conditions

> Syntax and options for the `get` verbs of the case-level and stage-level condition groups in a local case management JSON file — case-exit-conditions, stage-entry-conditions, and stage-exit-conditions — plus the JSON field reference for hand-editing each.

Three command groups manage the rule-based conditions that gate transitions inside a local case management definition file: `case-exit-conditions` (when can the whole case complete or close), `stage-entry-conditions` (when can a stage start), and `stage-exit-conditions` (when can a stage finish or hand off). All three share an identical `get` shape and read the same case management JSON document; see [`uip maestro case`](./uip-maestro-case.md) for the file format and the rest of the subsystem. For the task-level equivalent, see [`task-entry-conditions`](./uip-maestro-case-task-entry-conditions.md).

Conditions are edited by hand in `caseplan.json` — each group's JSON field reference is below its `get` verb.

## Concepts

- **A condition is a named container for one or more rule groups.** `rules` is an array of arrays — each inner array is one OR-branch, and every rule inside an inner array is ANDed together. In practice, every worked example in source has exactly one rule per condition, but the shape supports multiple.
- **The completion/exit rule-type split.** On `case-exit-conditions` and `stage-exit-conditions`, which `rule-type` value is valid depends on whether the condition marks its parent complete: `marksCaseComplete`/`marksStageComplete: true` uses the *completion* rule-type set; `false` (or absent) uses the *exit* set.
- **`stage-entry-conditions` has a single rule-type enum**, no completion/exit split.

## uip maestro case case-exit-conditions

Read exit/completion conditions on the whole case (file-scoped, no stage argument).

### Synopsis

```text
uip maestro case case-exit-conditions get <file> <condition-id>
```

### uip maestro case case-exit-conditions get

#### Arguments

| Name | Required | Purpose |
|---|---|---|
| `<file>` | yes | Path to the case management JSON file. |
| `<condition-id>` | yes | ID of the case exit condition to retrieve. |

#### Example

```bash
uip maestro case case-exit-conditions get case.json Condition_a1b2c3d4
```

#### Data shape (--output json)

```json
{
  "Code": "CaseExitConditionFound",
  "Data": {
    "Condition": {
      "id": "Condition_a1b2c3d4",
      "displayName": "Completed",
      "marksCaseComplete": true,
      "rules": [[{ "id": "Rule_e5f6a7b8", "type": "required-stages-completed" }]]
    }
  }
}
```

`Condition` is the raw node object as stored on disk — use this shape as a reference when hand-editing `caseplan.json`.

### Case-exit-condition JSON fields

Field reference for hand-editing a condition into `caseplan.json`:

| Field | Value | Notes |
|---|---|---|
| `displayName` | string | Display name for the condition. |
| `marksCaseComplete` | `true` \| `false` | Switches which `rule-type` set is valid (see Concepts). |
| rule `type` | **Completion set** (`marksCaseComplete: true`): `required-stages-completed`, `wait-for-connector`. **Exit set** (`false`/absent): `selected-stage-completed`, `selected-stage-exited`, `wait-for-connector`. | Goes inside a `rules[][]` entry. |
| condition expression | string | Free-form expression on a rule, when the rule type supports one. |
| `selectedStageId` | string | Stage ID for `selected-stage-*` rules. |

After editing, run [`uip maestro case validate`](./uip-maestro-case.md#uip-maestro-case-validate).

## uip maestro case stage-entry-conditions

Read entry conditions on one stage (file + stage-scoped).

### Synopsis

```text
uip maestro case stage-entry-conditions get <file> <stage-id> <condition-id>
```

### uip maestro case stage-entry-conditions get

#### Arguments

| Name | Required | Purpose |
|---|---|---|
| `<file>` | yes | Path to the case management JSON file. |
| `<stage-id>` | yes | ID of the stage node. |
| `<condition-id>` | yes | ID of the entry condition to retrieve. |

#### Example

```bash
uip maestro case stage-entry-conditions get case.json Stage_1 Condition_a1b2c3d4
```

#### Data shape (--output json)

```json
{
  "Code": "StageEntryConditionFound",
  "Data": {
    "Condition": {
      "id": "Condition_a1b2c3d4",
      "displayName": "Start",
      "rules": [[{ "id": "Rule_e5f6a7b8", "type": "current-stage-entered" }]]
    }
  }
}
```

### Stage-entry-condition JSON fields

Field reference for hand-editing:

| Field | Value | Notes |
|---|---|---|
| `displayName` | string | Display name for the condition. |
| `isInterrupting` | `true` \| `false` | Whether the condition is interrupting. |
| rule `type` | one of `case-entered`, `selected-stage-exited`, `selected-stage-completed`, `wait-for-connector`, `user-selected-stage` | Single enum, no completion/exit split. |
| condition expression | string | Free-form expression on a rule, when supported. |
| `selectedStageId` | string | Stage ID for `selected-stage-*` rules. |

After editing, run [`uip maestro case validate`](./uip-maestro-case.md#uip-maestro-case-validate).

## uip maestro case stage-exit-conditions

Read exit/completion conditions on one stage (file + stage-scoped). The richest of the three groups — it also controls where execution goes on exit.

### Synopsis

```text
uip maestro case stage-exit-conditions get <file> <stage-id> <condition-id>
```

### uip maestro case stage-exit-conditions get

#### Arguments

| Name | Required | Purpose |
|---|---|---|
| `<file>` | yes | Path to the case management JSON file. |
| `<stage-id>` | yes | ID of the stage node. |
| `<condition-id>` | yes | ID of the exit condition to retrieve. |

#### Example

```bash
uip maestro case stage-exit-conditions get case.json Stage_1 Condition_a1b2c3d4
```

#### Data shape (--output json)

```json
{
  "Code": "ExitConditionFound",
  "Data": {
    "Condition": {
      "id": "Condition_a1b2c3d4",
      "displayName": "Done",
      "marksStageComplete": true,
      "rules": [[{ "id": "Rule_e5f6a7b8", "type": "required-tasks-completed" }]]
    }
  }
}
```

### Stage-exit-condition JSON fields

Field reference for hand-editing:

| Field | Value | Notes |
|---|---|---|
| `displayName` | string | Display name for the condition. |
| `type` | `exit-only` \| `wait-for-user` \| `return-to-origin` | What happens on exit. |
| `exitToStageId` | string | Stage to transition to on exit (paired with `return-to-origin`). |
| `marksStageComplete` | `true` \| `false` | Switches which `rule-type` set is valid (see Concepts). |
| rule `type` | **Completion set** (`marksStageComplete: true`): `required-tasks-completed`, `wait-for-connector`. **Exit set** (`false`/absent): `selected-tasks-completed`, `wait-for-connector`. | Goes inside a `rules[][]` entry. |
| condition expression | string | Free-form expression on a rule, when supported. |
| `selectedTasksIds` | array of strings | Task IDs for a `selected-tasks-completed` rule. |

After editing, run [`uip maestro case validate`](./uip-maestro-case.md#uip-maestro-case-validate).

## Related

- [uip maestro case](./uip-maestro-case.md) — subsystem overview and the case management JSON file format.
- [uip maestro case cases and stages](./uip-maestro-case-cases-stages.md) — the stage nodes these conditions attach to.
- [uip maestro case tasks](./uip-maestro-case-tasks.md) — tasks these conditions ultimately gate.
- [uip maestro case task-entry-conditions](./uip-maestro-case-task-entry-conditions.md) — the task-level equivalent.

## See also

- [Maestro tool overview](./uip-maestro-bpmn.md)
- [Global options](./global-options.md)
- [Exit codes](./exit-codes.md)
