Repository navigation
fix: bind capture and publication to batch cancellation - #11
Merged
Merged
Conversation
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.
Cancellation previously changed capture state while already registered workers continued into publication. Register/arm also crossed separate critical sections, so cancellation could leave an orphan armed capture. This addresses INS-3/4 in #2.
Each batch now owns its cancellation event, effect-admission lock and active job count. Registration, capture arm, claims and state transitions share the bot ownership lock. Workers carry that same batch through identification, verification, trend, routing and publication. Natural window completion releases the capture job; processing jobs keep the batch cancellable until they finish. Replacing or cancelling a batch stops its future effects without changing a newer batch.
Cancellation closes effect admission and drains already admitted HTTP publications/notifications before acknowledging completion. Requests already committed remotely are not retracted. Read-only identification/model calls already in progress can finish, then hit the next cancellation checkpoint. Independent direct pipeline/CLI calls create an active operation at their entry; this uses the same implementation and adds no user configuration.
Validation:
Sweep: process_paper/run_auto_pipeline/_process_async, all capture.arm/finish_batch sites, batch ownership references and both /api/insight/publish clients. The standalone publisher is independent of chat batches and already shares the validated receipt contract from #10. The old _batch_stops representation is gone. No dependency, user/model field, timeout increase, retry mechanism or queue was added.
Production diff: +187/-82 (net +105), including the 29-line shared operation. Test/HTTP fixture diff: +207/-2 (net +205). The job count is needed to retain cancellation after the collection window closes and to release ownership once every registered job finishes; wrapper methods keep initialization and polling cleanup in one place. All six changed files and all four PR commits were reviewed. No live service writes or deployment were performed.