fix(orchestrator): register cache cleanup on wizardAbort paths - #1072
Open
fristovic wants to merge 1 commit into
Open
fix(orchestrator): register cache cleanup on wizardAbort paths#1072fristovic wants to merge 1 commit into
fristovic wants to merge 1 commit into
Conversation
gewenyu99
approved these changes
Aug 10, 2026
gewenyu99
left a comment
Collaborator
There was a problem hiding this comment.
Oh 🤦 how did I forget to do this. Good change. I'll test and take this forward!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After an aborted orchestrator run (accidental Ctrl+C in the wrong terminal window, but I assume errors would produce this as well), the install dir was left with an untracked
.posthog-wizard-cache/(plus.DELETE-ME.mdsaying it should have been removed when the wizard finished - which initiated my research into this fix).QueueStorecreates that folder as soon as the orchestrator starts, but the wipe only lives in thefinallyafterdrainQueue. Abort goes throughwizardAbort()→process.exit()and never hits that path, and the cache dir was never registered withregisterCleanup(). Ctrl+C / SIGTERM have the same gap (run-wizardalready callsrunCleanups()before exit).Changes
Extract
wipeOrchestratorCacheand wire it with the same dual-path pattern asflushScanReportin the program runner:registerCleanup(() => wipeOrchestratorCache(...))right afternew QueueStore(...)— covers abort / SIGINTfinally— covers normal completionQueueStorestays free of abort/analytics wiring.Test plan
cache-cleanup.test.ts: wipe removes aQueueStore-created cache dir; wipe viaregisterCleanup/runCleanups; no-op when already gonepnpm exec vitest run src/lib/agent/runner/sequence/orchestrator/__tests__/(63 tests passed, including the new ones)pnpm build.posthog-wizard-cache/is gone; successful run still leaves none behind