Skip to content

fix: bind capture and publication to batch cancellation - #11

Merged
HsukqiLee merged 4 commits into
mainfrom
fix/batch-cancellation
Nov 17, 2026
Merged

HsukqiLee merged 4 commits into
mainfrom
fix/batch-cancellation

Conversation

@HsukqiLee

@HsukqiLee HsukqiLee commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • The test-only head dc9fafc failed seven assertions in real Linux CI: https://github.com/FastR-D/FastInsight/actions/runs/44005341176
  • The same tests passed with c70891a: all 70 tests passed, followed by successful tested-runtime packaging: https://github.com/FastR-D/FastInsight/actions/runs/44005589821
  • Production composition stays real: official Feishu SDK with its public domain boundary set to a local HTTP server, handle_event, CaptureStore/fcntl, verifier/routing child processes and publish HTTP clients. External search, model and Research protocols are fixtures.
  • Controlled interleavings cover image identification, verification, trend, an admitted publication versus its next recipient, persisted natural window completion with and without cancellation, replacement batches, and the OS mkdir boundary during arm. Assertions wait for scenario-owned workers to finish.
  • Local Windows delivery/auth scenarios also passed (8 tests). Local full-SDK WSL attempts were limited by SDK import/install I/O across the Windows mount; those interrupted runs are not counted as passes. Linux CI supplies the complete SDK 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.

@HsukqiLee
HsukqiLee marked this pull request as ready for review November 17, 2026 02:52
@HsukqiLee
HsukqiLee merged commit 538b74c into main Nov 17, 2026
2 checks passed
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