feat!: LabDropGuard with FlushRegistry for guaranteed clean shutdown#29
Merged
feat!: LabDropGuard with FlushRegistry for guaranteed clean shutdown#29
Conversation
3239e7e to
d4e2df7
Compare
Wrap Lab around Arc<LabDropGuard> which derefs to LabInner. When the last Lab clone drops, the guard cancels all async and sync workers, flushes all buffered log files, and writes the final state.json. Device/Router/Iface handles hold Arc<LabInner> directly and do not prevent shutdown. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d4e2df7 to
b7a1f85
Compare
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.
Wrap Lab around Arc which derefs to LabInner. When the last Lab clone drops, the guard cancels all namespace workers (async runtimes + sync workers), flushes all buffered log files via a FlushRegistry, and writes the final state.json with the correct test status.
Device, Router, and Iface handles hold Arc directly, bypassing the guard. They do not prevent shutdown. This fixes an issue where outstanding handles could delay LabInner::drop, leaving state.json with status "running" and events.jsonl incompletely flushed.
The FlushRegistry collects all buffered file writers (events.jsonl, per-namespace tracing/ANSI/events/metrics logs) and flushes them synchronously in the drop guard.
Breaking changes
Device::lab(). Returned aLabclone but could not safely participate in the drop guard lifecycle. Never called externally.Router::lab(). Same reason.