# Concepts

> Programs, treatments, runs, runners, execution groups, secrets and tokens, defined.

Web page: https://docs.cadence.ci/en/how-it-works/concepts

The words used across the documentation and the console, and how they fit together. For the language itself, see the [Mélodium Language Book](https://doc.melodium.tech/book/en/); for every treatment, model and function available, the [Mélodium Reference](https://doc.melodium.tech/latest/en/).

## From a Program to Its Runs

1. **In your repository: Program.** Compo.toml and .mel files: what the pipeline does, step by step.
2. `melodium run`, **Where you launch it: Direct run.** The engine you start, on your laptop or in a CI job. It runs the program and dispatches its steps.
3. Dispatches each step, **In your cloud account: Distribution run: build, Distribution run: test.** One per dispatched step, on a machine Cadence.CI starts for it and stops after: the runner.

**Execution group:** the direct run and its distribution runs, shown together in the console.

You launch a **program** from an **entrypoint**. The engine that starts is the **direct run**. Each time the program sends a step elsewhere, a **distribution run** starts on a **runner**, a machine Cadence.CI starts in your cloud account for that step. Together, they form one **execution group**, shown as a hierarchy on the group page.

## Writing Pipelines

- **Program**: A [Mélodium project](https://doc.melodium.tech/book/en/programming/project_organization/main.html): a [`Compo.toml`](https://doc.melodium.tech/book/en/programming/project_organization/compo.html) file and `.mel` source files. In CI/CD, it usually lives in `.melodium-ci/` at the root of the repository. Cadence.CI requires Mélodium 0.11 or later.
- **Treatment**: A [unit of processing](https://doc.melodium.tech/book/en/programming/elements/treatments.html), with inputs, outputs and parameters. Treatments are connected to each other, and a treatment can be made of other treatments: `build` and `test` in the CI/CD template are treatments, made of many smaller ones.
- **Model**: A [configured component](https://doc.melodium.tech/book/en/programming/elements/models.html) that treatments share, such as the dispatch engine that requests machines ([`CicdDispatchEngine`](https://doc.melodium.tech/latest/en/cicd/runners/CicdDispatchEngine.html)), an HTTP server, or a remote language model (`RemoteLlm`).
- **Connection**: A [typed link](https://doc.melodium.tech/book/en/programming/concepts/connections.html) from an output to an input. A `Stream<T>` carries a flow of values, such as the bytes of a file; a `Block<T>` carries one value, such as the `trigger` signal (`Block<void>`). Connecting mismatched types is an error found by the check, before anything runs.
- **Entrypoint**: The [treatment a run starts from](https://doc.melodium.tech/book/en/programming/project_organization/entrypoints.html), declared under `[entrypoints]` in `Compo.toml`. A program can have several, for example `main` and `advanced` in the CI/CD template.
- **Check**: [`melodium check`](https://doc.melodium.tech/book/en/software/cli.html) validates the whole program, types, connections and parameters, without running anything. `melodium run` performs the same check before starting.
- **Secret**: A value typed `Secret`, such as a token or a password. It is given as a locator, `env:MELODIUM_SECRET_<NAME>` for an environment variable, `file:<path>` for a file, or `api:<name>` for a [secret stored on Cadence.CI](https://docs.cadence.ci/en/pipelines/secrets.md), and resolved by the engine that uses it. Secret values are masked in logs; Cadence.CI only sees the name and type of the secrets kept on your side, and keeps the ones you store with it encrypted.

## Running Pipelines

- **Engine**: The Mélodium process that executes a program. It appears as the **Mélodium Engine** service on a run page.
- **Run**: One engine's execution, as reported to Cadence.CI: its status (scheduling, unschedulable, running, finished), its result, the entrypoint and parameters it started with, its logs, debug events and program.
- **Direct run**: A run you launch yourself, for example with `melodium run --api-report` from your machine or from a CI job.
- **Distribution run**: A run started to receive work from another run, its parent. A CI/CD step dispatched with `CicdDispatchEngine` is a distribution run.
- **Execution group**: The direct run and every distribution run it started. The group page draws them as a hierarchy.
- **Work location**: Where dispatched steps go. `api`, the default, asks Cadence.CI for machines in your cloud account; `compose` starts containers with Podman or Docker Compose on the machine running the program. See [Where It Runs](https://docs.cadence.ci/en/how-it-works/where-it-runs.md).
- **Runner**: Where a distribution run executes: an instance Cadence.CI starts in your cloud account for the step and stops after it, or a container when steps run locally with `compose`.
- **Instance**: A virtual machine Cadence.CI started in one of your connected cloud accounts. Each connected account lists its instances, with the run each one served.
- **Debug events**: The record of what the engine did: models and treatments built, started and finished, data sent and received on each connection. At the `detailed` level, they also carry the value of every transmission, except secrets, which never appear. The run page plays them back on a timeline.

## Access

- **Organization**: The unit that owns runs, cloud accounts, tokens and the plan. Members hold a role: Administrator, Operator or Member.
- **Run token**: Lets a program report runs and request machines on behalf of an organization. Set it in the `MELODIUM_API_TOKEN` environment variable: `--api-report` uses it, and so does the CI/CD template to request machines.
- **Cloud account**: An account with one of the [supported providers](https://docs.cadence.ci/en/how-it-works/clouds.md#supported-cloud-providers), connected in **Clouds**, where Cadence.CI starts instances for your runs. See [Connect a Cloud](https://docs.cadence.ci/en/console/clouds.md).
