The verifier does not say "valid" or "invalid": it returns the list of reasons, and every reason
carries a code, the step that emitted it, the concrete form of the failure and a readable detail. The
caller decides from the code, not from the text. There are fourteen `algoritmo-v1` codes (`R01` to
`R14`), plus `R15` on the federated route.

## Steps

The steps are the middleware's: one preparation step and the eight steps of the algorithm. Except for
step 1, which is the preparation, step N equals step N-1 in the contract's eight-step numbering; on the
federated route the anchor takes step 9 and the result becomes step 10.

| Step | What it does | Codes |
| --- | --- | --- |
| 1 | prepare the verification and read the status from the cache | `R12` |
| 2 | take the signature with an allowed `alg` and the key inside `x5c` | `R01`, `R02`, `R03` |
| 3 | canonicalize with JCS and validate the JWS | `R04` |
| 4 | validate the `x5c` chain and the conformance of the leaf | `R05`, `R06` |
| 5 | require SAN URI equal to the origin URL and a proven origin | `R07`, `R08` |
| 6 | require validity and an inclusion proof bound to the card | `R09`, `R10`, `R11` |
| 7 | query the status list by its three indices | `R12` |
| 8 | validate the mandate and its issuer when the action asks for it | `R13`, `R14` |
| 9 | require a valid CRDCA anchor for the federated log the card declares | `R15` |
| 10 | return `agent_id`, `operador`, `nivel`, `motivos`, `limites_verificados` and `mandato` | none |

Step 9 only exists on the federated route, when the card declares a log that is not CRDCA's; without a
foreign log the verification ends at step 8 and returns at step 9.

## Output

A blocked result looks like this (excerpt):

```json
{
  "aceptada": false,
  "bloqueada": true,
  "modo": "bloquear",
  "agent_id": "https://example.com/agents/invoices/agent-card.json",
  "operador": "example.com",
  "nivel": 0,
  "nivel_firma": "",
  "motivos": [
    {
      "id": "R08_ORIGIN_UNPROVEN",
      "codigo": "R08",
      "paso": 5,
      "detalle": "la URL de origen no está probada en esta verificación",
      "forma": null
    }
  ],
  "limites_verificados": "por-solicitud",
  "mandato": null,
  "codigos": ["R08"],
  "llamadas_en_linea": 0
}
```

`codigos` is the deduplicated list of emitted codes, in the order they appeared. `pasos` carries the
trace of every executed step, with its decision and its result.

## Modes

| Mode | Contract alias | What it does with a reason |
| --- | --- | --- |
| `bloquear` | `estricto` | the first rejection stops the verification and the call does not pass |
| `advertir` | `tolerante` | collects every reason, the call passes and the result is recorded |

Both modes enumerate the fourteen v1 codes, so the library takes twenty-eight code decisions. `R15`
lives outside that frozen block: it belongs to federation.

## Codes

| Code | Name | Meaning | Step | What to do |
| --- | --- | --- | --- | --- |
| `R01` | `ALG_NOT_ALLOWED` | the signature `alg` is not in the list: `EdDSA`, `ES256` and, from v2, `ML-DSA-65` | 2 | Reject. The issuer must re-sign with an allowed algorithm |
| `R02` | `KEY_SOURCE_NOT_X5C` | the key does not come from `x5c`, or the header carries `jku`, `jwk`, `x5u` or `crit` | 2 | Reject. The key is not looked up anywhere else |
| `R03` | `KID_MISMATCH` | `kid` is not the SHA-256 thumbprint of the SPKI of `x5c[0]` | 2 | Reject. `kid` is recomputed, never trusted |
| `R04` | `SIGNATURE_INVALID` | the JWS is malformed, the payload is not the canonical JCS card, or the signature does not verify | 3 | Reject. If the detail is the missing signature tool, retry on a node with `openssl` and alert |
| `R05` | `CHAIN_UNTRUSTED` | the `x5c` chain does not end in a valid root of the trust package, or there is a broken link, a revocation or an invalid signature | 4 | Reject. Retry only when the package or the revocation was unavailable: reload and repeat |
| `R06` | `HOJA_NO_CONFORME` | `x5c[0]` is a CA, lacks its profile EKU, leaves its issuer's namespace or outlives its issuer | 4 | Reject and alert the issuer: the defect is in the certificate, not in the call |
| `R07` | `SAN_MISMATCH` | the certificate SAN URI is not equal to the origin URL, or the leaf does not carry exactly one `https` URI | 5 | Reject and alert the operator: the card must be issued with the right URL |
| `R08` | `ORIGIN_UNPROVEN` | the origin URL was not proven by fetching the card in this verification | 5 | Retry the fetch and verify again; if it repeats, reject |
| `R09` | `NOT_VALID_NOW` | the leaf certificate is not valid at the verification instant | 6 | Reject. The issuer renews through ARI at half life |
| `R10` | `INCLUSION_MISSING` | there is no valid inclusion proof: it is missing, it belongs to another tree size, the checkpoint goes backwards or it is stale | 6 | Reject if missing or invalid; retry after reloading the checkpoint when the problem is its freshness or availability |
| `R11` | `INCLUSION_MISMATCH` | the proof is valid against the log but comes from another leaf | 6 | Reject and alert: a proof from another card is a reuse attempt |
| `R12` | `STATUS_SUSPENDED` | the status list marks the class, the platform or the operator as suspended, or there is no usable copy | 1, 7 | Reject when suspended or when there is no row; if the copy is stale or the publisher does not respond, reload and retry |
| `R13` | `MANDATE_INVALID` | the action asks for a mandate and none was presented, or the mandate is not valid | 8 | Reject and ask the human for a new mandate |
| `R14` | `MANDATE_ISSUER_UNTRUSTED` | the mandate issuer is not in the verifier's admitted issuer list | 8 | Reject and escalate: the list belongs to the verifier, not to the mandate issuer |
| `R15` | `LOG_NO_ANCLADO` | the foreign log the card declares has no valid CRDCA anchor binding its checkpoint | 9 | Reject. Retry only when the anchor was unavailable or expired; alert if it belongs to another operator or another checkpoint |

## Forms

The concrete form travels in `forma` and distinguishes cases of the same code. An empty or null form
is the general case.

| Code | Forms | What it distinguishes |
| --- | --- | --- |
| `R01` | `pq` | the post-quantum complementary signature is superfluous or declares a disallowed `alg` |
| `R02` | `pq` | the post-quantum key in `crdca_pq` is missing or unreadable |
| `R04` | `pq` | the complementary signature does not verify; the signature level is left empty |
| `R05` | `x5c_vacio`, `cadena_incompleta`, `der_invalido` | the header carries no `x5c`, fewer than two elements, or an unreadable certificate |
| `R05` | `paquete_vencido`, `paquete_no_disponible`, `revocacion_no_disponible` | a verifier input is missing: retryable |
| `R05` | `revocado`, `eslabon_roto`, `firma_no_verificable`, `firma_invalida`, `raiz_no_confiada`, `fuera_de_vigencia` | the chain is not trusted |
| `R06` | `ca`, `eku`, `name_constraints`, `vida`, `ilegible` | the leaf is a CA, lacks the profile EKU, leaves its issuer, outlives it, or cannot be read |
| `R10` | `ausente`, `sin_checkpoint`, `checkpoint`, `tamano`, `checkpoint_vencido`, `canonica`, `invalida` | the proof is missing, the checkpoint is missing, it goes backwards, it belongs to another tree, it is stale, the card cannot be canonicalized, or the proof does not validate |
| `R11` | `otra_hoja` | the proof comes from another leaf |
| `R12` | `vencida`, `sin_respuesta`, `sin_fila`, `suspendido` | the copy is outside the window, the publisher does not respond, there is no row for the index, or the row is suspended |
| `R15` | `sin_ancla`, `caducada`, `otro_operador`, `trasplantada`, `checkpoint_ajeno`, `ancla_invalida` | there is no anchor, it is outside its window, it belongs to another operator, it does not bind the checkpoint, the card attaches no checkpoint, or the anchor is invalid |

## Levels

| Level | Meaning |
| --- | --- |
| `0` | chain and origin proven; inclusion or status is not proven |
| `1` | plus a valid inclusion proof and fresh status in cache |
| `2` | plus the action asks for a mandate and the mandate verifies |

`limites_verificados` is always `por-solicitud`: the mandate limits are checked per request, with no
shared state that could accumulate amounts across mandates.

::: nota What is not a code
A reason is not an exception and not a network error: it is a decision. The verifier does not call
CRDCA during the call and does not query the issuer; it works with the trust package, the cached
status list, the log and the mandate verifier it receives. `llamadas_en_linea` is always `0`.
:::
