> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alkera.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Reactivity

> Cells know what they read and what reads them, so results stay current as inputs and queries change.

Alkera notebooks are **reactive**. Each cell knows which names it defines and which names it reads, so the notebook forms a dependency graph. Change an input or a query, and the cells that depend on it re-run. A result on screen always matches the code above it.

There is no hidden state from running cells out of order, because the order cells run in comes from the graph, not from their position on the page.

## How the graph is built

Alkera reads each cell's code to find:

* **Definitions**: the variables, functions, and imports the cell creates.
* **References**: the names it reads that another cell defines.

A cell that reads `orders` depends on the cell that defines `orders`. SQL cells take part too. A SQL cell's result name is a definition, and a DuckDB query that selects from a dataframe is a reference to it.

In the gutter beside each cell, **↑** and **↓** counts show how many cells it reads from and how many read it. Hover to highlight them, and click to jump there.

### Rules that keep the graph sound

* Each name is defined in one cell. If two cells define the same name, both are flagged, and the cell offers to make the name local to that cell or to rename it.
* Cells can't depend on each other in a loop. Cells in a cycle are flagged and do not run.
* Names that start with an underscore are local to their cell, so `_tmp` in one cell does not clash with `_tmp` in another.

## Run modes

Choose how the notebook reacts in **Settings** (the gear in the toolbar), under **When a cell runs**.

| Mode | Setting | What happens when a cell runs |
| - | - | - |
| **Autorun** (default) | **Cells that read a changed value re-run** | Every cell downstream re-runs, in dependency order. |
| **Lazy** | **They are marked stale instead** | Downstream cells are marked **Stale**. Run them when you are ready. |

Lazy mode is useful when downstream cells do something expensive, such as a slow computation or a query against a billed warehouse.

When a run would take a long time, Alkera asks first with **Run these cells?** and an estimated time.

## Cell status

The dot in each cell's gutter shows its state.

| Status | Meaning |
| - | - |
| **Up to date** | Its output matches its code and inputs. |
| **Edited** | The code changed since it last ran. |
| **Stale** | Something it reads changed. Run it to update. |
| **Not run** | It has not run in this kernel. |
| **Queued** / **Running** | Waiting to run, or running. |
| **Error** | It raised an error. |
| **Interrupted** / **Stopped** | The run was interrupted, or the cell stopped itself. |
| **Skipped** | It did not run because a cell it depends on failed. |
| **Disabled** | It is turned off and never runs. |

## Run controls

The toolbar has **Run all**, **Run stale**, and **Interrupt**. The **Kernel** menu adds **Restart**, **Restart and run all**, **Interrupt and clear the queue**, **Shut down**, and **Clear all outputs**.

Each cell's **⋯** menu adds **Run above** and **Run below**.

## See the whole graph

Open **Panels** in the toolbar and choose **Graph** to see the notebook's dependency graph. Filter it to a cell's **Upstream** or **Downstream** to see what feeds it and what it affects.

**Variables** lists every name the notebook defines and jumps to the cell that defines it. **Outline** lists the notebook's Markdown headings.

## Widgets drive reactivity

Interactive widgets such as sliders and dropdowns are values in the graph. Move a slider and every cell that reads it re-runs. See [widgets](/notebooks/outputs#widgets).

## Related

<Columns cols={2}>
  <Card title="SQL and Python" icon="database" href="/notebooks/sql-and-python">
    How SQL results join the graph.
  </Card>

  <Card title="Outputs and charts" icon="chart-line" href="/notebooks/outputs">
    Widgets and the outputs they drive.
  </Card>
</Columns>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.