> For the complete documentation index, see [llms.txt](https://docs.metamynd.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metamynd.ai/core-concepts/context-provenance-and-risk-floors.md). Agents can also search and read this documentation through its [MCP server](https://docs.metamynd.ai/~gitbook/mcp).

# Context Provenance & Risk Floors

Rules judge context: the risk level of an action, the tool it uses, its jurisdiction, whether consent was given. Most of that context arrives in the request's `itinerary` — which is **unsigned**, and in any case written by the agent. A rule that judges only what the agent said about itself has judged nothing.

A signature doesn't fix that. Signing a field says *who* asserted a value, not that it is *true* — and a counterparty that re-checks the request reads the same claim. So MAGP takes a different approach: every context field carries its **provenance**, and the fields that matter most can be set by someone other than the agent.

#### Provenance: where each value came from <a href="#user-content-provenance-where-each-value-came-from" id="user-content-provenance-where-each-value-came-from"></a>

Every context field is labelled with the source of its value. The label is attached by the party assembling the context — never by the request, so an agent cannot label its own claim as trusted.

| Provenance        | Source                                                                                                                                                                                                                 | Rank |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
| `agent_asserted`  | the agent's own unsigned context                                                                                                                                                                                       | 0    |
| `agent_signed`    | covered by the agent's signature — attributable, not verified                                                                                                                                                          | 1    |
| `gateway_derived` | derived by the authenticated executing service from the real request                                                                                                                                                   | 2    |
| `authoritative`   | derived by the issuer (spend so far, call count, trust) or set by the mandate's owner                                                                                                                                  | 3    |
| `attested`        | a fact signed by an observer the owner registered and scoped, read under `env.<fact>` (see <a href="https://docs.metamynd.ai/core-concepts/attested-environment-facts" target="_blank">Attested Environment Facts</a>) | 4    |

An unlabelled field is `agent_asserted`: nothing reads as more trusted than the agent's own word by accident. Sources are applied in order of trust — unsigned, then signed, then gateway-derived, then server-derived, then attested — each later source winning a collision, so a key the agent puts in its itinerary can never shadow a signed amount or a server-counted rate. The `env.` namespace is reserved for attested facts: an `env.*` key from any other source is dropped.

#### Risk is a floor, never a ceiling <a href="#user-content-risk-is-a-floor-never-a-ceiling" id="user-content-risk-is-a-floor-never-a-ceiling"></a>

`riskLevel` (`low` · `medium` · `high` · `critical`) is treated differently from other fields: it is **merged, not overridden**. The effective risk is the **highest** of:

* the agent's own claim;
* the mandate owner's **`riskTier`** on the permission (`authoritative`), set when the mandate is issued;
* a **risk signal** MetaMynd derived from the request itself (`authoritative`, see below);
* a value the executing gateway derived from the real request (`gateway_derived`).

An agent may *raise* the risk of its action; it can never lower it below what a trusted source says. `riskTier` is part of the signed mandate, so the gate and every guard apply the same floor, and a delegated mandate cannot drop or lower its parent's tier. The operating-mode check judges the *effective* risk too, so an agent in `supervised` mode cannot skip high-risk review by claiming `low`.

#### Risk signals: risk MetaMynd derives from the request <a href="#user-content-risk-signals-risk-metamynd-derives-from-the-request" id="user-content-risk-signals-risk-metamynd-derives-from-the-request"></a>

An owner tier says how risky an action *always* is. Some risk depends on the individual request, so the gate derives it from what the request actually does, never from the agent's label. Each signal sets the risk to **`high`**:

| Signal          | Fires when                                                                                                                                                                                                                                              | Applies to                                                                                                                                                             |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `amount-share`  | A single payment is at or above **70%** of the action's per-transaction cap (`perTxnMax`). With a cap of 500, a payment of 350 or more is `high`.                                                                                                       | Value-bearing actions with a per-transaction cap                                                                                                                       |
| `new-merchant`  | This is the **first payment to a merchant nobody has vetted**: it is not on the mandate's merchant list, not a payee the owner registered, and has never been paid under this mandate. If the payment-history lookup fails, the merchant counts as new. | Value-bearing actions whose mandate has **no** merchant list (a listed merchant is already vetted)                                                                     |
| `context-value` | An owner rule keyed on what the action does fired (`context-value-in` / `context-value-not-in`), e.g. `op=delete-all is owner-marked for review`.                                                                                                       | Any action, including non-financial ones. See <a href="https://docs.metamynd.ai/guides/govern-non-financial-actions" target="_blank">Govern Non-Financial Actions</a>. |

`amount-share` and the owner's tier come from the signed mandate, so the gate and every guard derive the same floor. Only the gate knows the payee directory and the payment history, so only the gate raises `new-merchant`.

A signal raises the risk; it does not refuse anything on its own. Whatever judges risk acts on it: the default SOP that onboarding provisions includes a **High-risk review** rule (`risk-at-or-above: high` → escalate `RISK_REVIEW`), and an agent in `supervised` mode is escalated at `high` (`MODE_SUPERVISED_REVIEW`).

**Tuning the signals**

The owner sets `riskSignals` per action, on the mandate (`POST /policy/mandate`) or at provisioning:

```
{  "riskTier": "medium",  "riskSignals": { "amountShare": 0.9, "newMerchant": "strict" }}
```

| Setting              | Values                                                                                                                                                             | Default |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
| `amountShare`        | a fraction greater than 0 and at most 1, or `false` to turn the signal off                                                                                         | `0.7`   |
| `newMerchant`        | `true`, `false`, or `"strict"`: also treat a payment that names **no** merchant like a first payment, so an agent can't avoid review by leaving the merchant blank | `true`  |
| `riskSignals: false` | turns off every derived signal for this action (the owner's `riskTier` still applies)                                                                              | —       |

If an action is granted more than once, the strictest setting wins: the smallest `amountShare`, and `newMerchant` stays on if any grant leaves it on. An invalid value is rejected with a `400` when the mandate is issued, never silently ignored.

**Where the signals show up**

Every signal carries a sentence explaining why it fired, for example `82% of the 500 per-transaction cap (review from 70%)` or `the first payment to this merchant`. Signals that can send an action for review (any level above `low`) appear:

* on the **verdict**, as `riskSignals` (the SDKs expose it as `err.governance.riskSignals` in Node and `GovernanceRefusal["riskSignals"]` in Python);
* on the **escalation card** a reviewer sees;
* in the **decision record**, as a `risk` control result.

If an escalation carries no `riskSignals`, the review came from the agent's own `riskLevel` claim.

#### Risk rules fail closed <a href="#user-content-risk-rules-fail-closed" id="user-content-risk-rules-fail-closed"></a>

A rule that uses the `risk-at-or-above` atom cannot pass when `riskLevel` is missing or isn't one of the four levels. Instead it decides at least `escalate`, with reason code **`CONTEXT_UNVERIFIABLE`** — whatever its combinator, so a `none` rule can't read absence as "nothing wrong". That escalation is a **floor, not a shield**: it lifts a request that would otherwise be allowed to human review, but a request that a hard rule blocks — an SOP spending cap, the mandate's per-transaction or total cap — is still blocked, with that rule's code, whether or not `riskLevel` was sent. (`"HIGH "` is read as `high`; the check is case- and whitespace-insensitive.)

{% hint style="info" %} If your agent calls the gate directly — for example from the Python client — include `riskLevel` in the request context. A request that sends none will be escalated by any rule that judges risk. {% endhint %}

#### Rules can demand a trusted source <a href="#user-content-rules-can-demand-a-trusted-source" id="user-content-rules-can-demand-a-trusted-source"></a>

A molecule can state the trust it needs: `requireProvenance: { riskLevel: 'gateway_derived' }`. For each named field, the molecule needs a well-formed value whose provenance is at least that level; otherwise it decides at least `escalate` (`CONTEXT_UNVERIFIABLE`). An unknown level is read as the strictest, and a document declaring one is rejected when it is authored — so a typo can only make a rule refuse more, never less.

A rule about the state of your systems, such as "restart only an unhealthy service", declares `requireProvenance: { "env.health": "attested" }`: only an observer you registered can then satisfy it, and when no observer speaks for the target the rule escalates. See <a href="https://docs.metamynd.ai/guides/govern-operations-with-attested-facts" target="_blank">Govern Operations with Attested Facts</a>.

#### The gateway can supply what it knows <a href="#user-content-the-gateway-can-supply-what-it-knows" id="user-content-the-gateway-can-supply-what-it-knows"></a>

The service that executes the action sees the real request, not the agent's description of it. The guards let it pass what it derived as **`trustedContext`** — for example `guardIncomingTool('wire-transfer', handler, { trustedContext: { riskLevel: 'high' } })` in `agentsafe-mcp-guard`, with the equivalent in `agentsafe-http-gateway` and `agentsafe-a2a-guard`. That context is applied over the agent's claim and labelled `gateway_derived`.

A `trustedContext` deriver that is configured but yields nothing usable — it throws, returns something that isn't an object, or returns a `riskLevel` that isn't a level — means the deriver is broken, and the request is **refused**. It never falls back to the agent's word.

#### What this does and does not establish <a href="#user-content-what-this-does-and-does-not-establish" id="user-content-what-this-does-and-does-not-establish"></a>

Be precise about the guarantee:

* It closes **omission** and **garbling** of risk everywhere: a missing or unrecognised `riskLevel` is refused, not read as low.
* It closes **understating** risk *where a trusted source exists*: an owner `riskTier`, a risk signal, a gateway-derived value, or a `requireProvenance` rule.
* It does **not** make an agent's claim true. With no owner tier, no signal that fires, no gateway derivation and no `requireProvenance`, `riskLevel` is still the agent's word — only hiding or garbling it is refused.
* Other agent-supplied fields (`tool`, `model`, `consent`, …) keep their documented behaviour when absent. `jurisdiction` is not one of them: the gate enforces only a signed jurisdiction or the country the owner registered for the payee, and ignores one in the context (see <a href="https://docs.metamynd.ai/guides/restrict-jurisdictions" target="_blank">Restrict Jurisdictions</a>). A rule that must not depend on the agent's word about them should declare `requireProvenance`.

Adding these fields to the signed message would not help: it would only attribute them, and it would break every deployed client and every anchored proof. Provenance is the defence instead.

#### Where to go next <a href="#user-content-where-to-go-next" id="user-content-where-to-go-next"></a>

* <a href="https://docs.metamynd.ai/core-concepts/policy-standards-and-sops" target="_blank">Policy: Standards & SOPs</a> — the atoms and molecules these rules are built from.
* <a href="https://docs.metamynd.ai/agent-protocol/the-authorize-gate-16-ordered-checks" target="_blank">The Authorize Gate: 16 Ordered Checks</a> — where the risk floor and operating-mode checks sit.
* <a href="https://docs.metamynd.ai/core-concepts/attested-environment-facts" target="_blank">Attested Environment Facts</a> — where `attested` values come from.
* The protocol text: <a href="https://metamynd.ai/developers/spec" target="_blank">MAGP §6.3, §6.4 and §17.4</a>.

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.metamynd.ai/core-concepts/context-provenance-and-risk-floors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
