#198 Catalog retains stale source-file entries when extension version drops a file; no native prune/repair
Opened by stack72 · 5/1/2026
Summary
.swamp/_extension_catalog.db accumulates rows for source files that an extension removes in a later version. The stale rows continue to participate in model-type resolution and produce intermittent runtime failures ("No such file or directory: .../fetch_kubeconfig.js") and silently-wrong behavior (the older bundle path's logic runs instead of the newer one).
There is no native command to prune the catalog short of swamp extension rm <name> + swamp extension pull <name>, which is heavy-handed and prompts for destructive confirmation. swamp doctor extensions passes ("5 passed, 0 failed — OVERALL: PASS") even though the catalog points at non-existent files.
Reproduction (real, just hit this)
- Pull
@hivemq/harvester/[email protected]— this version ships two files:kubeconfig.tsandfetch_kubeconfig.ts. Both get rows inbundle_typeskeyed by source path. swamp extension update '@hivemq/harvester/kubeconfig'upgrades to2026.05.01.38— this version dropsfetch_kubeconfig.ts(logic merged back intokubeconfig.ts). The pulled-extensions directory is rewritten without that file. Bundle dir is rewritten withoutfetch_kubeconfig.js.bundle_typesstill has both rows:
('.../kubeconfig.ts', '@hivemq/harvester/kubeconfig', 'model', '.../bundles/738c72f8/harvester/kubeconfig.js', '2026.05.01.38', ...)
('.../fetch_kubeconfig.ts', '@hivemq/harvester/kubeconfig', 'model', '.../bundles/738c72f8/harvester/fetch_kubeconfig.js', '2026.04.21.3', ...)The second source path no longer exists on disk, and its bundle_path no longer exists either.
- Running
swamp model method run <kubeconfig-model> fetchnon-deterministically picks one of the two rows. Symptoms:- sometimes:
FTL error Method execution failed: No such file or directory (os error 2): readfile '.../bundles/738c72f8/harvester/fetch_kubeconfig.js' - sometimes: silently runs the v2026.04.21.3 code path (we confirmed this by log-message text — the older bundle's log line
Renaming context '{from}' → '{to}'was emitted even though the on-disk bundle for v2026.05.01.38 saysRenaming context/cluster/user to '{to}').
- sometimes:
swamp doctor extensionsreports OVERALL: PASS while this is happening.
Why this matters
It looks exactly like a bug in the extension's own logic (the merge of two bundles produces wrong output), so users (and agents) chase the wrong root cause. In our session this consumed ~30 minutes of debugging and led an agent to do rm -rf .swamp/bundles && rm .swamp/_extension_catalog.db* cache surgery before finding the right answer.
Asks (any subset)
swamp extension pull/updateshould prunebundle_typesrows whosesource_pathis not in the freshly-extracted set for the same extension. A version transition that drops a source file is a normal, valid operation; the catalog needs to follow.swamp doctor extensionsshould detect orphan catalog rows — e.g.,bundle_pathdoes not exist on disk, orsource_pathdoes not exist on disk. Surface them as warnings/failures with a one-line repair hint.- Add a native prune command, e.g.
swamp extension reindex <name>orswamp extension repair, that deletes catalog rows for missing files and rebuilds from the pulled-extensions directory tree, without removing the extension. - (Stretch) Make resolution deterministic when multiple rows exist for the same
(type, kind)— pick the one whosebundle_pathexists, or error loudly with a fix-it message instead of silently selecting the broken row.
Environment
- swamp
20260501.010449.0-sha.c24fb601 - Catalog db schema:
bundle_meta(key, value),bundle_types(source_path, type_normalized, kind, bundle_path, version, description, extends_type, source_mtime, source_fingerprint)
Related
- systeminit/swamp#1271 — "Document and surface a native cache-refresh path so agents stop doing cache surgery". This issue is the root cause that motivates that one: agents reach for
rm -rfbecause no native repair exists. - hivemq/swamp-extensions#55 — the bug we were trying to verify a fix for; the stale catalog row made it look like the fix had not landed.
Automoved by swampadmin from https://github.com/systeminit/swamp/issues/1272
Closed
No activity in this phase yet.
Sign in to post a ripple.