Skip to content

feat: suit off cleans up injected components (+ --keep-injected)#73

Merged
danmestas merged 1 commit into
mainfrom
feat/inject-off-cleanup
May 25, 2026
Merged

feat: suit off cleans up injected components (+ --keep-injected)#73
danmestas merged 1 commit into
mainfrom
feat/inject-off-cleanup

Conversation

@danmestas

Copy link
Copy Markdown
Owner

Increment 2 of suit inject (follows #66). Closes the inject lifecycle: you could inject a component but not cleanly remove it.

The bug

suit off iterated only the up-applied files[] then deleted the lockfile — orphaning any inject-recorded files on disk. Fatal for an inject-only lockfile (files: [], injected: [...]), which is exactly what suit inject creates when a worker was launched via stateless prepare.

Fix

  • Extracted detectDrift() + removeTrackedFile() + a shared RemovalState so up-applied and injected files flow through one removal contract (drift scan, additive marker-block strip, replace unlink, empty-dir prune, tallies). No copy-paste.
  • Default suit off now removes injected files too, then deletes the lockfile.
  • --keep-injected: removes only the up-applied files, leaves injected files on disk, and rewrites (rather than deletes) the lockfile with files: [] + reset resolution + the injected list preserved. Degrades to a normal full off when there are no injected entries.
  • suit off now accepts --project/--home <dir> (was cwd-only), matching the current parsing added in feat: suit inject — realtime component injection (proposal + increment 1) #66 — needed because inject targets a worker home, not cwd.

Verification

  • npm run typecheck, npm run build, npm test625 tests pass (+7 new: both up+injected, inject-only orphan fix, injected drift refuse/force, additive strip, additive empty-delete, keep-injected, keep-injected-without-injected).
  • Live lifecycle smoke: inject philosophy (174 files) → off --keep-injected (removes 0 up, keeps 173 injected, lockfile retained) → off (removes 173 injected, lockfile gone, 0 files left — no orphans).

Next increments (deferred, per the multi-session plan)

suit off iterated only the up-applied files[] and then deleted the
lockfile, orphaning any inject-recorded files on disk — fatal for an
inject-only lockfile (files:[], injected:[...]) created when a worker was
launched via stateless prepare.

- extract detectDrift() + removeTrackedFile() + RemovalState so up-applied
  and injected files traverse one removal contract (drift scan, additive
  block-strip, replace unlink, dir-prune, tallies)
- default off now removes injected files too, then deletes the lockfile
- --keep-injected: remove only up files, preserve injected files on disk,
  rewrite the lockfile with files:[] + reset resolution + injected intact;
  degrades to a full off when there are no injected entries
- off now accepts --project/--home <dir> (was cwd-only), matching current

Lifecycle verified end-to-end: inject -> off --keep-injected (preserves) ->
off (clean teardown, no orphans).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant