feat(extract): async cancel lifecycle + canonical types across MCP/SDK#290
Merged
Conversation
A DELETE that landed in the narrow window after the worker persisted the last URL but before finalize ran marked the whole job cancelled unconditionally, even though every per-URL result was completed with real data — a response that contradicted itself. Only report cancelled when at least one in-flight URL was actually stopped; otherwise settle the job by its outcomes, as the naturally finished job it is. Lockfile re-synced to the workspace version.
The canonical cancellation work dropped `success` from crw_extract, crw_check_extract_status and crw_cancel_extract to mirror the native /v1 HTTP shape, but every other MCP tool returns `success` and clients already read it, so removing it silently broke those consumers. Re-add `success` on the MCP surface only (injected from the shared HTTP type, false only when every URL failed) and relax the MCP/OpenAPI parity check to ignore that one envelope field while still enforcing the data-field contract.
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.
Adds the async cancel lifecycle to
/v1/extractand makes the extract typescanonical across the HTTP, MCP and SDK surfaces.
What changes
DELETE /v1/extract/{id}andCancelling/Cancelledstates on the extractjob state machine. The worker claims one URL at a time and shares the job
write-lock with DELETE, so a cancel and the final write race on exactly one
lock and terminal state is never rewritten.
narrow window after the last URL is persisted but before finalize runs now
settles the job by its per-URL outcomes instead of reporting
cancelledoverresults that are all
completedwith real data.crw_cancel_extractMCP tool;crw_extract/crw_check_extract_statuskeep thesuccessenvelope every other MCP tool returns (removing it silently brokeclients that read it). The MCP/OpenAPI parity check ignores that one envelope
field while still enforcing the data contract.
start_extract/get_extract/cancel_extracton the Python and TypeScriptSDKs, with an
extract()waiter that treatscancelledas terminal (raisingwith any partial results) and issues a best-effort cancel on timeout.
uses (
_http_request), fixing the scheduled Examples Test that had gone red.Verification
crw-server test suite green (lib + integration), clippy clean, Python SDK
38/38, TypeScript SDK builds and tests, OpenAPI drift check passes (served
/openapi.jsonbyte-equal to the committed spec), lockfile unchanged from main.Refs the Agent A readiness work (async extract lifecycle + canonical types).