Repository navigation
feat(operations): implement safe cancellation for long-running imports and exports (#325) - #431
Merged
preshotta merged 2 commits intoOct 22, 2026
Conversation
Collaborator
|
Merged after updating/checking against the live base branch and passing the required Malware guard. The earlier status comment was based on an older GitHub merge preview or a branch that did not need updating; it was not a finding that this contribution introduced malware. Please fix and rerun the remaining non-security checks:
|
Collaborator
|
Merged as requested after the required Malware guard passed. Non-security checks are still failing; please fix and rerun these checks:
|
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.
Summary
Closes #325
Implements safe cancellation for long-running imports and exports in Trellis-frontend, ensuring immediate cessation of processing, automatic pre-write snapshot rollback, and role-based cancellation authorization without data corruption.
Acceptance Criteria Verification
POST /api/operations/cancelandGET /api/operations(admins can cancel any operation; contributors can cancel operations owned by their wallet; viewers are denied with 403 Forbidden).tests/__tests__/safe-cancellation.test.ts: 20 unit tests covering normal execution, failure paths, early cancellation, mid-write rollback, streaming helpers, and RBAC matrix.lib/export/__tests__/streaming-export.test.ts: 23 unit tests verifying streaming export cancellation, retry backoff termination, and field permission handling.docs/import-pipeline.mddetailing the snapshot rollback mechanism, cancellation endpoints, and compensation steps.lib/export/OPERATIONAL_GUIDE.mddetailing stream cancellation, timeout handling, and memory safety.runImportPipelineandstreamingExportoptions (signalandonProgressare optional)./api/operationsand/api/operations/cancel.Key Changes
lib/cancellation/operation-registry.ts,lib/cancellation/index.ts):running,completed,cancelled,failed), and AbortController integration.lib/import/pipeline.ts,lib/import/stream.ts):importStore.createSnapshotbefore executing persistent writes; on cancellation mid-write, automatically invokesimportStore.restoreSnapshotto safely roll back all writes and prevent partial or corrupted state.rollbackGuidanceand cancellation metadata.lib/export/streaming-export.ts):app/api/operations/route.ts,app/api/operations/cancel/route.ts):GET /api/operations: Inspect active and past operations with role-based visibility.POST /api/operations/cancel: Request cooperative cancellation with audit log.components/import/ImportProgressModal.tsx):Verification & Testing