# API Reference


## The database


One DuckDB file, content-addressed by SHA-256, with every kernel location and tracked metakernel.


[KernelDB](KernelDB.md#spice_kernel_db.KernelDB)  
Content-addressed SPICE kernel database.

[RegistryRow](RegistryRow.md#spice_kernel_db.RegistryRow)  
One tracked metakernel, as a row of the metakernel registry.


## KernelDB Methods


Methods for the KernelDB class


[KernelDB.release()](KernelDB.release.md#spice_kernel_db.KernelDB.release)  
Close the DB connection to release the lock.

[KernelDB.reacquire()](KernelDB.reacquire.md#spice_kernel_db.KernelDB.reacquire)  
Reopen the DB connection after `release()`.

[KernelDB.kernel_roots](KernelDB.kernel_roots.md#spice_kernel_db.KernelDB.kernel_roots)  
The configured kernel roots, as expanded, resolved paths.

[KernelDB.root_for()](KernelDB.root_for.md#spice_kernel_db.KernelDB.root_for)  
The kernel root a download belongs in (decided 2026-11-21).

[KernelDB.add_mission()](KernelDB.add_mission.md#spice_kernel_db.KernelDB.add_mission)  
Register a mission in the database.

[KernelDB.list_missions()](KernelDB.list_missions.md#spice_kernel_db.KernelDB.list_missions)  
List all configured missions.

[KernelDB.remove_mission()](KernelDB.remove_mission.md#spice_kernel_db.KernelDB.remove_mission)  
Remove a mission from the database.

[KernelDB.get_mission()](KernelDB.get_mission.md#spice_kernel_db.KernelDB.get_mission)  
Look up a mission by name.

[KernelDB.register_file()](KernelDB.register_file.md#spice_kernel_db.KernelDB.register_file)  
Register a single kernel file and return its SHA-256.

[KernelDB.aliases()](KernelDB.aliases.md#spice_kernel_db.KernelDB.aliases)  
Follow the deduplication trail for a kernel.

[KernelDB.alias_counts()](KernelDB.alias_counts.md#spice_kernel_db.KernelDB.alias_counts)  
Map each SHA-256 to how many filenames it is known under.

[KernelDB.alias_counts_by_name()](KernelDB.alias_counts_by_name.md#spice_kernel_db.KernelDB.alias_counts_by_name)  
For each filename, count how many other names its content is known under.

[KernelDB.scan_directory()](KernelDB.scan_directory.md#spice_kernel_db.KernelDB.scan_directory)  
Recursively scan a directory tree and register all kernel files.

[KernelDB.scan_roots()](KernelDB.scan_roots.md#spice_kernel_db.KernelDB.scan_roots)  
Run `scan_directory` over every configured kernel root.

[KernelDB.find_by_filename()](KernelDB.find_by_filename.md#spice_kernel_db.KernelDB.find_by_filename)  
Find all locations for a kernel by filename.

[KernelDB.find_by_hash()](KernelDB.find_by_hash.md#spice_kernel_db.KernelDB.find_by_hash)  
Find all locations for a kernel by its SHA-256 hash.

[KernelDB.resolve_kernel()](KernelDB.resolve_kernel.md#spice_kernel_db.KernelDB.resolve_kernel)  
Resolve a kernel filename to an absolute path on disk.

[KernelDB.report_duplicates()](KernelDB.report_duplicates.md#spice_kernel_db.KernelDB.report_duplicates)  
Find and report kernels that exist in multiple locations.

[KernelDB.index_metakernel()](KernelDB.index_metakernel.md#spice_kernel_db.KernelDB.index_metakernel)  
Parse a metakernel and store its entries in the `metakernel_entries` table.

[KernelDB.registry_rows()](KernelDB.registry_rows.md#spice_kernel_db.KernelDB.registry_rows)  
Every tracked metakernel, ordered by mission and filename.

[KernelDB.registry_row()](KernelDB.registry_row.md#spice_kernel_db.KernelDB.registry_row)  
The registry row *ref* names, or None when no row matches.

[KernelDB.resolve_metakernel()](KernelDB.resolve_metakernel.md#spice_kernel_db.KernelDB.resolve_metakernel)  
The on-disk path of the metakernel *ref* names (#45).

[KernelDB.verify_against_server()](KernelDB.verify_against_server.md#spice_kernel_db.KernelDB.verify_against_server)  
Compare each local kernel of a metakernel against the server.

[KernelDB.check_metakernel()](KernelDB.check_metakernel.md#spice_kernel_db.KernelDB.check_metakernel)  
Check which kernels from a metakernel are already available locally.

[KernelDB.check_report()](KernelDB.check_report.md#spice_kernel_db.KernelDB.check_report)  
Everything the `check` command reports, as data (#46).

[KernelDB.newer_remote_version()](KernelDB.newer_remote_version.md#spice_kernel_db.KernelDB.newer_remote_version)  
A notice when the server lists a newer copy of the metakernel, else None.

[KernelDB.rewrite_metakernel()](KernelDB.rewrite_metakernel.md#spice_kernel_db.KernelDB.rewrite_metakernel)  
Rewrite a metakernel for local use with minimal edits.

[KernelDB.verify_metakernel()](KernelDB.verify_metakernel.md#spice_kernel_db.KernelDB.verify_metakernel)  
Deeply cross-check a metakernel against the database.

[KernelDB.get_metakernel()](KernelDB.get_metakernel.md#spice_kernel_db.KernelDB.get_metakernel)  
Fetch a remote metakernel, show its status, and download the missing kernels.

[KernelDB.update_metakernel()](KernelDB.update_metakernel.md#spice_kernel_db.KernelDB.update_metakernel)  
Re-fetch a metakernel from its source URL and download new or missing kernels.

[KernelDB.update_all()](KernelDB.update_all.md#spice_kernel_db.KernelDB.update_all)  
Re-fetch every tracked metakernel from its source, as `skd update` does (#47).

[KernelDB.import_metakernel()](KernelDB.import_metakernel.md#spice_kernel_db.KernelDB.import_metakernel)  
Track a metakernel that is already on disk, without a download (#47).

[KernelDB.list_metakernels()](KernelDB.list_metakernels.md#spice_kernel_db.KernelDB.list_metakernels)  
List all tracked metakernels, optionally filtered by mission.

[KernelDB.metakernels_covering()](KernelDB.metakernels_covering.md#spice_kernel_db.KernelDB.metakernels_covering)  
Tracked metakernels whose SPK kernels cover a body.

[KernelDB.info_metakernel()](KernelDB.info_metakernel.md#spice_kernel_db.KernelDB.info_metakernel)  
Show detailed information about a tracked metakernel, as `skd show` does (#47).

[KernelDB.remove_metakernel()](KernelDB.remove_metakernel.md#spice_kernel_db.KernelDB.remove_metakernel)  
Remove a metakernel from the registry and its entries.

[KernelDB.browse_remote_metakernels()](KernelDB.browse_remote_metakernels.md#spice_kernel_db.KernelDB.browse_remote_metakernels)  
Scan a remote NAIF `mk/` directory and show the available metakernels.

[KernelDB.poisoned_superseded()](KernelDB.poisoned_superseded.md#spice_kernel_db.KernelDB.poisoned_superseded)  
Find kernels flagged as superseded by content that exists in no live location.

[KernelDB.stale_locations()](KernelDB.stale_locations.md#spice_kernel_db.KernelDB.stale_locations)  
List the registered locations whose file is gone from disk.

[KernelDB.doctor()](KernelDB.doctor.md#spice_kernel_db.KernelDB.doctor)  
Report the health of the database, with no metakernel argument (#46).

[KernelDB.stats()](KernelDB.stats.md#spice_kernel_db.KernelDB.stats)  
Print and return summary statistics.

[KernelDB.deduplicate_plan()](KernelDB.deduplicate_plan.md#spice_kernel_db.KernelDB.deduplicate_plan)  
Generate a deduplication plan without executing it.

[KernelDB.deduplicate_with_symlinks()](KernelDB.deduplicate_with_symlinks.md#spice_kernel_db.KernelDB.deduplicate_with_symlinks)  
Replace duplicate files with symlinks to the canonical copy.

[KernelDB.prune()](KernelDB.prune.md#spice_kernel_db.KernelDB.prune)  
Remove stale locations where the file no longer exists on disk.

[KernelDB.prune_orphan_symlinks()](KernelDB.prune_orphan_symlinks.md#spice_kernel_db.KernelDB.prune_orphan_symlinks)  
Find symlinks under the download trees whose target no longer exists.

[KernelDB.prune_metakernels()](KernelDB.prune_metakernels.md#spice_kernel_db.KernelDB.prune_metakernels)  
Find registry rows whose remote URL is permanently gone and optionally remove them.

[KernelDB.coverage_metakernel()](KernelDB.coverage_metakernel.md#spice_kernel_db.KernelDB.coverage_metakernel)  
Check body coverage for all SPK kernels in a metakernel.

[KernelDB.store_coverage()](KernelDB.store_coverage.md#spice_kernel_db.KernelDB.store_coverage)  
Upsert coverage intervals into kernel_coverage table.

[KernelDB.query_coverage()](KernelDB.query_coverage.md#spice_kernel_db.KernelDB.query_coverage)  
Query kernels that cover a body, optionally within a time range.

[KernelDB.close()](KernelDB.close.md#spice_kernel_db.KernelDB.close)  
Close the database connection.

[KernelDB.__enter__()](KernelDB.__enter__.md#spice_kernel_db.KernelDB.__enter__)  

[KernelDB.__exit__()](KernelDB.__exit__.md#spice_kernel_db.KernelDB.__exit__)  


## One call against the configured database


Each opens the database named in the config, does one thing and closes it.


[check()](check.md#spice_kernel_db.check)  
`skd check` as data: the verdicts and their evidence.

[get()](get.md#spice_kernel_db.get)  
`skd get`: fetch a metakernel by URL, or re-fetch a tracked one by name.

[metakernels_covering()](metakernels_covering.md#spice_kernel_db.metakernels_covering)  
Tracked metakernels whose SPK kernels cover a body (at *et*, if given).

[register_metakernel()](register_metakernel.md#spice_kernel_db.register_metakernel)  
Track a metakernel already on disk, as `skd import` does.

[resolve_metakernel()](resolve_metakernel.md#spice_kernel_db.resolve_metakernel)  
The on-disk path of a tracked metakernel, from any form of reference.

[scan()](scan.md#spice_kernel_db.scan)  
Index the kernel files under *directory*, or under every configured root.


## Configuration


The config file and the kernel roots. Nothing here prints or prompts.


[Config](Config.md#spice_kernel_db.Config)  
User configuration for spice-kernel-db.

[ConfigError](ConfigError.md#spice_kernel_db.ConfigError)  
The config file is corrupt, or there is none and nothing says what to write.

[ensure_config()](ensure_config.md#spice_kernel_db.ensure_config)  
Load the config, or write a first one around *seed_root*.

[kernel_roots()](kernel_roots.md#spice_kernel_db.kernel_roots)  
The configured kernel roots as expanded, resolved paths (#48).

[add_root()](add_root.md#spice_kernel_db.add_root)  
Append *directory* to the kernel roots and save (#48).

[remove_root()](remove_root.md#spice_kernel_db.remove_root)  
Remove *directory* from the kernel roots and save (#48).


## Metakernel files


Reading and writing .tm files.


[parse_metakernel()](parse_metakernel.md#spice_kernel_db.parse_metakernel)  
Parse a SPICE metakernel (`.tm`) file from a local path, without needing a database.

[parse_metakernel_text()](parse_metakernel_text.md#spice_kernel_db.parse_metakernel_text)  
Parse a SPICE metakernel from text content.


## Exceptions


[AmbiguousKernelRoot](AmbiguousKernelRoot.md#spice_kernel_db.AmbiguousKernelRoot)  
Nothing says which configured kernel root a download belongs in.

[AmbiguousMetakernel](AmbiguousMetakernel.md#spice_kernel_db.AmbiguousMetakernel)  
A metakernel reference matched several registry rows.

[ConcurrentModificationError](ConcurrentModificationError.md#spice_kernel_db.ConcurrentModificationError)  
Another process modified the kernel records during a download.

[LegacyDatabaseFound](LegacyDatabaseFound.md#spice_kernel_db.LegacyDatabaseFound)  
A database sits at the pre-0.19 default and nothing says to use it.

[MetakernelNotTracked](MetakernelNotTracked.md#spice_kernel_db.MetakernelNotTracked)  
A metakernel reference matched nothing that skd tracks.

[MetakernelUnreachableError](MetakernelUnreachableError.md#spice_kernel_db.MetakernelUnreachableError)  
The remote copy of a tracked metakernel is gone.


## Hosting the CLI


`spice_kernel_db.cli.app` is the Typer app a host mounts under its own command (planetarypy's `plp spice`); these two complete the host contract.


[cli.exit_code()](cli.exit_code.md#spice_kernel_db.cli.exit_code)  
The exit code for one of this package's exceptions, or `None` for any other.

[cli.logging_to_stderr()](cli.logging_to_stderr.md#spice_kernel_db.cli.logging_to_stderr)  
For one CLI run, print the library's warnings as bare lines on stderr.
