> 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/attested-environment-facts.md). Agents can also search and read this documentation through its [MCP server](https://docs.metamynd.ai/~gitbook/mcp).

# Attested Environment Facts

Some rules depend on the state of the world, not on the request: restart a service only while it is unhealthy, scale up only under sustained load, roll back only after a recent release. The agent is the party these rules constrain, so its word about that state is worth nothing. If the gate took "the service is unhealthy" from the agent, any agent that wanted to restart a healthy service would simply say so.

Signing doesn't help here either. A signature says *who* asserted a value, not that it is *true* (see <a href="https://docs.metamynd.ai/core-concepts/context-provenance-and-risk-floors" target="_blank">Context Provenance & Risk Floors</a>). An attested fact comes from someone other than the agent: an **observer**.

#### Observers <a href="#user-content-observers" id="user-content-observers"></a>

An observer is a service you register in your <a href="https://docs.metamynd.ai/core-concepts/trusted-counterparties-and-payee-directory" target="_blank">trusted counterparty registry</a> and give an **observation scope**:

| Scope                | Meaning                                                                                                                           | Example                     |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| **Subjects**         | The targets it may speak about. Exact names, or a pattern ending in `*` that matches any target starting with the text before it. | `svc:checkout`, `svc:*`     |
| **Facts**            | The fact names it may attest.                                                                                                     | `health`, `load`, `release` |
| **Maximum validity** | Optional. The longest any fact it signs may be relied on, in seconds, at most 600.                                                | `120`                       |

The intended observer is a monitoring adapter that reads your own systems (a cluster API, a health endpoint) and is not the agent. The service that executes the agent's actions can be an observer too, for facts it can see.

**An agent can never be its own observer.** A scope can't be given to a DID that is one of your own agents (`OBSERVER_IS_AGENT`): an agent must never attest the facts it is judged on.

A service that only attests facts is registered with the purpose **`observe`**. It claims, settles and reports nothing, and registering it doesn't make your holds registered-only.

#### A fact <a href="#user-content-a-fact" id="user-content-a-fact"></a>

A fact is one short-lived statement about one target:

```
{  "subject": "svc:checkout",  "fact": "health",  "value": "unhealthy",  "observedAt": "2026-11-25T10:02:11Z",  "validFor": 120}
```

| Field        | Rule                                                                                                       |
| ------------ | ---------------------------------------------------------------------------------------------------------- |
| `subject`    | The target, 1 to 256 characters. It is compared **exactly** with the `resource` the agent's request names. |
| `fact`       | A name: a lowercase letter, then up to 63 letters, digits, `_` or `-`.                                     |
| `value`      | A string (at most 256 characters), a number or a boolean.                                                  |
| `observedAt` | When it was observed (ISO 8601). At most 30 seconds in the future, for clock skew.                         |
| `validFor`   | Seconds it may be relied on: 1 to 600, and no more than the observer's own maximum.                        |

The observer **pushes** facts to MetaMynd (`POST /policy/facts`), signed with its own key. The agent never carries them, so it can't choose to present an older, more convenient fact and withhold a newer one.

#### How the gate reads facts <a href="#user-content-how-the-gate-reads-facts" id="user-content-how-the-gate-reads-facts"></a>

When it decides a request that names a `resource`, the gate reads, for each fact name, the **latest unexpired** fact about exactly that target from observers you registered. Each one goes into the rule context under a reserved key, `env.<fact>` (for example `env.health`), labelled `attested`, the highest <a href="https://docs.metamynd.ai/core-concepts/context-provenance-and-risk-floors" target="_blank">provenance</a> level.

* **The `env.` namespace belongs to observers.** Any `env.*` key, or a top-level `env` object, that the agent sends (signed or not), or that a gateway supplies, is dropped before evaluation. An agent can't shadow a fact with its own value.
* **A request with no `resource` reads no facts.**
* **Facts are per owner.** A fact is stored for, and read by, only the owners whose registration of that observer allows it.

A rule reads a fact with an ordinary atom and declares that it must be attested:

```
{  "id": "restart-only-when-unhealthy",  "name": "Restart only an unhealthy service",  "combinator": "all",  "atoms": [    { "id": "health", "predicate": "context-value-not-in", "config": { "field": "env.health", "values": ["unhealthy"] } }  ],  "decision": "block",  "reasonCode": "TARGET_HEALTHY",  "requireProvenance": { "env.health": "attested" }}
```

| The target is...                                                 | The rule decides                     |
| ---------------------------------------------------------------- | ------------------------------------ |
| attested unhealthy                                               | passes                               |
| attested healthy                                                 | **block**, `TARGET_HEALTHY`          |
| not attested: no fact, an expired fact, or only the agent's word | **escalate**, `CONTEXT_UNVERIFIABLE` |

#### Missing facts fail closed <a href="#user-content-missing-facts-fail-closed" id="user-content-missing-facts-fail-closed"></a>

A fact counts only between `observedAt` and `observedAt + validFor`. Once it expires, it is gone: a rule that requires it escalates to a person. "We no longer know the service is unhealthy" never reads as "it is". If your observer stops sending, your agent loses autonomy; it never gains any.

`requireProvenance` is what makes that happen. Without it, a rule on `env.health` with no fact present reads the field as missing, and the atom's `missing` setting decides. **Always declare `requireProvenance` on a rule that reads a fact.**

The requirement covers every request the agent makes: an atom's `actions` list narrows when the atom fires, not when the requirement applies. So a request from that agent with no attested fact for its target escalates, whatever its action. Give such a rule to agents whose actions all act on targets your observers report on.

#### Facts are read again at the claim <a href="#user-content-facts-are-read-again-at-the-claim" id="user-content-facts-are-read-again-at-the-claim"></a>

Between the decision and the execution, the world can change. When a service claims the hold to execute the action, the gate re-checks the agent's rules against the facts about the hold's target **as they stand at that moment** (see <a href="https://docs.metamynd.ai/core-concepts/holds-claims-and-exactly-once-execution" target="_blank">Holds, Claims & Exactly-Once Execution</a>).

* A restart allowed while `svc:checkout` was unhealthy is **voided** if an observer has since said it recovered. The claim is refused `AUTHORIZATION_RULES_CHANGED`, nothing executes, and the hold records the rule that fired: `HOLD_VOIDED:TARGET_HEALTHY`.
* It is also voided if no observer speaks for the target any more, because the fact expired: `HOLD_VOIDED:CONTEXT_UNVERIFIABLE`.
* When you change the agent's rules, the same check runs over its unclaimed holds.

The agent asks again, and the gate decides on the facts as they are now. A hold a person approved is not voided for a rule that escalates, because the person already decided that case.

Keep `validFor` short. It bounds how long a stale fact can stand.

#### Local-first guards <a href="#user-content-local-first-guards" id="user-content-local-first-guards"></a>

A guard deciding from its cached bundle (the `agentsafe-guard` default, local mode) has no observer feed. A rule that needs an attested fact therefore escalates locally, and the guard hands that escalation to the gate, which holds the facts and decides. Only a guard running fully offline, with no gate to ask, keeps the escalation local, which is the safe answer there.

#### Evidence <a href="#user-content-evidence" id="user-content-evidence"></a>

The decision record lists the facts the rules read: their ids, names and observers, but **not their values**. Each stored fact keeps the observer's signature, so a later reader can check exactly what the gate relied on and who stated it.

In the dashboard, a decision's detail in the **Decision Explorer** shows an **Environment facts relied on** table: each fact, its value, who attested it, and how old it was at decision time. See <a href="https://docs.metamynd.ai/guides/reporting-and-the-decision-explorer" target="_blank">Reporting & the Decision Explorer</a>.

#### 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>

* It moves the source of a state fact from the agent to a service you chose and scoped.
* It does **not** make the observer right. A wrong or compromised observer can attest false facts within its scope. Limit the damage by scoping it narrowly (specific targets, specific facts), revoking it when needed, and reading which observer each decision relied on.
* It works today for facts compared against a list (`health` is `unhealthy`). Rules on numeric facts (`env.load` above 0.8) need a numeric atom on a named field, which isn't available yet.

#### 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/guides/govern-operations-with-attested-facts" target="_blank">Govern Operations with Attested Facts</a>: register an observer, push a fact and write the rule, step by step.
* <a href="https://docs.metamynd.ai/core-concepts/context-provenance-and-risk-floors" target="_blank">Context Provenance & Risk Floors</a>: the provenance levels and `requireProvenance`.
* The protocol text: <a href="https://metamynd.ai/developers/spec" target="_blank">MAGP §6.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/attested-environment-facts.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.
