spice-kernel-db 0.22.2__tar.gz → 0.30.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. spice_kernel_db-0.30.0/.claude/scheduled_tasks.lock +1 -0
  2. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/.github/workflows/publish.yml +16 -6
  3. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/.gitignore +9 -0
  4. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/CHANGELOG.md +315 -0
  5. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/CITATION.cff +1 -1
  6. spice_kernel_db-0.30.0/CLAUDE.md +133 -0
  7. spice_kernel_db-0.30.0/Makefile +25 -0
  8. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/PKG-INFO +7 -3
  9. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/README.md +3 -2
  10. spice_kernel_db-0.30.0/conda/recipe.yaml +64 -0
  11. spice_kernel_db-0.22.2/docs/motivation.qmd → spice_kernel_db-0.30.0/docs/01-motivation.qmd +2 -2
  12. spice_kernel_db-0.22.2/docs/design.qmd → spice_kernel_db-0.30.0/docs/02-design.qmd +2 -2
  13. spice_kernel_db-0.22.2/docs/usage.qmd → spice_kernel_db-0.30.0/docs/03-usage.qmd +70 -32
  14. spice_kernel_db-0.30.0/docs/04-cli.qmd +846 -0
  15. spice_kernel_db-0.22.2/docs/troubleshooting.qmd → spice_kernel_db-0.30.0/docs/07-troubleshooting.qmd +58 -19
  16. spice_kernel_db-0.30.0/docs/index.qmd +79 -0
  17. spice_kernel_db-0.30.0/great-docs.yml +89 -0
  18. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/pyproject.toml +6 -2
  19. spice_kernel_db-0.30.0/src/spice_kernel_db/__init__.py +69 -0
  20. spice_kernel_db-0.30.0/src/spice_kernel_db/api.py +253 -0
  21. spice_kernel_db-0.30.0/src/spice_kernel_db/cli/__init__.py +241 -0
  22. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/cli/_app.py +32 -4
  23. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/cli/browse.py +79 -67
  24. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/cli/configure.py +79 -16
  25. spice_kernel_db-0.30.0/src/spice_kernel_db/cli/inspect_cmds.py +495 -0
  26. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/cli/prompts.py +72 -82
  27. spice_kernel_db-0.30.0/src/spice_kernel_db/cli/transform.py +239 -0
  28. spice_kernel_db-0.30.0/src/spice_kernel_db/config.py +315 -0
  29. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/coverage.py +18 -4
  30. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/db.py +2156 -732
  31. spice_kernel_db-0.30.0/src/spice_kernel_db/hashing.py +178 -0
  32. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/parser.py +130 -17
  33. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/remote.py +40 -22
  34. spice_kernel_db-0.30.0/tests/_netguard.py +15 -0
  35. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/conftest.py +70 -3
  36. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/helpers.py +38 -1
  37. spice_kernel_db-0.30.0/tests/test_api.py +306 -0
  38. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/test_cli.py +618 -37
  39. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/test_db.py +334 -19
  40. spice_kernel_db-0.30.0/tests/test_isolation.py +44 -0
  41. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/test_metakernel.py +96 -68
  42. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/test_regressions.py +241 -12
  43. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/test_remote.py +2 -2
  44. spice_kernel_db-0.22.2/CLAUDE.md +0 -100
  45. spice_kernel_db-0.22.2/conda/meta.yaml +0 -49
  46. spice_kernel_db-0.22.2/docs/_quarto.yml +0 -42
  47. spice_kernel_db-0.22.2/docs/api.qmd +0 -654
  48. spice_kernel_db-0.22.2/docs/cli.qmd +0 -634
  49. spice_kernel_db-0.22.2/docs/custom.scss +0 -17
  50. spice_kernel_db-0.22.2/docs/index.qmd +0 -55
  51. spice_kernel_db-0.22.2/docs/tutorial-mission-discovery.ipynb +0 -376
  52. spice_kernel_db-0.22.2/src/spice_kernel_db/__init__.py +0 -32
  53. spice_kernel_db-0.22.2/src/spice_kernel_db/cli/__init__.py +0 -118
  54. spice_kernel_db-0.22.2/src/spice_kernel_db/cli/inspect_cmds.py +0 -497
  55. spice_kernel_db-0.22.2/src/spice_kernel_db/cli/transform.py +0 -176
  56. spice_kernel_db-0.22.2/src/spice_kernel_db/config.py +0 -135
  57. spice_kernel_db-0.22.2/src/spice_kernel_db/hashing.py +0 -111
  58. spice_kernel_db-0.22.2/tests/_netguard.py +0 -9
  59. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/.github/workflows/ci.yml +0 -0
  60. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/.zenodo.json +0 -0
  61. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/LICENSE +0 -0
  62. /spice_kernel_db-0.22.2/docs/coverage.qmd → /spice_kernel_db-0.30.0/docs/05-coverage.qmd +0 -0
  63. {spice_kernel_db-0.22.2/docs → spice_kernel_db-0.30.0/docs/_archive}/review.qmd +0 -0
  64. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/docs/images/hero.svg +0 -0
  65. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/mission_registry.toml +0 -0
  66. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/src/spice_kernel_db/registry.py +0 -0
  67. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/__init__.py +0 -0
  68. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/fixtures/mission_registry_min.toml +0 -0
  69. {spice_kernel_db-0.22.2 → spice_kernel_db-0.30.0}/tests/test_network.py +0 -0
@@ -0,0 +1 @@
1
+ {"sessionId":"8526dcb1-77f1-4638-bb4c-453f1b92cbc1","pid":1584,"procStart":"Mon Nov 23 13:08:58 2026","acquiredAt":1795454208381}
@@ -1,4 +1,4 @@
1
- name: Deploy Quarto site to GitHub Pages
1
+ name: Deploy docs to GitHub Pages
2
2
 
3
3
  on:
4
4
  workflow_run:
@@ -23,19 +23,29 @@ jobs:
23
23
  steps:
24
24
  - name: Checkout
25
25
  uses: actions/checkout@v7
26
+ with:
27
+ fetch-depth: 0 # page timestamps from history
28
+
29
+ - uses: actions/setup-python@v6
30
+ with:
31
+ python-version: "3.12"
32
+
33
+ - name: Install package and great-docs
34
+ run: |
35
+ python -m pip install --upgrade pip
36
+ python -m pip install -e ".[docs]"
26
37
 
27
38
  - name: Setup Quarto
28
39
  uses: quarto-dev/quarto-actions/setup@v2
29
40
 
30
- - name: Render Quarto Project
31
- uses: quarto-dev/quarto-actions/render@v2
32
- with:
33
- path: docs
41
+ - name: Build docs (great-docs; converts the tutorial notebook first)
42
+ run: make docs
34
43
 
35
44
  - name: Upload artifact
36
45
  uses: actions/upload-pages-artifact@v5
37
46
  with:
38
- path: docs/_site
47
+ path: great-docs/_site
48
+ include-hidden-files: true # .well-known/agent-skills/ (great-docs skill discovery)
39
49
 
40
50
  deploy:
41
51
  environment:
@@ -16,6 +16,9 @@ venv/
16
16
  .venv/
17
17
  docs/_site/
18
18
  docs/.quarto/
19
+ # great-docs build directory and the tutorial page `make notebooks` generates
20
+ great-docs/
21
+ docs/06-*.qmd
19
22
  docs/.gitignore
20
23
  3i_atlas.bsp
21
24
 
@@ -24,3 +27,9 @@ docs/.gitignore
24
27
 
25
28
  # Design plans and working notes stay local: never in git, never in a release.
26
29
  Plans/
30
+
31
+ # Design trials and review copies (standing rule: never committed)
32
+ review/
33
+
34
+ # ISA (Claude work record, like Plans/: never committed)
35
+ ISA.md
@@ -7,6 +7,318 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.30.0] - 2026-11-23
11
+
12
+ The version jumps from 0.22.3 to 0.30.0 to mark the CLI redesign: there are
13
+ no 0.23 to 0.29 releases. Everything below landed between 2026-11-19 and
14
+ 2026-11-23 from the CLI review (#41, #43, #45 to #49, #53, #55).
15
+
16
+ ### Changed
17
+
18
+ - **The documentation is built with great-docs** (#53). The API reference is
19
+ generated from the docstrings of the public names (`great-docs.yml`
20
+ `reference:`, kept equal to `spice_kernel_db.__all__` by a test); the
21
+ hand-written `api.qmd` is gone and what it said now lives in those
22
+ docstrings. The guides (motivation, design, usage, CLI, coverage, tutorial,
23
+ troubleshooting) are unchanged in content, and `make docs` / `make serve`
24
+ build and preview the site.
25
+
26
+ ### Added
27
+
28
+ - **A quiet library and a declared public API** (#49, closes #6). Nothing
29
+ under `spice_kernel_db` prints unless it is handed a `rich.console.Console`:
30
+ `KernelDB(console=...)` is where tables, notes, progress bars and the
31
+ download question go, and without one (the default) `get_metakernel`
32
+ answers its own question with no and reports `aborted`. The CLI passes its
33
+ console. Warnings go through the `spice_kernel_db` logger, which the CLI
34
+ routes to stderr (INFO under `--verbose`). `spice_kernel_db.__all__` is
35
+ the public API, listed in `docs/index.qmd` § Public API and held stable
36
+ within a major version, with module-level `get`, `check`, `scan`,
37
+ `register_metakernel`, `resolve_metakernel` and `metakernels_covering`
38
+ that open the configured database per call. `config.py` neither prints
39
+ nor prompts: a corrupt file raises `ConfigError` (the CLI prints the message
40
+ and exits 78, the configuration-error code, instead of falling back to
41
+ setup, which would have overwritten the file), `ensure_config()` with no file
42
+ and no `seed_root` raises it too, and the first-run questions live in the
43
+ CLI. `fetch_metakernel`, `list_remote_metakernels` and
44
+ `resolve_kernel_urls` are no longer exported from the package (they stay
45
+ in `spice_kernel_db.remote`). For a program that mounts the command tree
46
+ under its own CLI, `spice_kernel_db.cli.app`,
47
+ `spice_kernel_db.cli.exit_code(exc)` and
48
+ `spice_kernel_db.cli.logging_to_stderr()` are the host contract
49
+ (planetarypy's `plp spice`).
50
+ - **`check` answers three questions, each with its own exit bit** (#46).
51
+ *present* (every listed kernel on disk, bit 1), *resolves* (every entry
52
+ resolves through `PATH_VALUES` to the file the database knows, bit 2) and
53
+ *matches remote* (sizes, with `--hash` also SHA-256, against the server,
54
+ bit 4, only with `--remote`). The exit code is the sum, so a script can
55
+ tell a missing kernel from a corrupt one, and the output never collapses
56
+ into one tick. `--json` emits the verdicts and their evidence.
57
+ - **`doctor`** reports database health with no metakernel argument: poisoned
58
+ supersession rows, kernel locations whose file is gone, tracked metakernels
59
+ whose file is gone, and the table counts. It exits 1 only on poisoned rows
60
+ (#46).
61
+ - **One resolver for every metakernel argument** (#45). `KernelDB.resolve_metakernel()`
62
+ turns a path, a registry filename, a versionless base name (with or without
63
+ `.tm`) or the source URL into the tracked file, case-insensitively, and every
64
+ command (`check`, `list`, `verify`, `coverage`, `update`, `rewrite`,
65
+ `metakernels`, `resolve --metakernel`) goes through it. A name that matches
66
+ nothing exits 1 with the `get` hint; a name that matches several tracked
67
+ metakernels raises the new `AmbiguousMetakernel`, and the CLI lists them and
68
+ exits 2. The first match is never picked silently. `rewrite` now accepts the
69
+ same forms and offers the picker when the argument is omitted.
70
+ - **Pickers know whether they have a terminal** (#45). With no argument at a
71
+ terminal every picker behaves as before. In a script, a notebook or a pipe
72
+ (stdin not a terminal) the candidates are printed on stderr and the command
73
+ exits 2 instead of blocking on input; stdout stays clean for the caller.
74
+
75
+ - **Poisoned supersession rows are reported** (#31). #29 made the state
76
+ repairable but nothing said it existed: a user saw the same kernels
77
+ re-download on every `update` with no hint why. `KernelDB.poisoned_superseded()`
78
+ lists kernels present on disk yet flagged as superseded by content that
79
+ exists in no location. `check` names them and exits 1 when any are found;
80
+ `stats` shows the count, highlighted when non-zero. Both point at
81
+ `scan <kernel_dir>` as the repair.
82
+
83
+ - **`import <mk-file>` tracks a metakernel that is already on disk** (#47).
84
+ It indexes the entries, registers the kernels the file resolves to that
85
+ exist on disk, and adds the registry row with no source URL. It makes no
86
+ network request. `--mission` overrides the mission guessed from the path.
87
+ The Python entry point is `KernelDB.import_metakernel()`.
88
+ - **`update` walks every tracked metakernel** (#47). It re-fetches each one
89
+ from its source and shows what is missing. It is a dry run by default;
90
+ `--execute` downloads and is the confirmation, so there is no
91
+ per-metakernel prompt. Alias rows (symlinks) are skipped. A source that
92
+ answers 403, 404 or 410, or one that cannot be reached, is noted in the
93
+ summary table and the walk goes on. The Python entry point is
94
+ `KernelDB.update_all()`; `get_metakernel()` and `update_metakernel()` gained
95
+ a `dry_run` parameter for it.
96
+ - **`clean` removes what points at nothing, in three named classes** (#47):
97
+ `--locations` (kernel locations whose file is gone, then kernel rows left
98
+ with no location), `--symlinks` (dangling symlinks under each mission's
99
+ download tree) and `--registry` (tracked metakernels whose source URL
100
+ answers 403, 404 or 410, the only class that contacts the server;
101
+ `--delete-files` also unlinks the `.tm`). Dry run by default, `--execute`
102
+ removes. With no class flag the two local classes run, so a plain `clean`
103
+ now also sweeps dangling symlinks.
104
+ - **`get <name>` re-fetches a tracked metakernel** (#47). When the argument
105
+ names a tracked metakernel, `get` fetches it from its stored source URL,
106
+ downloads what is missing and re-indexes, which is what `update <name>` did.
107
+ A filename that is not tracked is still looked up on the configured mission's
108
+ server.
109
+
110
+ - **Several kernel roots** (#48). `[storage]` in `config.toml` now holds
111
+ `kernel_dirs`, a list in which no root is special. Every root is scanned,
112
+ resolved against (`which`, `check`) and deduplicated across, so `dedup`
113
+ links a kernel in one root to its identical twin in another. A file with only `kernel_dir` loads as
114
+ a one-root list and is rewritten as `kernel_dirs` on the next save.
115
+ - **`config add-root <dir>` and `config remove-root <dir>`** edit the list
116
+ (#48). `add-root` creates the directory and does not add a root twice;
117
+ `remove-root` refuses the last root and leaves files and database rows alone.
118
+ `skd config` lists the roots.
119
+ - **`scan` takes an optional directory** (#48). With none it scans every
120
+ configured kernel root.
121
+ - **Where a download lands is derived, never configured.** `get` re-fetches
122
+ a tracked metakernel into the root that holds it, puts a new metakernel
123
+ into the one root that already holds its mission, and with one root uses
124
+ that root. Only when several roots could take a new mission does it list
125
+ them and ask at a terminal (exit 2 in a script); `--download-dir` names
126
+ the root explicitly. `scan --archive` moves each file into its own root or
127
+ its mission's root, settling every file before anything moves. `update`
128
+ (the all-metakernels walk) and `update_all()` lose `--download-dir`, which
129
+ would have forced metakernels from every root into one directory.
130
+ `KernelDB.root_for(mission, mk_path)` is the one resolver and
131
+ `AmbiguousKernelRoot` the exception. Before this, the first configured
132
+ root was a "download target", which would have written a re-fetched
133
+ second-root metakernel into the first root.
134
+ - **`import --unofficial` and the `official` column** (#48). A metakernel
135
+ assembled locally, such as a subsetter's output or planetarypy's
136
+ `archived_kernels.py`, can be marked as not published by an archive.
137
+ `metakernel_registry` gains `official BOOLEAN DEFAULT TRUE`, added when an
138
+ older database is first opened for writing; opened read-only before that
139
+ (`ls`, `show`, `doctor`, `check`), every row reads as official. `ls` appends `unofficial` to the name and `show`
140
+ prints `Official: no`. `RegistryRow`, `list_metakernels()` and
141
+ `info_metakernel()` carry `official`, and
142
+ `import_metakernel(path, mission=None, official=True)` sets it.
143
+ - **Python functions for the roots** (#48): `kernel_roots()`,
144
+ `add_root(dir)` and `remove_root(dir)`, exported from the
145
+ package, and `ensure_config(seed_root=...)`, which writes a first
146
+ configuration with that root instead of prompting. An existing configuration
147
+ is never changed by the seed. `Config(db_path, kernel_dirs)` holds the
148
+ list; the single-root `kernel_dir` parameter and property are gone.
149
+ `KernelDB(kernel_roots=...)` and `db.kernel_roots` carry the roots used to
150
+ guess a mission, and `db.scan_roots()` scans every one.
151
+
152
+ ### Changed
153
+
154
+ - **`verify` folded into `check`** (#46). `verify` stays as a hidden alias
155
+ (`--deep` is `--hash`, `--strict` is ignored with a note) and its `--json`
156
+ document now has the three-verdict shape. `check --full` is gone; the
157
+ server comparison is `check --remote`, and `--hash` no longer needs it. The
158
+ poisoned-row report moved from `check` to `doctor`, so `check` exits 1 for
159
+ a missing kernel and nothing else. `KernelDB.check_metakernel()` prints
160
+ nothing and no longer contacts the server; the newer-version notice is part
161
+ of `--remote`, and `KernelDB.check_report()` returns the three verdicts as
162
+ data.
163
+
164
+ - **`KernelDB.info_metakernel()` and `update_metakernel()` raise `MetakernelNotTracked`**
165
+ for an unknown name instead of printing "not found" or raising a bare
166
+ `LookupError`; the CLI maps that to exit 1 in one place (#45).
167
+
168
+ - **`mk --remove` no longer matches a bare prefix**; it takes the same forms as
169
+ every other command, so a prefix matching several rows is reported instead of
170
+ removing the first one (#45).
171
+
172
+ - **`skd --version` and `--help` start faster** (#26). `requests`, `duckdb`,
173
+ `importlib.metadata` and Typer's rich error formatter are now imported
174
+ where they are used instead of at module level, so invocations that open
175
+ no database and touch no network no longer pay for them. On the
176
+ reference machine `--version` went from 184 ms to 123 ms and `--help`
177
+ from 187 ms to 141 ms. `spice_kernel_db.__version__` is resolved on
178
+ first access; everything else in the public API is unchanged.
179
+
180
+ - **The verbs were renamed and regrouped** (#47). `--help` now shows four
181
+ panels in order: acquire (`browse`, `get`, `update`), inspect (`ls`, `show`,
182
+ `which`, `coverage`, `stats`, `check`, `doctor`), maintain (`scan`,
183
+ `import`, `rewrite`, `rm`, `clean`, `dedup`, `reset`) and configure
184
+ (`mission`, `config`). `browse`, `coverage`, `rewrite`, `dedup`, `mission`
185
+ and `config` keep their names.
186
+ - **`metakernels` and `mk` became `ls [mission]`**, the listing of tracked
187
+ metakernels. The `--mission` option is now the optional argument.
188
+ - **`list` and `metakernels <name>` became `show <mk>`**: the registry row
189
+ (mission, source, acquired, local path) plus the kernels with type, size
190
+ and status. `--type` filters the table. On a `.tm` that is not tracked it
191
+ lists the kernels and says `skd import` tracks it.
192
+ - **`resolve` and `aliases` became `which <kernel>`**. The first line is the
193
+ local path. When the content is known under several filenames, the alias
194
+ table and the on-disk locations follow. It accepts a filename or a SHA-256
195
+ prefix. `--metakernel <mk>` resolves every kernel of a metakernel. With no
196
+ argument at a terminal it offers a picker over the deduplicated kernels.
197
+ - **`duplicates` was folded into `stats`**: the database statistics come
198
+ first, then the duplicate kernels section.
199
+ - **`metakernels --remove` became `rm <mk>`**. It removes the registry row
200
+ and its entries; the file stays. With no argument at a terminal it offers
201
+ a picker.
202
+ - **`prune` became `clean`** with the classes named `--locations`,
203
+ `--symlinks` (was `--orphan-symlinks`) and `--registry` (was
204
+ `--metakernels`). The three classes can now be combined in one run.
205
+ - **`update <name>` became `get <name>`**, and `update` with no argument
206
+ became the walk over all tracked metakernels, a dry run unless
207
+ `--execute` is given. `update` with an argument prints
208
+ `note: 'update <name>' is now 'get <name>'` and runs `get`.
209
+ - **`reset` moved from the configure panel to the maintain panel.** The
210
+ command is unchanged.
211
+ - **`scan` never prompts** (#47). A mission that is not configured and has
212
+ no `.spice-server` marker no longer starts a setup dialog. `scan` prints
213
+ the `skd mission add <NAME> --server-url <URL>` command instead, so it is
214
+ safe in a script.
215
+ - **`KernelDB.info_metakernel()` takes `kernel_type=None`** to limit the
216
+ printed kernel table to one type (#47).
217
+
218
+ ### Deprecated
219
+
220
+ - **The old verb names remain as hidden aliases and are removed in 1.0**
221
+ (#47). Each prints `note: 'old' is now 'new'` on stderr, then runs the new
222
+ command with the new command's options: `list` is `show`; `metakernels`
223
+ and `mk` are `ls`, and with a name `show`, and with `--remove` `rm`;
224
+ `resolve` and `aliases` are `which`; `duplicates` is `stats`; `prune` is
225
+ `clean` (`--metakernels` and `--mk` are `--registry`, `--orphan-symlinks`
226
+ is `--symlinks`, and a plain `prune` keeps its old meaning of locations
227
+ only); `verify` is `check` (`--deep` is `--hash`); `update <name>` is
228
+ `get <name>`.
229
+
230
+ ### Fixed
231
+
232
+ - A re-scan of a directory holding a metakernel that `get` had fetched
233
+ replaced its registry row, dropping the source URL and the acquisition
234
+ time, so a later `update` reported it as added by scan with no source. A
235
+ scan now writes a registry row only for a metakernel it sees for the first
236
+ time; `get` and `import` still replace the row (found while removing the
237
+ download target, 2026-11-21).
238
+ - **A tracked metakernel's mission comes from the registry, and `guess_mission`
239
+ knows the kernel roots** (#43, #48). A metakernel in the default store
240
+ (`~/.local/share/spice-kernel-db/kernels/JUICE/mk/x.tm`) got the mission
241
+ `SPICE-KERNEL-DB`, the directory that holds the store, and `check` then
242
+ reported `Cross-mission: 102 kernels`. `check`, `rewrite`, `coverage` and the
243
+ server comparison now read a tracked metakernel's mission from its registry
244
+ row. `guess_mission(filepath, roots=None)` takes the first directory below a
245
+ configured root as the mission, classifies a file under a root but in no
246
+ mission directory from its filename alone, and applies the old heuristic only
247
+ outside every root. `scan` and `import` pass the configured roots. A `scan`
248
+ that meets an already tracked metakernel keeps the mission and `official`
249
+ flag of its row; `get` and `import` state them.
250
+ - **`doctor` lists a path registered under more than one hash, and `scan`
251
+ repairs it** (#48). One file could carry two `locations` rows, such as a
252
+ 0-byte row from an interrupted download beside the real one, and `check`
253
+ then reported `SIZE_MISMATCH` against the wrong row (`!= expected 0`).
254
+ `KernelDB.doctor()` returns the paths as `conflicting_locations` and the CLI
255
+ prints them; the exit code is unchanged. `register_file` used to supersede
256
+ one stale row at a path. It now supersedes all of them, so a `scan` of the
257
+ directory keeps the row that matches the file on disk.
258
+ - **`check` no longer reports `AMBIGUOUS` for a registered path whose filename
259
+ exists elsewhere with other content** (#48). When an entry resolves to a path
260
+ (or to the file its symlink leads to) that is a registered location, that
261
+ row's size and hash are the expectation. Only an unregistered path falls back
262
+ to the filename, where several active `kernels` rows are still `AMBIGUOUS`.
263
+ Three different `naif0012.tls` across two stores no longer fail the check.
264
+ - **`verify` and `list` crashed on a registry filename that `check` accepted**
265
+ (#41). Both handed the bare name to the parser and died with
266
+ `FileNotFoundError`; they now resolve it like `check` does.
267
+
268
+ - **`get -v` no longer crashes** (#39). The verbose "Resolved URLs" listing
269
+ in `get_metakernel()` read a name that did not exist, so every verbose
270
+ `get` ended in a `NameError` after the kernel table. Found by ruff's
271
+ undefined-name check; a test now exercises the branch.
272
+ - **Broad `except Exception` handlers no longer hide defects** (#33). 21
273
+ handlers caught everything and reported something plausible; one had
274
+ already turned a `TypeError` in `verify_against_server()` into "could not
275
+ fetch". Each now names what the call site raises: `duckdb.IOException` for
276
+ the connect retry, `duckdb.CatalogException` for the startup
277
+ case-duplicate check, `OSError` / `http.client.HTTPException` on network
278
+ paths, `requests.RequestException` for the size HEAD, `SpiceyError` around
279
+ spiceypy. Two dead `except Exception: raise` lines are gone. The four that
280
+ stay broad (two atomic-write cleanups, two transaction rollbacks) all
281
+ re-raise and say so in a comment.
282
+
283
+ Narrowing exposed what the issue predicted: 25 unit tests had been
284
+ reaching the real network through the size lookup and `check`'s
285
+ staleness probe, and the offline guard's exception was being swallowed.
286
+ Those tests now mock both, the `remote_sizes` fixture patches the binding
287
+ `db.py` actually uses, and the guard exception is a `BaseException` so no
288
+ handler can hide it again.
289
+ - **The test suite can no longer overwrite the user's `config.toml`** (#28).
290
+ `test_config_set` kept the real `save_config` away only by patching it by
291
+ name; when the Typer port moved the import site the patch missed and
292
+ `~/.config/spice-kernel-db/config.toml` was replaced with a test's tmp
293
+ paths, breaking every later `skd` call. An autouse fixture now points
294
+ `HOME`, `CONFIG_DIR` and `CONFIG_FILE` at an empty directory for every
295
+ test, and a session guard fails the run if the real config changed anyway.
296
+
297
+ ## [0.22.3] - 2026-10-26
298
+
299
+ ### Fixed
300
+
301
+ - **A kernel marked superseded now recovers when its file is present** (#29).
302
+ `superseded_by` had exactly one writer and it only ever SET the column, so
303
+ the state was unrecoverable. Whenever anything wrote non-kernel content to a
304
+ tracked path -- a pre-0.17.0 interrupted download, a Dropbox conflict copy,
305
+ an editor -- the real kernel's hash was marked superseded by that junk.
306
+ Restoring the file marked the junk superseded in turn, leaving *both* rows
307
+ flagged, and `find_by_filename()` excludes superseded rows. So `resolve`
308
+ reported "not found" for a byte-perfect file on disk,
309
+ `_should_skip_download()` saw no `db_hash`, and every `update` re-downloaded
310
+ the same kernel forever. Observed on a real install where `pck00011.tpc` and
311
+ `earthstns_fx_201023.bsp` re-downloaded on every run.
312
+
313
+ `register_file()` now clears the flag when the superseding content exists in
314
+ **no live location**. The condition is narrow on purpose: a genuine upstream
315
+ update whose newer file is on disk keeps its supersession, so `resolve` can
316
+ never start handing back a real older release. Content that supersedes
317
+ nothing findable was never a version, only damage.
318
+
319
+ This makes **`scan` the repair path** for an already-damaged database: one
320
+ pass over the kernel tree heals every poisoned row.
321
+
10
322
  ## [0.22.2] - 2026-10-26
11
323
 
12
324
  ### Fixed
@@ -1108,6 +1420,9 @@ spice-kernel-db check <your-metakernel.tm>
1108
1420
  reference)
1109
1421
  - Comprehensive test suite (30 tests)
1110
1422
 
1423
+ [Unreleased]: https://github.com/michaelaye/spice-kernel-db/compare/v0.30.0...HEAD
1424
+ [0.30.0]: https://github.com/michaelaye/spice-kernel-db/compare/v0.22.3...v0.30.0
1425
+ [0.22.3]: https://github.com/michaelaye/spice-kernel-db/compare/v0.22.2...v0.22.3
1111
1426
  [0.22.2]: https://github.com/michaelaye/spice-kernel-db/compare/v0.22.1...v0.22.2
1112
1427
  [0.22.1]: https://github.com/michaelaye/spice-kernel-db/compare/v0.22.0...v0.22.1
1113
1428
  [0.22.0]: https://github.com/michaelaye/spice-kernel-db/compare/v0.21.0...v0.22.0
@@ -15,7 +15,7 @@ authors:
15
15
  repository-code: https://github.com/michaelaye/spice-kernel-db
16
16
  url: https://michaelaye.github.io/spice-kernel-db
17
17
  license: MIT
18
- version: 0.22.2
18
+ version: 0.30.0
19
19
  date-released: "2026-10-26"
20
20
  keywords:
21
21
  - SPICE
@@ -0,0 +1,133 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Commands
6
+
7
+ ```bash
8
+ # Install in development mode
9
+ pip install -e ".[dev]"
10
+
11
+ # Run full test suite
12
+ pytest tests/
13
+
14
+ # Run a single test class or test
15
+ pytest tests/test_kernel_db.py::TestResolveKernel
16
+ pytest tests/test_kernel_db.py::TestResolveKernel::test_exact_match_preferred_mission
17
+
18
+ # Build / preview the documentation (great-docs: generated API reference + docs/ guide)
19
+ make docs
20
+ make serve
21
+ ```
22
+
23
+ There is no linter or formatter configured. CI runs pytest across Python 3.11–3.14; the publish workflow builds the site with great-docs and deploys it to GitHub Pages (chained after CI passes). The API reference is generated from docstrings (numpy style) for the names in `great-docs.yml` `reference:`, which `tests/test_api.py` keeps equal to `spice_kernel_db.__all__`; the guide pages are the numbered `docs/*.qmd` files, the tutorial notebook in `notebooks/` is converted by `make notebooks`.
24
+
25
+ ## Architecture
26
+
27
+ Content-addressed SPICE kernel database. Every kernel file is identified by its SHA-256 hash, not its filename. Multiple filesystem locations (across missions) can reference the same hash, enabling deduplication and cross-mission reuse.
28
+
29
+ ### DuckDB Schema (6 tables)
30
+
31
+ - **`kernels`** — unique file content: `(sha256 PK, filename, kernel_type, size_bytes)`
32
+ - **`locations`** — where files live on disk: `(sha256 + abs_path PK, mission, source_url, scanned_at)` → references `kernels`
33
+ - **`metakernel_entries`** — kernel entries within a `.tm` file: `(mk_path + entry_index PK, raw_entry, filename)`
34
+ - **`metakernel_registry`** — tracked metakernel files: `(mk_path PK, mission, source_url, filename, acquired_at, official)`; `official` is FALSE for a metakernel assembled locally (`import --unofficial`), and a tracked metakernel's mission is read from this row, never guessed from its path
35
+ - **`missions`** — configured missions: `(name PK, server_url, mk_dir_url, dedup, added_at)`
36
+ - **`kernel_coverage`** — cached SPK body coverage intervals: `(sha256 + body_id PK, et_start, et_end, source)`
37
+
38
+ ### Module Responsibilities
39
+
40
+ | Module | Role |
41
+ |--------|------|
42
+ | `db.py` | `KernelDB` class — all DB operations, scanning, resolution, metakernel rewriting, get, browse. Writes only to the `console` it was given (none by default: library use is silent, #49); warnings go to the `spice_kernel_db` logger |
43
+ | `parser.py` | `ParsedMetakernel` dataclass; parse/write `.tm` files; symbol resolution |
44
+ | `hashing.py` | `sha256_file()`, `classify_kernel()` (extension→type), `guess_mission(filepath, roots=None)` (path heuristic; the first directory below a configured kernel root wins) |
45
+ | `remote.py` | Network operations: fetch metakernels, resolve URLs, parallel HEAD/download with rich.progress |
46
+ | `config.py` | `Config` (`kernel_dirs`, the list of kernel roots; no root is special, `KernelDB.root_for` derives where a download lands), TOML persistence at `~/.config/spice-kernel-db/config.toml`, `kernel_roots()` / `add_root()` / `remove_root()`; raises `ConfigError`, never prints or prompts |
47
+ | `api.py` | Module-level `get`, `check`, `scan`, `register_metakernel`, `resolve_metakernel`, `metakernels_covering`: one call against the configured database; `__init__.py`'s `__all__` is the public API (#49), mirrored in `docs/index.qmd` § Public API and in `great-docs.yml` `reference:`, both checked by `tests/test_api.py` |
48
+ | `cli/` | Typer CLI, one module per help panel: `browse.py` (browse, get, update), `inspect_cmds.py` (ls, show, which, coverage, stats, check, doctor, plus the hidden aliases list, metakernels/mk, resolve, aliases, duplicates, verify), `transform.py` (scan, import, rewrite, rm, clean, dedup, and the hidden prune), `configure.py` (mission, config, reset); `prompts.py` holds the shared interactive pickers, `_app.py` the `app` object and per-invocation state, `__init__.py` the root options and `main()` |
49
+
50
+ ### Key Design Decisions
51
+
52
+ **Mission-aware resolution** (`resolve_kernel`) uses a 3-step fallback:
53
+ 1. Exact filename in preferred mission
54
+ 2. Exact filename in any mission
55
+ 3. Path-suffix match (file exists on disk under a different canonical name)
56
+
57
+ Each fallback step emits a warning. Fuzzy prefix matching was removed in v0.10.0 due to silent data corruption risk.
58
+
59
+ Steps 1 and 2 go through `find_by_filename`, which joins on `sha256`, so identical content under two names produces one `kernels` row and a `locations` row per name — and either name matches both. `_prefer_exact_name` puts the location actually named `filename` first, so a name always resolves to its own file; the differently-named copy is used only when nothing of that name is registered, with a warning (issue #9).
60
+
61
+ **Metakernel rewriting** only modifies `PATH_VALUES` — the header, `PATH_SYMBOLS`, `KERNELS_TO_LOAD`, and all comments are preserved verbatim. A symlink tree bridges between where the metakernel expects files and where they actually live.
62
+
63
+ **Remote browsing** parses Apache `mod_autoindex` HTML directory listings. Version tags like `_v461_20251127_001` are stripped to group versioned snapshots under their base metakernel name.
64
+
65
+ **Case-insensitive fuzzy matching** — all mission name lookups (get, browse, ls, mission remove) use case-insensitive prefix matching. `get_mission()` resolves via the `missions` table; SQL queries on `metakernel_registry` use `LOWER(mission) LIKE LOWER(?) || '%'` directly.
66
+
67
+ **Output formatting** uses `rich` throughout — `rich.Table` and `rich.Panel` for all tabular output, `rich.progress.Progress` for download and query progress bars (thread-safe with `ThreadPoolExecutor`).
68
+
69
+ ## Development rules
70
+
71
+ **Docs ship with the feature, not after.** Every new CLI subcommand, every new flag on an existing subcommand, every new public method on `KernelDB`, and every new behavior visible to the user (new error class, new exit code, new output format) must land in the same change as the corresponding documentation update. Concretely:
72
+
73
+ - New or changed CLI subcommand → entry in `docs/04-cli.qmd` (table of options + at least one example).
74
+ - New CLI flag → row added to the relevant subcommand's options table in `docs/04-cli.qmd`.
75
+ - New public name (`__init__.py` export) → a numpy docstring that says everything a user needs, and an entry under `reference:` in `great-docs.yml` (the test fails otherwise). A new `KernelDB` method needs only the docstring.
76
+ - New user-visible error or recovery path → entry in `docs/07-troubleshooting.qmd`.
77
+ - New feature → `CHANGELOG.md` entry under the unreleased section (or current dev version).
78
+
79
+ A pull request that adds features without updating docs is incomplete. If you spot an existing gap while doing other work, fix it in the same change rather than filing a TODO.
80
+
81
+ **Issue fixes go straight to `main`.** No feature branch or pull request is needed for work on a tracked issue; commit on `main` with `Closes #N` and push (Michael, 2026-10-28).
82
+
83
+ ## Testing Patterns
84
+
85
+ Tests use `pytest-tmp-files` for temporary directory fixtures. The main fixture `tmp_spice_tree` creates a realistic multi-mission SPICE directory tree with known duplicates. Network operations are mocked with `unittest.mock.patch`. Metakernel content is written as multi-line strings in tests.
86
+
87
+ ## Release Process
88
+
89
+ **IMPORTANT: Always update the changelog when bumping the version. Never commit a version bump without a corresponding changelog entry.**
90
+
91
+ The version string lives in **three** places and all three move together:
92
+ `pyproject.toml`, `conda/recipe.yaml` (`context.version`) and `CITATION.cff`.
93
+
94
+ 1. Commit all changes with descriptive messages
95
+ 2. Update the version in all three files above (minor for features, patch for fixes)
96
+ 3. Add entry to `CHANGELOG.md` (Keep a Changelog format) with comparison link at bottom
97
+ 4. Commit as "Bump version to X.Y.Z: brief description"
98
+ 5. Push to GitHub: `git push`
99
+ 6. Publish to PyPI: `rm -rf dist/ && python -m build && python -m twine upload dist/*`
100
+ 7. Create GitHub release: `gh release create vX.Y.Z --title "vX.Y.Z" --notes-file <file> --verify-tag`
101
+ 8. Put the **published** sdist's sha256 in `conda/recipe.yaml`, then build:
102
+ ```bash
103
+ curl -s https://pypi.org/pypi/spice-kernel-db/X.Y.Z/json \
104
+ | jq -r '.urls[] | select(.packagetype=="sdist") | .digests.sha256'
105
+ rattler-build build --recipe conda/recipe.yaml -c conda-forge --output-dir /tmp/skd-conda-out
106
+ ```
107
+ 9. Upload to anaconda.org:
108
+ ```bash
109
+ export ANACONDA_API_KEY=<token>
110
+ rattler-build upload anaconda -o michaelaye /tmp/skd-conda-out/noarch/spice-kernel-db-X.Y.Z-*.conda
111
+ ```
112
+
113
+ **Notes:**
114
+ - **Tag before building any artefact, and build from the tag.** A 0.22.x lesson:
115
+ the Typer port sat on `main` under the already-released 0.22.0 version string,
116
+ so a build from `main` would have published something the tag and the Zenodo
117
+ record did not describe. 0.22.1 then shipped a tag containing a stray build
118
+ directory that `git add -A` swept in. Check `git status` and the sdist's
119
+ contents before uploading, not after.
120
+ - **`rattler-build` replaced `conda-build` here** (2026-10-26). It is a
121
+ standalone Rust binary with no Python or conda-build dependency, so nothing
122
+ has to live in `base` or in a work env. Installed via
123
+ `pixi global install rattler-build`, landing in `~/.pixi/bin`. The recipe is
124
+ `conda/recipe.yaml` in the v1 format (CEP 13/14); the old
125
+ `conda/meta.yaml` and the `grayskull`/`anaconda-client` steps are gone.
126
+ - The v1 format is also conda-forge's direction, so the recipe should mostly
127
+ carry over if this ever moves to conda-forge. As of early 2026 conda-forge
128
+ still accepts both formats.
129
+ - conda-forge calls the DuckDB bindings **`python-duckdb`**, while
130
+ `pyproject.toml` asks for `duckdb`. The recipe must use the conda name.
131
+ - The recipe's tests exercise **both console scripts plus `--version`**. 0.22.0
132
+ moved the CLI to Typer, and an import-only test would not notice an entry
133
+ point breaking.
@@ -0,0 +1,25 @@
1
+ .PHONY: install test notebooks docs serve clean
2
+
3
+ install:
4
+ pip install -e ".[dev,docs]"
5
+
6
+ test:
7
+ pytest
8
+
9
+ # great-docs renders .qmd, not .ipynb: the tutorial is converted first. Its own
10
+ # front matter carries `execute: enabled: false` (it shells out to NAIF and never
11
+ # stored outputs), so the page shows the commands unrun.
12
+ notebooks:
13
+ @for nb in notebooks/*.ipynb; do \
14
+ [ -e "$$nb" ] || continue; \
15
+ quarto convert "$$nb" --output "docs/06-$$(basename "$${nb%.ipynb}").qmd"; \
16
+ done
17
+
18
+ docs: notebooks
19
+ great-docs build
20
+
21
+ serve: notebooks
22
+ great-docs preview
23
+
24
+ clean:
25
+ rm -rf dist build *.egg-info great-docs/ docs/06-*.qmd
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: spice-kernel-db
3
- Version: 0.22.2
3
+ Version: 0.30.0
4
4
  Summary: Browse, get, and manage SPICE kernels and metakernels across NASA and ESA mission archives
5
5
  Project-URL: Homepage, https://github.com/michaelaye/spice-kernel-db
6
6
  Project-URL: Repository, https://github.com/michaelaye/spice-kernel-db
@@ -22,6 +22,9 @@ Requires-Dist: typer>=0.27
22
22
  Provides-Extra: dev
23
23
  Requires-Dist: pytest-tmp-files>=0.0.2; extra == 'dev'
24
24
  Requires-Dist: pytest>=7; extra == 'dev'
25
+ Provides-Extra: docs
26
+ Requires-Dist: great-docs>=0.17; extra == 'docs'
27
+ Requires-Dist: jupyter; extra == 'docs'
25
28
  Provides-Extra: spice
26
29
  Requires-Dist: spiceypy>=6.0; extra == 'spice'
27
30
  Description-Content-Type: text/markdown
@@ -39,8 +42,9 @@ Browse, get, and manage SPICE kernels and metakernels across NASA and ESA missio
39
42
  > who used `spice-kernel-db get` or `spice-kernel-db update` are affected**,
40
43
  > regardless of the dedup setting — the symlink creation code did not honor the
41
44
  > per-mission dedup flag (also fixed in 0.10.0). Users who only used `scan` and
42
- > `resolve` are not affected. After updating, remove all symlinks in your kernel
43
- > directories and re-run `spice-kernel-db update`. See [CHANGELOG.md](CHANGELOG.md)
45
+ > single-kernel lookup (`which` today) are not affected. After updating,
46
+ > remove all symlinks in your kernel directories and re-run
47
+ > `spice-kernel-db update --execute`. See [CHANGELOG.md](https://github.com/michaelaye/spice-kernel-db/blob/main/CHANGELOG.md)
44
48
  > for recovery steps.
45
49
 
46
50
  ## What this tool does
@@ -11,8 +11,9 @@ Browse, get, and manage SPICE kernels and metakernels across NASA and ESA missio
11
11
  > who used `spice-kernel-db get` or `spice-kernel-db update` are affected**,
12
12
  > regardless of the dedup setting — the symlink creation code did not honor the
13
13
  > per-mission dedup flag (also fixed in 0.10.0). Users who only used `scan` and
14
- > `resolve` are not affected. After updating, remove all symlinks in your kernel
15
- > directories and re-run `spice-kernel-db update`. See [CHANGELOG.md](CHANGELOG.md)
14
+ > single-kernel lookup (`which` today) are not affected. After updating,
15
+ > remove all symlinks in your kernel directories and re-run
16
+ > `spice-kernel-db update --execute`. See [CHANGELOG.md](https://github.com/michaelaye/spice-kernel-db/blob/main/CHANGELOG.md)
16
17
  > for recovery steps.
17
18
 
18
19
  ## What this tool does