Add sweep registry to prevent GC of ERROR sweeps and enable discovery#29
Closed
Add sweep registry to prevent GC of ERROR sweeps and enable discovery#29
Conversation
Co-authored-by: caidish <16291224+caidish@users.noreply.github.com>
Co-authored-by: caidish <16291224+caidish@users.noreply.github.com>
… helper Co-authored-by: caidish <16291224+caidish@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add sweep registry to manage ERROR state sweeps
Add sweep registry to prevent GC of ERROR sweeps and enable discovery
Jan 26, 2026
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.
ERROR state sweeps are currently lost if the user reference is deleted, may be GC'd before inspection, and reference cycles prevent cleanup of KILLED sweeps.
Changes
Registry System
WeakValueDictionarytracks all sweep instances (allows normal GC)setholds strong references to ERROR sweeps (prevents GC until explicit release)threading.Lockon all registry operationsLifecycle Management
mark_error()adds sweep to error holdkill()andclear_error()remove from error holdkill()calls newclear_sweep_ref()methods on runner/plotter to break cyclesPublic API
Reference Cycle Breaking
clear_sweep_ref()toRunnerThreadandPlotterkill()before nulling referencesImplementation Details
_next_idcounter assigns unique IDs during__init__get_error_sweeps()returns directly from error_hold (O(1))_clear_registry_for_testing()helper for test isolationOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.