Skip to main content
← Back to list
01Issue
BugShippedSwamp CLI
Assigneesstack72

#392 swamp extension rm leaves empty <kind>-bundles/<hash>/ dirs behind

Opened by keeb · 5/20/2026· Shipped 5/21/2026

Summary

Sibling finding to swamp-club#383. After swamp extension rm <name> --force of an extension that does NOT ship vaults / drivers / datastores / reports, the per-kind bundle namespace dirs at the repo root level remain on disk:

  • .swamp/vault-bundles/<hash>/ (empty)
  • .swamp/driver-bundles/<hash>/ (empty)
  • .swamp/datastore-bundles/<hash>/ (empty)
  • .swamp/report-bundles/<hash>/ (empty)

.swamp/bundles/<hash>/ (the models bundle namespace) cleans up correctly because the extension ships at least one compiled model JS, so the dir is populated → tracked → pruned via its parentDir.

Reproduction

mkdir /tmp/swamp-bundle-leak && cd /tmp/swamp-bundle-leak
swamp repo init
swamp extension pull @alvagante/docker-image-test    # ships only models + files
swamp extension rm @alvagante/docker-image-test --force
ls .swamp/
# vault-bundles/  driver-bundles/  datastore-bundles/  report-bundles/  ← still there
ls .swamp/vault-bundles/
# 0023d933/  ← empty hash dir

Expected

rm removes the <hash>/ namespace dir under each <kind>-bundles/ that was scaffolded for the removed extension. If that empties the parent .swamp/<kind>-bundles/ entirely (no other extensions), prune that too.

Actual

The empty <hash>/ namespace dirs are left behind. Verified against current main with the swamp-club#383 fix applied (which only addresses the per-extension subtree under .swamp/pulled-extensions/<scope>/<name>/).

Root cause

src/libswamp/extensions/pull.ts:898, 914, 930, 946 unconditionally Deno.mkdir the four bundle namespace dirs (vault-bundles/<hash>/, driver-bundles/<hash>/, datastore-bundles/<hash>/, report-bundles/<hash>/) regardless of whether the extension ships that bundle kind. When the source archive has no <kind>-bundles/ directory, copyDir returns an empty file list and nothing is recorded as tracked. RemoveExtensionService never sees these paths in parentDirs, so pruneEmptyDirs never visits them.

This is the same shape of bug as swamp-club#383 but for top-level bundle dirs rather than per-extension scaffolds. The fix for #383 (push known scaffold paths into parentDirs) is the per-extension fix; a parallel push for bundle namespaces would close this.

Suggested fix

Mirror the #383 approach: have RemoveExtensionService.execute() compute the four <kind>-bundles/<hash>/ paths for the removed extension (using bundleNamespace(<absoluteKindDir>, repoDir) the same way pull.ts does) and push them into parentDirs. The existing pruneEmptyDirs walk handles the rest.

Alternative: lazy-mkdir in pull (only create bundle namespace dirs when there's a bundle file to copy). This is also the deferred follow-up noted for the #383 fix.

Environment

  • swamp 20260206.200442.0-sha. (dev build with swamp-club#383 fix locally applied)
  • Linux 6.19.13-arch1-1, zsh
02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 2 MOREREVIEW+ 3 MOREPR_MERGED+ 1 MORENOTIFICATION_SKIPPED

Shipped

5/21/2026, 4:44:38 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack725/21/2026, 11:41:53 AM

Sign in to post a ripple.