Skip to content

feat(protocol): define recoverable download handoff contract - #4

Merged
agalwood merged 3 commits into
mainfrom
feat/download-handoff-contract
Nov 19, 2026
Merged

agalwood merged 3 commits into
mainfrom
feat/download-handoff-contract

Conversation

@agalwood

@agalwood agalwood commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Problem and contract

Browser takeover cannot safely treat a lost submit reply as permission to restart the browser download. Add an opt-in handoff v1 wire contract for extension-owned confirmation: download/handoff.prepare, .commit, .status, and .abort.

The new optional initialize capability binds operations to a durable ledger instance. Prepare freezes direct HTTP(S) GET payloads; commit also carries the approved payload hash. Method-specific results distinguish prepared, committed, aborted, expired and observational not-found. Instance changes and payload conflicts have dedicated error codes. All four methods are excluded from the agent catalog; actual authorization and transport exposure remain host responsibilities.

Shared canonical payload encoding normalizes schema defaults and object key order before SHA-256, binding destination, filename, headers, cookies and source metadata. Strict request schemas reject unsupported method/body options instead of silently turning POST into GET. Existing submit and old-peer initialization remain compatible.

Independent browser-store rollout

Store review delays and users retaining old extensions are supported configurations. The host must keep the original download/submit, initialization, pairing and task behavior, without raising the extension minimum version for this feature. New extensions must retain the legacy path for old hosts.

Both new-operation gates default closed: server acceptingNew and the client flag passed to canStartDownloadHandoff. Unsupported or invalid optional handoff capabilities no longer break the base handshake. Disabling new handoffs must keep handlers and the durable journal available for in-flight recovery; an operation already transmitted must never downgrade to a second legacy submission. See the bilingual contract for release order and compatible rollback requirements.

Cross-version tests use the actual published @motrix/mdxp@0.8.1 SDK through an exact dev-only alias. They cover old/old, old/new, new/old, disabled rollout, and a future capability, using serialized RPC initialize and submit messages. These tests do not replace released-extension/production-host E2E, which remains required before enablement.

Scope

This PR supplies schemas, inferred types, typed RPC entries, tool registration, canonical encoding and a bilingual normative contract. It does not implement or claim a durable ledger, transactional outbox, engine reconciliation, or browser ownership controller. It does not publish a package or switch the extension to this protocol.

The contract specifies abort tombstones for absent operations, terminal-state retention, same-key recovery after lost replies, instance rotation after ledger loss, expiry serialization and the integration fault matrix required before a host may advertise support. Download confirmation stays in the extension. V1 does not support POST or request bodies; one-use URLs are not guaranteed replayable.

This follows motrixapp/motrix-extension#46. A host must keep the capability absent until the documented persistence and browser integration requirements are implemented and verified.

Validation

  • 192 tests pass, including schema boundaries, legacy compatibility, immutable payload vectors, all four typed RPC round trips and refusal-code propagation.
  • Type-checking now includes test fixtures; two existing initialize fixtures use schema parsing to apply their existing default fields.
  • Added MDXP contract checks CI: frozen dependency install, full lint, typecheck, tests, build and package verification.
  • Actual npm tarball checked through root, Node and browser-condition exports; both contract translations and declarations are included and test sources excluded. This is export verification, not a browser execution test.
  • Full Biome, TypeScript, build, package verification, actionlint and diff checks pass locally. The latest remote MDXP contract checks run passed on Linux for commit 0950100, including all 192 tests and packaged entry verification.

Integration update

Head 55b4f71 integrates the 0.9.0 media-format capability with handoff v1. All 278 SDK tests passed locally; the packed root, Node and browser entry points were verified. This PR is the protocol dependency for the host journal in agalwood/Motrix#2535 and the paired extension candidate in motrixapp/motrix-extension#78. The independently reviewable browser ownership fix is motrixapp/motrix-extension#77. The candidate SDK was exercised from a local checkout.

@agalwood
agalwood marked this pull request as ready for review November 19, 2026 16:13
@agalwood
agalwood merged commit 37cc323 into main Nov 19, 2026
1 check 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