# `core/charts/risk.ts`

<p class="generated-note">Generated from the exports of <a href="https://github.com/altasystem-ai/alta/blob/main/core/charts/risk.ts"><code>core/charts/risk.ts</code></a> · <code>npm run docs:gen</code></p>

The risk level of a chart (docs/standards/alta-chart-0.1.md §8, "Risk level"): computed from what the chart names, never declared by its author. Deterministic, because `capabilities` must already equal the capabilities of the executors the chart names (chart.capabilities) and the permissions are closed lists. Every reason is returned: the consent step and `alta verify` show them. Conservative: a `when` is ignored (what a chart may do with some values, it may do). Pure: no disk, no network.

**Standards that cite this file**: [alta.attestation/0.1: who signed which files of a chart](https://docs.altasystem.ai/reference/advanced/specs/alta-attestation-0.1) · [alta.chart/0.1: the Agent Chart](https://docs.altasystem.ai/reference/advanced/specs/alta-chart-0.1)

## Exports

### `RiskLevel` 
```ts
type RiskLevel = "low" | "medium" | "high";
```

### `RISK_LEVELS` 
```ts
const RISK_LEVELS: readonly RiskLevel[]
```

### `RISK_RULES` 
The rules, in the order they are checked. Ids are stable: the docs and the tests name them.

```ts
const RISK_RULES = [ { id: "risk.exec", level: "high" }, { id: "risk.tools-floor", level: "high" }, { id: "risk.setup", level: "high" }, { …
```

### `RiskRuleId` 
```ts
type RiskRuleId = (typeof RISK_RULES)[number]["id"];
```

### `RiskReason` 
```ts
interface RiskReason { rule: RiskRuleId; level: RiskLevel; en: string; fr: string }
```

### `Risk` 
```ts
interface Risk { level: RiskLevel; reasons: RiskReason[] }
```

### `RiskTables` 
The tables the rules read (the defaults are the closed lists of this build; a test may give others).

```ts
interface RiskTables {
  toolsFloor?: readonly string[];
  netTools?: readonly string[];
  /** Is a repair kind one the owner may allow to run without being asked? */
  grantable?: (kind: unknown) => boolean;
  /** The capability of an executor id (default: the closed list, core/runs/executors.ts). */
  capOf?: (executor: unknown) => string | null | undefined;
}
```

### `riskOf` 
The risk level of a chart and every reason for it. `bindings` (need id → provider): the real case after binding,
for the consent step; absent, the worst case among each need's providers, for the catalogue.

```ts
function riskOf(chart: Chart | Loose, tables: RiskTables = {}, bindings?: Record<string, string | undefined>): Risk
```

### `RISK_WORDS` 
The level in plain words, for the consent step.

```ts
const RISK_WORDS: Readonly<Record<RiskLevel, { en: string; fr: string }>>
```

### `riskLines` 
The lines of the consent step: the level, then one line per reason.

```ts
function riskLines(r: Risk): { en: string[]; fr: string[] }
```
