Skip to content

fix(media): preserve Matroska extensions after byte detection - #133383

Merged
steipete merged 1 commit into
openclaw:mainfrom
ly85206559:codex/media-matroska-mime
Aug 30, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
ly85206559:codex/media-matroska-mime

Conversation

@ly85206559

@ly85206559 ly85206559 commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Briefly describe the problem and fix:

  • Problem: byte detection reports Matroska containers as video/matroska, while OpenClaw's filename and extension tables use video/x-matroska. Extensionless or mislabeled MKV input therefore loses the canonical .mkv mapping after sniffing.
  • Why this fix: normalize the detector spelling at the existing MIME synonym boundary, matching the established AVI alias handling without adding a new format path or configuration surface.
  • What changed: added the Matroska synonym and a regression test using a minimal EBML/Matroska header.
  • What did not change: no playback policy, allowlist, config, protocol, or dependency changes.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Security hardening
  • Build/tooling

Scope

  • Core/runtime
  • Gateway/protocol
  • Plugin/extension
  • CLI/tooling
  • Docs only
  • CI/build

Verification

  • Targeted tests added/updated
  • Manual verification performed
  • Screenshots attached (required for UI changes)
  • Logs/output attached (required for runtime/behavioral changes)

Evidence

  • Before the production change, node scripts/run-vitest.mjs packages/media-core/src/mime.test.ts failed only the new regression: expected video/x-matroska, received video/matroska (189 passed, 1 failed).
  • On current origin/main, the same focused suite passes: 190/190.
  • The pinned [email protected] detector returns { ext: "mkv", mime: "video/matroska" } for the regression header.
  • Commit-scoped autoreview (Codex gpt-5.5, high) reported no actionable findings, correctness confidence 0.82.
  • Exact-head real media-store save/read proof (9fb8cb5b791c081f71de623d54f24347aa7f2720, Node 24.16.0): a byte-sniffed Matroska buffer was persisted as video/x-matroska with .mkv, then fetched byte-for-byte (storedBytes=16, fetchedBytes=16, bytesMatch=true).

User Impact

Byte-detected Matroska attachments retain the same canonical MIME and .mkv extension behavior as filename-detected MKV files.

Risks and Rollback

  • Risk: very low; the change only folds an equivalent Matroska spelling into an existing canonical value.
  • Rollback: revert this commit to restore pass-through handling of video/matroska.

AI Assistance

AI-assisted by Codex. I reviewed the implementation, dependency behavior, focused red/green test, and final commit-scoped review.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 30, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 1:31 PM ET / 17:31 UTC.

ClawSweeper review

What this changes

The PR normalizes byte-detected Matroska MIME values to OpenClaw’s canonical video/x-matroska spelling and adds a regression test for .mkv extension lookup.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for normal maintainer review: current main still passes the detector’s Matroska spelling through without an .mkv mapping, while the proposed synonym repairs that shared normalization boundary with focused real-behavior evidence and no blocking finding.

Priority: P2
Reviewed head: 9fb8cb5b791c081f71de623d54f24347aa7f2720

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused shared-boundary repair with behavior evidence and no supported correctness or security blocker.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The changed owner is Media Core’s byte-detection normalization; the PR records an exact-head real media-store save/read of a byte-sniffed Matroska buffer with canonical MIME, .mkv output, and byte-for-byte retrieval, supported by a focused red/green detector regression trace.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed owner is Media Core’s byte-detection normalization; the PR records an exact-head real media-store save/read of a byte-sniffed Matroska buffer with canonical MIME, .mkv output, and byte-for-byte retrieval, supported by a focused red/green detector regression trace.
Evidence reviewed 8 items Introduced owner-boundary repair: The PR adds the Matroska alias at the shared normalization boundary; sniffMime normalizes the detector result before detectMime returns it, and extension lookup normalizes before reading the canonical .mkv entry.
Current-main behavior remains unfixed: Fetched current main retains video/x-matroska as the extension-table key but its synonym table ends at the AVI alias, so a detector result of video/matroska is not canonicalized.
Observable downstream path: The media store calls detectMime, resolves the extension from that result, and uses it in the persisted media ID; the alias therefore fixes extensionless or mislabeled byte-detected inputs at the producer boundary.
Findings None None.
Security None None.

How this fits together

Media Core classifies attachment bytes and filenames into a MIME type used by media storage and delivery code. Its normalized result determines the saved filename extension and downstream media handling.

flowchart LR
  A[Attachment bytes] --> B[Byte MIME detector]
  C[Filename and header hints] --> D[MIME normalization]
  B --> D
  D --> E[Canonical MIME type]
  E --> F[Extension lookup]
  F --> G[Saved media filename]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: the submitted PR is already the focused owner-boundary fix and only needs ordinary maintainer review.
Agent review details

Security

None.

PR surface

Source +1, Tests +8. Total +9 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 8 0 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 10 1 +9

Review metrics

Metric Value Why it matters
Production versus test delta production +1 semantic mapping, 1 comment wording change; tests +8 The added mapping is the smallest shared representation of the detector spelling; the test covers the byte-detection-to-extension contract.

Technical review

Best possible solution:

Merge the shared Matroska synonym and retain the focused byte-detection regression coverage, so all consumers receive the established canonical MIME before extension lookup.

Do we have a high-confidence way to reproduce the issue?

Yes, with high confidence from source and supplied exact-head evidence: file-type output is normalized in detectMime, then drives extension lookup; current main lacks the required Matroska alias.

Is this the best way to solve the issue?

Yes. Folding the detector spelling at the existing MIME synonym boundary is cleaner than adding media-store fallbacks, and matches the established AVI alias pattern.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2548efddff51.

Labels

Label justifications:

  • P2: This is a bounded attachment filename/extension regression with a focused owner-boundary repair.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed owner is Media Core’s byte-detection normalization; the PR records an exact-head real media-store save/read of a byte-sniffed Matroska buffer with canonical MIME, .mkv output, and byte-for-byte retrieval, supported by a focused red/green detector regression trace.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed owner is Media Core’s byte-detection normalization; the PR records an exact-head real media-store save/read of a byte-sniffed Matroska buffer with canonical MIME, .mkv output, and byte-for-byte retrieval, supported by a focused red/green detector regression trace.

Evidence

What I checked:

  • Introduced owner-boundary repair: The PR adds the Matroska alias at the shared normalization boundary; sniffMime normalizes the detector result before detectMime returns it, and extension lookup normalizes before reading the canonical .mkv entry. (packages/media-core/src/mime.ts:167, 9fb8cb5b791c)
  • Current-main behavior remains unfixed: Fetched current main retains video/x-matroska as the extension-table key but its synonym table ends at the AVI alias, so a detector result of video/matroska is not canonicalized. (packages/media-core/src/mime.ts:160, 2548efddff51)
  • Observable downstream path: The media store calls detectMime, resolves the extension from that result, and uses it in the persisted media ID; the alias therefore fixes extensionless or mislabeled byte-detected inputs at the producer boundary. (src/media/store.ts:618, 9fb8cb5b791c)
  • Focused regression coverage: The new test supplies a .bin path to avoid filename-derived MIME and asserts both byte-detected canonical MIME and .mkv extension. Existing nearby AVI coverage exercises the same normalization design. (packages/media-core/src/mime.test.ts:54, 9fb8cb5b791c)
  • Sibling compatibility: Playback explicitly accepts both Matroska spellings with the same transcode format, so canonicalizing the detector output does not remove its existing playback route. (src/media/playback-transcode.ts:76, 9fb8cb5b791c)
  • Dependency signal and review limitation: Media Core directly imports file-type, which is pinned to 22.0.2. Its installed source was unavailable in this read-only checkout and GitHub DNS was unavailable, but the PR’s exact-head proof records that this detector emits video/matroska for the fixture. (packages/media-core/package.json:68, 9fb8cb5b791c)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-30T16:36:59.821Z sha 9fb8cb5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-30T17:01:18.361Z sha 9fb8cb5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-30T17:20:48.023Z sha 9fb8cb5 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 30, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 30, 2026
@ly85206559

Copy link
Copy Markdown
Contributor Author

Exact-head behavior proof for 9fb8cb5b791c081f71de623d54f24347aa7f2720 (Windows):

$ node --input-type=module -e 'import { fileTypeFromBuffer } from "file-type"; const b=Buffer.from("1a45dfa38b4282886d6174726f736b61","hex"); console.log(await fileTypeFromBuffer(b));'
{ ext: 'mkv', mime: 'video/matroska' }

$ node scripts/run-vitest.mjs packages/media-core/src/mime.test.ts   # regression before production mapping
expected "video/x-matroska", received "video/matroska"
Tests  1 failed | 189 passed (190)

$ node scripts/run-vitest.mjs packages/media-core/src/mime.test.ts   # exact head
Test Files  1 passed (1)
Tests  190 passed (190)

The regression enters the real detectMime byte-sniff path, loads the pinned file-type detector, then verifies the normalized MIME produces .mkv through extensionForMime.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 30, 2026
@steipete steipete self-assigned this Aug 30, 2026
@steipete

Copy link
Copy Markdown
Contributor

Maintainer review confirms this is the shared normalization fix: pinned file-type 22.0.2 emits video/matroska, while OpenClaw's canonical extension table uses video/x-matroska. I inspected the dependency's EBML detector, MIME owner, media-store callers, and playback policy; playback already accepts both spellings with the same demuxer.

The contributor's exact-head proof records one failing detector regression before the mapping, all 190 tests passing afterward, and a real media-store save/read preserving all 16 fixture bytes with the .mkv extension. Those are contributor runs. Our independent isolated rerun never obtained a host and did not execute. Exact-head CI passed in run 33322562079, and fresh Codex review found no actionable P0 finding.

The latest ClawSweeper review has no remaining source finding or rank-up move. Production grows by one necessary synonym; tests add eight lines. No new configuration, parser, storage schema, or format family. Release-note context: byte-detected Matroska attachments retain their canonical .mkv extension. Thanks @ly85206559.

@steipete
steipete merged commit 25fc02a into openclaw:main Aug 30, 2026
206 of 207 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit to shojikumaru/openclaw that referenced this pull request Aug 30, 2026
…cked-delivery

* origin/main:
  fix(ui): wait for restored draft before clearing (openclaw#133575)
  fix(deps): update fast-uri security patches (openclaw#133572)
  test: reduce workflow sanity fixture cleanup time (openclaw#133588)
  fix(media): normalize detected Matroska MIME (openclaw#133383)
  refactor(docker): retire ClawDock shell helpers (openclaw#133594)
  perf(browser): reuse snapshot refs and screenshot metadata (openclaw#133598)
  perf: load web chat history in larger, faster batches (openclaw#133565)
  fix(plugins): keep bundled plugins bundled when selected by plugins.load.paths (openclaw#133584)
  test: isolate shared /tmp session-store paths in runner and health suites (openclaw#133568)
  fix(cron): avoid no-op schedule repair writes (openclaw#133552)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants