Skip to content

fix(media): accept canonical file URL forms - #121676

Merged
steipete merged 14 commits into
mainfrom
codex/windows-media-understanding-file-url-publication-current
Aug 11, 2026
Merged

steipete merged 14 commits into
mainfrom
codex/windows-media-understanding-file-url-publication-current

Conversation

@steipete

@steipete steipete commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Windows media handling had three connected portability gaps:

  1. nested media-store keys were assembled with host-native separators, which @openclaw/fs-safe 0.5.4 correctly rejects;
  2. several local/sandbox media owners recognized only selected file:// spellings instead of the complete anchored file: scheme; and
  3. media-reference comparison did not consistently canonicalize valid single-slash, Windows-drive, Windows-UNC, and hostless POSIX file URLs before reply-delivery deduplication.

The result could be failed managed-media writes, rejected mounted image/PDF reads, or duplicate/ambiguous media delivery on Windows.

Canonical Fix

  • src/media/store.ts now emits validated nested store keys with path.posix.join at the producer. Native filesystem paths are still constructed later by the file-store dependency.
  • Attachment normalization, local-media resolution, web-media loading, parsing, and sandbox source resolution recognize the complete anchored file: scheme and delegate syntax/security to their existing safe conversion owners.
  • Normal reply media classification now recognizes the same anchored ile: scheme, so no-sandbox canonical file URLs reach the established host-local rejection instead of propagating as raw outbound media; safe sandbox-mapped /workspace URLs keep their existing path.
  • src/agents/sandbox-media-paths.ts delegates file URL parsing to safeFileURLToPath(raw, "linux"), because sandbox mount paths are POSIX even when the host is Windows. SandboxFsBridge remains the containment owner.
  • src/media/media-reference-comparison.ts uses Node's explicit platform conversion contract: Windows drive/UNC forms retain Windows semantics, while hostless POSIX/container forms use POSIX semantics. Before conversion, it reuses @openclaw/fs-safe's encoded-separator predicate so %2F/%5C references retain their original comparison key instead of colliding with decoded local paths. The historical malformed-input fallback remains narrow.
  • The lower-value duplicate direct store regression introduced during the repair was removed; nested store behavior stays in the store owner test, while managed outgoing media remains covered at the real caller boundary.

User Impact

Windows managed-media writes work with nested keys such as outgoing/originals/<id>. Valid local references such as FILE:/C:/Media/photo.png, FILE:/workspace/media/pic.png, and their triple-slash equivalents now reach the same safe parsing and containment boundaries. Equivalent safe references deduplicate consistently. Encoded %2F/%5C references remain deliberately distinct from decoded local paths, preventing reply dedupe from silently suppressing outbound media without weakening remote-host, UNC/network, local-root, or sandbox-mount protections.

Proof

Authentic Windows-focused proof on the final composition:

  • media-reference comparator + real reply-payload dedupe: 52/52 (including %2F/%5C, upper/lower hex, and non-collision controls);
  • no-sandbox reply-media owner: authentic 4 failed / 4 passed before the fix, then 8/8 green across lower/upper single/triple-slash, remote-host, network, and encoded-separator forms; full host-file policy 9/9;
  • real auto-reply media caller suite: 10/12, with the only two failures unchanged Windows POSIX fixture-path expectations; Linux owner suite: 29/29;
  • delivery-evidence + chat-send comparator siblings: 22/22;
  • sandbox media path owner: 17/17;
  • media store + local/managed outgoing callers: 51 passed, 2 intentional skips;
  • real mounted image/PDF caller controls: 8 passed, 268 unrelated tests skipped by focus;
  • Windows changed-scope routing + package registration: 58/58;
  • targeted oxfmt, direct oxlint, and git diff --check: clean;
  • normal pre-commit hook: clean on all final overlay files.

A broader image/PDF file run exceeded the local wrapper's 184-second bound without a failing result or surviving process; the exact mounted-caller filter then passed. Earlier full-file proof on the identical reviewed blobs had only the named unchanged iMessage attachment-root assertion baseline.

Dependency and Security Contract

The exact cached @openclaw/fs-safe 0.5.4 artifact was inspected and executed against its lockfile integrity (sha512-lttlWKRBQU7eYDYykU2BPoF1S6AESGrT77mVCXsuWBxnRBTAI/PuGB89DB3D1lBCDaqTykIjymPJz4pFesGnkg==). Direct proof confirms:

  • POSIX relative keys split successfully;
  • backslash relative keys are rejected;
  • FILE:/workspace/media/pic.png with explicit Linux semantics resolves to /workspace/media/pic.png;
  • remote hosts and encoded separators are rejected;
  • Node's POSIX converter rejects %2F but decodes %5C, while the canonical fs-safe predicate rejects both case-insensitively before conversion.

Downstream local-root and sandbox-mount containment is unchanged. Fresh independent review found no traversal, host/local conflation, encoded-separator bypass, UNC regression, path/query secret exposure, or duplicate/silent-delivery defect.

Review Evidence

  • Exact-head ClawSweeper findings applied: reject %2F/%5C before comparison conversion while preserving the original key, and route every anchored case-insensitive file: form through the normal-reply host-local rejection boundary.
  • Fresh independent repaired-head review: clean, no P0/P1; best-fix, security, caller/sibling, and test-distinctness judgments clean.
  • Fresh fully WSL-local structured no-sandbox repair review: exact two-file hash manifest verified; Linux owner suite 29/29; TruffleHog clean in 16.7s; gpt-5.6-sol/high returned 0 findings, correctness 0.98.
  • The concurrent maintainer store-key commit remains the exact same reviewed path.posix.join producer fix.

Change Size

Against the concurrent main parent:

  • production: +24/-15 (net +9), justified by the dependency/platform, encoded-separator collision-prevention, and outbound host-file rejection contracts;
  • test support: +18/-0;
  • tests: +251/-30;
  • full PR: 22 source paths;
  • config/default/API/schema/dependency surfaces: unchanged.

CI Context

Exact head a9c5373 completed CI successfully (59 passed, 13 skipped, 0 failed). Exact-head CI for the final no-sandbox repair head eef9980 is the authoritative landing gate.

Changelog

Not required: this is a narrow Windows media-path compatibility and correctness repair with no public API or configuration change.

@steipete steipete self-assigned this Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 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 maintainer Maintainer-authored PR labels Aug 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 10, 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 repository_dispatch).
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 10:59 PM ET / August 11, 2026, 02:59 UTC.

ClawSweeper review

What this changes

This PR accepts canonical local file: URL forms across media loading, sandbox mapping, reply-media handling, deduplication, and portable media-store keys.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for maintainer review: the prior P1 is fixed on the current PR head and no new actionable patch defect was found, but the protected maintainer-owned delivery/security boundary still needs exact-head landing verification.

Priority: P1
Reviewed head: eef99804274186b8d1da14e3ff9cc85ad270659a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The repair is coherent and addresses prior findings, with exact-head validation and dependency-source confirmation still needed before merge.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned PR is outside the external-contributor proof gate; its submitted Windows-focused evidence remains useful supplemental context.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned PR is outside the external-contributor proof gate; its submitted Windows-focused evidence remains useful supplemental context.
Evidence reviewed 8 items Reply-media rejection boundary: The final-head normalizer classifies every anchored case-insensitive file: form as local, so no-sandbox inputs reach the established host-local rejection rather than being returned as raw outbound media.
Sandbox containment remains downstream: The PR converts file URLs with explicit Linux semantics for the container path, then resolves through the bridge and existing workspace containment checks.
Dedupe preserves unsafe encoded references: Comparison retains the original key when the shared encoded-separator predicate matches, avoiding collision with a decoded local path before Node conversion.
Findings None None.
Security None None.

How this fits together

Media references originate in agent output and tool inputs, then flow through local URL conversion and sandbox/host access policy before media is read or delivery is deduplicated. This change affects Windows path portability and the boundary that prevents raw host-local files from being sent in normal replies.

flowchart LR
  A[Agent and tool media references] --> B[Media URL normalization]
  B --> C{Sandbox workspace mapping}
  C -->|mapped| D[Workspace containment]
  C -->|not mapped| E[Host-local media policy]
  D --> F[Media read]
  E --> G[Reply delivery and deduplication]
Loading

Decision needed

Question Recommendation
After exact-head validation and direct inspection of the locked file-URL conversion dependency, should this maintainer-owned media boundary repair land? Verify then land: Refresh the merge result, complete exact-head required checks, and confirm the pinned dependency contract before merging.

Why: The protected maintainer label and unavailable direct dependency source leave a bounded security/delivery judgment that automated review cannot discharge.

Before merge

  • Resolve merge risk (P1) - The final-head required check set is not yet complete, so the current merge result still needs exact-head validation.
  • Resolve merge risk (P1) - The patch changes host-file rejection and reply-media deduplication; direct inspection of the locked @openclaw/fs-safe source was unavailable in this read-only environment.
  • Resolve merge risk (P1) - Production code grows by 9 net lines; the distinct parser, Linux sandbox-mount, comparison-key, and reply-policy ownership boundaries make a single shared conversion helper unsafe without changing established behavior.
Agent review details

Security

None.

PR surface

Source +27, Tests +221. Total +248 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 10 42 15 +27
Tests 12 251 30 +221
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 293 45 +248

Review metrics

Metric Value Why it matters
Production versus test delta production +24/-15 (net +9); test support +18; tests +251/-30 The production growth is confined to platform-specific conversion, comparison, and rejection boundaries, with broad focused regression coverage.

Stored data model

Persistent data-model change detected: persistent cache schema: src/media-understanding/attachments.file-url.windows.test.ts, serialized state: src/agents/sandbox-media-paths.test.ts, serialized state: src/agents/tools/image-tool.test.ts, serialized state: src/agents/tools/pdf-tool.test.ts, vector/embedding metadata: src/media/local-media-path.windows.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh landing proof (recommended)
    Rebase or regenerate the clean merge result, then complete exact-head checks and inspect the pinned file-URL conversion contract before merge.
  2. Accept the residual contract risk
    A maintainer may merge with the reviewed source reasoning despite unavailable package-source inspection, explicitly owning the platform conversion risk.

Technical review

Best possible solution:

Keep the boundary-specific conversions, refresh the merge result against current main, and land only after exact-head checks plus direct confirmation of the locked file-URL conversion contract.

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

Yes: current main recognizes only selected file:// forms at the affected media boundaries, while the final-head source and focused regression tables define a clear Windows-oriented path.

Is this the best way to solve the issue?

Yes, subject to dependency confirmation: the patch extends existing owner boundaries rather than creating a parallel path, while retaining sandbox containment and encoded-separator handling.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9ae35833759a.

Labels

Label justifications:

  • P1: The PR repairs Windows media-path handling and outbound reply behavior that can affect active media delivery.
  • merge-risk: 🚨 message-delivery: Canonicalization changes the keys used to suppress duplicate reply media and the classification of outbound media references.
  • merge-risk: 🚨 security-boundary: Canonical file URLs now traverse sandbox containment and host-local rejection paths, so a conversion mistake could affect local-file access policy.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned PR is outside the external-contributor proof gate; its submitted Windows-focused evidence remains useful supplemental context.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the portable media-store producer to Peter Steinberger, and the PR-head commits cover canonical URL handling, encoded separators, and no-sandbox reply blocking. (role: recent media-path contributor; confidence: high; commits: e004ad791b08, a9c5373fa48b, eef998042741; files: src/media/store.ts, src/media/media-reference-comparison.ts, src/auto-reply/reply/reply-media-paths.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete required checks for the current merge result.
  • Inspect the locked @openclaw/fs-safe 0.5.4 source or types in an artifact-enabled environment before landing.

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 (7 earlier review cycles)
  • reviewed 2026-08-10T18:51:54.984Z sha 6d68643 :: found issues before merge. :: [P1] Cover parser and sandbox paths for canonical file URLs
  • reviewed 2026-08-10T20:59:26.655Z sha 31a8e21 :: needs changes before merge. :: [P1] Normalize canonical file URLs in media dedupe keys
  • reviewed 2026-08-10T21:55:22.056Z sha b00ccf0 :: found issues before merge. :: [P1] Use POSIX joining for the file-store key
  • reviewed 2026-08-10T22:05:27.779Z sha b00ccf0 :: found issues before merge. :: [P1] Join the file-store key with POSIX separators
  • reviewed 2026-08-10T23:01:24.540Z sha e004ad7 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-11T01:05:13.677Z sha 405f470 :: found issues before merge. :: [P1] Reject encoded separators before comparison normalization
  • reviewed 2026-08-11T02:00:04.567Z sha a9c5373 :: found issues before merge. :: [P1] Recognize canonical file URLs in reply media normalization

@steipete
steipete requested a review from a team as a code owner August 10, 2026 20:52
@openclaw-barnacle openclaw-barnacle Bot added docker Docker and sandbox tooling agents Agent runtime and tooling size: S and removed size: XS labels Aug 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 10, 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 repository_dispatch).
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 the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Aug 10, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 10, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Aug 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 10, 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 repository_dispatch).
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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 11, 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 repository_dispatch).
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 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer landing adjudication for exact head eef99804274186b8d1da14e3ff9cc85ad270659a: both optional ClawSweeper rank-up moves are satisfied. Exact-head CI run 31452055652 is terminal green (58 successful jobs, 12 intentional skips, no failures). I also directly inspected the pinned @openclaw/[email protected] npm-cache source at the lockfile-matching integrity sha512-lttlWKRBQU7eYDYykU2BPoF1S6AESGrT77mVCXsuWBxnRBTAI/PuGB89DB3D1lBCDaqTykIjymPJz4pFesGnkg==; its URL parser rejects remote hosts, encoded separators, and Windows network paths as relied on here. The exact-head review reports no findings and no security issue, so the protected delivery/security judgment is accepted for guarded maintainer landing.

@steipete
steipete merged commit cc9e75e into main Aug 11, 2026
133 checks passed
@steipete
steipete deleted the codex/windows-media-understanding-file-url-publication-current branch August 11, 2026 03:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 11, 2026
* fix(media): accept canonical file URL forms

* fix(media): normalize file store keys

* fix(media): handle canonical file URLs end to end

* test(media): expose nested store key failure on Windows

Amp-Thread-ID: https://ampcode.com/threads/T-019fed8d-ad78-74f0-9592-a3466bb6a9bd
Co-authored-by: Peter Steinberger <[email protected]>

* test(media): cover canonical file URL dedupe

Amp-Thread-ID: https://ampcode.com/threads/T-019fed8d-ad78-74f0-9592-a3466bb6a9bd
Co-authored-by: Peter Steinberger <[email protected]>

* Revert "test(media): cover canonical file URL dedupe"

This reverts commit 63efbbc.

* fix(media): keep nested store keys portable

* fix(media): complete canonical file URL handling

* fix(media): reject encoded separators in comparison keys

* fix(auto-reply): block canonical file URLs without sandbox

---------

Co-authored-by: Amp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docker Docker and sandbox tooling maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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