Skip to content

feat(protocol): define bounded media format queries - #6

Merged
agalwood merged 2 commits into
mainfrom
feat/media_formats_contract_20261018
Oct 18, 2026
Merged

agalwood merged 2 commits into
mainfrom
feat/media_formats_contract_20261018

Conversation

@agalwood

@agalwood agalwood commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

The quality picker in agalwood/Motrix#2365 needs a published media/formats contract before the desktop and extension can consume it. This implementation preserves scoped browser Cookie records, rejects contradictory listings, and bounds complete payloads so per-cookie limits cannot produce a request larger than the MBP1 frame allowance.

Refs #5 and agalwood/Motrix#2365. This is a replacement implementation from current main for review.

Changes:

  • Register Methods.MediaFormats, typed request/result exports, an optional mediaFormats capability, and a non-agent-facing tool entry. Keep protocol version 1.0 and existing pairing/submit contracts.
  • Strict HTTP(S) params reject user information, raw control characters, raw selectors, unscoped cookies, and cookies outside the initial URL's domain/path/Secure scope. Preserve the existing Cookie fields and Unix-millisecond expiry. Bound parsed UTF-8 params and results to 64 KiB.
  • Distinguish available nonempty listings from unavailable results with a required machine reason and empty entries. Bound unique video-height/MP3 choices and enforce key/kind/height consistency.
  • Ship an English/Chinese contract for explicit user actions, current authority/instance data consent, separate credential consent, endpoint/document revalidation, scoped extractor cookie replay, secret lifetime, ready-session transport gates, and correct capability/error fallback.
  • Document the concrete consumer changes needed in #2365 and feat(media): add scoped format discovery and grab overlay motrix-extension#56, including metadata normalization, real MP3 availability, removal of global Cookie headers/raw-cookie cache keys, and schema-parsed serialization.

Validation:

  • pnpm test: 242 passed, including 22 trailing-dot regression cases. Twelve of those cases failed before the fix.
  • pnpm build and pnpm lint: passed.
  • Exact 64 KiB / next-byte, UTF-8 expansion, URL-control, cookie-scope, contradictory-result, typed RPC round-trip, and existing submit compatibility checks passed.
  • Executed #2365's actual parseFormatEntries and the extension's actual mapCookies against the built schemas: standard video/MP3 output and millisecond expiry matched. The old name/value-only cookie draft and empty successful listing are intentionally rejected.
  • npm pack --ignore-scripts includes both contract documents and runtime/declaration exports. A clean external consumer of that tarball passed strict TypeScript checks with exactOptionalPropertyTypes and runtime imports.
  • The trailing-dot P2 is fixed in 0347079: accept and preserve one canonical trailing DNS dot, reject multiple trailing dots, and keep dotted/undotted domains isolated in both directions. Host-only, subdomain, path, and Secure boundaries remain enforced; both contract documents spell out the distinction.
  • A fresh adversarial round on the pushed fix found no actionable blocker: independent checks included 68 cookie-scope cases, 576 encoded/Unicode-dot combinations, and 1,144 malformed-input probes without unexpected throws. A separate 76-case match matrix also passed. The exact 64 KiB / next-byte boundary was rechecked. These checks cover protocol schemas, not live browser capture or extractor adapters.

The package is prepared as 0.9.0; publication and application adoption follow protocol review. The protocol package cannot enforce an application's current grants or extractor behavior, so the documented consumer acceptance checks remain prerequisites for advertising/calling the capability. This repository's current base has no CI workflow; the checks above were run locally.

@agalwood
agalwood marked this pull request as ready for review October 18, 2026 14:20
@agalwood
agalwood merged commit 1861aea into main Oct 18, 2026
@agalwood
agalwood deleted the feat/media_formats_contract_20261018 branch October 18, 2026 14:42
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