## KernelDB.verify_metakernel()


Deeply cross-check a metakernel against the database.


Usage

``` python
KernelDB.verify_metakernel(
    mk_path,
    *,
    deep=False,
)
```


Each entry in `KERNELS_TO_LOAD` is substituted through `PATH_VALUES` and `PATH_SYMBOLS` to the absolute path SPICE will load. That path is validated against the `kernels` row of the registered location at that path, or of the file a symlink there leads to. Only a path the database has not registered falls back to the `kernels` rows whose filename matches (case-insensitive).

Checks, with the entry `status` each failure gets:

- `PATH_VALUES` entries that are not absolute, or not existing directories (`BAD_PATH_VALUE`);
- traversal escape from the `PATH_VALUES` root (`TRAVERSAL`, C1);
- dangling symlinks (`DANGLING`), missing files (`NOT_FOUND`) and paths that are not files (`NOT_FILE`);
- size mismatch against `kernels.size_bytes` (`SIZE_MISMATCH`);
- SHA-256 mismatch against `kernels.sha256`, only with `deep=True` (`HASH_MISMATCH`);
- ambiguous resolution (`AMBIGUOUS`, C3): the path is not registered and several non-superseded `kernels` rows share the filename. A registered path is never ambiguous, so a same-named kernel with other content in another mission or kernel root is not flagged (see the design notes on `superseded_by` semantics);
- files the database does not know (`UNREGISTERED`).

An entry that passes has status `OK`. This is the recommended cross-check after every [get](get.md#spice_kernel_db.get), `update` and `rewrite`. Run it with `deep=True` periodically to catch content corruption that preserves the size.


## Parameters


`mk_path: str | Path`  
The metakernel: a path, or any reference [resolve_metakernel](resolve_metakernel.md#spice_kernel_db.resolve_metakernel) accepts. Typically a rewritten one with absolute `PATH_VALUES`.

`deep: bool = ``False`  
Recompute the SHA-256 of every entry. Without it only stat-based checks run, which is fast.


## Returns


`dict`  
With the keys `entries`, `ok` (the number of entries that passed), `fail` (the number that did not), `fatal`, `mk_path` and `deep`. Each entry is a dict with `raw`, `resolved`, `status` and `detail` (and `sha256` for a verified one in deep mode). `fatal` is `True` if any entry is in a P0 state: `BAD_PATH_VALUE`, `TRAVERSAL`, `DANGLING`, `NOT_FOUND`, `NOT_FILE`, `AMBIGUOUS`, `SIZE_MISMATCH` or `HASH_MISMATCH`. `UNREGISTERED` counts as a failure but is not fatal.


## Raises


`MetakernelNotTracked`  
*mk_path* matches nothing.

`AmbiguousMetakernel`  
*mk_path* matches several registry rows.
