Skip to content

refactor(media): share image and video geometry normalization - #119416

Merged
steipete merged 1 commit into
mainfrom
codex/loc-0804-media-luem8u
Aug 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-0804-media-luem8u

Conversation

@steipete

@steipete steipete commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Image and video generation duplicated geometry normalization and provider registry scaffolding, while TTS repeated equivalent result contracts. This is part of a maintainer-requested project-wide production LOC reduction campaign.

Why This Change Was Made

Move equivalent geometry normalization into its canonical shared media owner, remove empty provider wrappers, and consolidate structurally identical TTS result types without changing public contracts.

User Impact

Image/video aspect ratios, resolutions, model-specific capabilities, ignored overrides, and TTS behavior remain unchanged. Removes 202 production lines.

Evidence

Exact-head image and video normalization proof

The actual committed image normalizer, video normalizer, new shared geometry owner, and their canonical capability/duration helpers were loaded directly from the exact reviewed commit. The isolated fixture made no provider API calls and used no credentials. The output below was actually produced and all twelve production-path assertions passed.

$ git rev-parse HEAD
972dde25d311b6b7bb7d740a18c357a989c0566c
$ node --disable-warning=ExperimentalWarning --input-type=module < exact-head-media-normalization-proof.mjs
{
  "head":"972dde25d311b6b7bb7d740a18c357a989c0566c",
  "image":{"requested":{"model":"flex-image","aspectRatio":"16:9","resolution":"4K","quality":"high"},"applied":{"width":2048,"height":1152,"resolution":"2K"},"ignored":[{"key":"quality","value":"high"}]},
  "video":{"requested":{"model":"motion-v1","size":"1280x720","resolution":"720P","durationSeconds":5,"audio":false,"watermark":false},"applied":{"aspectRatio":"16:9","resolution":"768P","durationSeconds":6},"ignored":[{"key":"audio","value":false},{"key":"watermark","value":false}]},
  "rejectedSentinels":{"requested":{"model":"motion-v1","aspectRatio":"adaptive","resolution":"4K"},"ignored":[{"key":"aspectRatio","value":"adaptive"},{"key":"resolution","value":"4K"}]},
  "assertions":12
}

The proof invokes the actual resolveImageGenerationOverrides and resolveVideoGenerationOverrides functions, including shared geometry fallback, provider-supported model-specific dimensions, closest resolution, supported duration rounding, false-valued unsupported overrides, and rejected adaptive sentinels.

ClawSweeper rank-up disposition: the requested after-fix runtime transcript is supplied above. Refreshing the branch onto current main is intentionally skipped: this exact reviewed head already passed 162 focused tests, the full Blacksmith changed gate, and the exact-head hosted ci-gate; the canonical maintainer merge workflow verifies current-main drift immediately before landing and treats it as advisory. Rebasing would discard validated exact-head CI and review evidence without fixing a conflict.

@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 5, 2026
@steipete
steipete marked this pull request as ready for review August 5, 2026 02:20
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 11:16 PM ET / August 5, 2026, 03:16 UTC.

ClawSweeper review

What this changes

This PR centralizes image and video geometry normalization, removes redundant provider-registry wrappers, and factors equivalent internal TTS result fields without changing behavior.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for protected maintainer review. The exact-head refactor preserves image/video-specific normalization choices while removing duplicate logic, and the previously missing runtime proof is now supplied.

Priority: P3
Reviewed head: 972dde25d311b6b7bb7d740a18c357a989c0566c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) This is a clean, evidence-backed refactor pending the required protected maintainer review.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body provides exact-head terminal output from the actual image and video normalization functions, covering 12 asserted outcomes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides exact-head terminal output from the actual image and video normalization functions, covering 12 asserted outcomes.
Evidence reviewed 6 items Shared owner preserves distinct policies: The new helper keeps optional switches for video resolution ordering, unrecognized override reporting, and size/aspect-ratio matching; image and video callers supply their respective policies.
Runtime entry points: Current image and video runtimes pass normalized overrides directly into provider generation requests, so the shared helper remains on the existing owner path.
Existing boundary coverage: Current suites cover model-specific image geometry, size-to-aspect translation, video resolution normalization, unparseable override reporting, and image-to-video mode capabilities.
Findings None None.
Security None None.

How this fits together

Image and video generation convert requested dimensions and provider capabilities into safe provider requests and user-facing adjustment metadata. The shared media helper sits between per-mode capability selection and each provider call.

flowchart LR
  A[Generation request] --> B[Image or video runtime]
  B --> C[Mode and model capabilities]
  C --> D[Shared geometry normalization]
  D --> E[Provider request]
  D --> F[Adjustment metadata]
Loading

Before merge

  • Complete next step (P2) - The protected maintainer label requires an explicit human landing decision; there is no concrete repair task for an automation lane.
Agent review details

Security

None.

PR surface

Source -202. Total -202 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 7 252 454 -202
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 252 454 -202

Review metrics

Metric Value Why it matters
Production versus test LOC production -202, tests ±0 The patch is a net-negative production refactor and changes no test files; existing boundary suites cover the retained behavior.

Technical review

Best possible solution:

Retain one shared geometry-normalization owner while keeping video-only duration, audio, watermark, resolution-order, and sentinel-reporting behavior in the video path.

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

Not applicable; this PR refactors existing behavior. Its exact-head terminal transcript directly exercises the affected normalizers rather than demonstrating a reported failure.

Is this the best way to solve the issue?

Yes. The shared media owner removes duplicate geometry policy while explicit caller options preserve the image/video differences that existing runtime tests cover.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1f3d45b76f51.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head terminal output from the actual image and video normalization functions, covering 12 asserted outcomes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-head terminal output from the actual image and video normalization functions, covering 12 asserted outcomes.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This is behavior-preserving refactor cleanup with limited user-facing blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-head terminal output from the actual image and video normalization functions, covering 12 asserted outcomes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head terminal output from the actual image and video normalization functions, covering 12 asserted outcomes.

Evidence

What I checked:

  • Shared owner preserves distinct policies: The new helper keeps optional switches for video resolution ordering, unrecognized override reporting, and size/aspect-ratio matching; image and video callers supply their respective policies. (src/media-generation/geometry-normalization.ts:28, 972dde25d311)
  • Runtime entry points: Current image and video runtimes pass normalized overrides directly into provider generation requests, so the shared helper remains on the existing owner path. (src/image-generation/runtime.ts:133, 1f3d45b76f51)
  • Existing boundary coverage: Current suites cover model-specific image geometry, size-to-aspect translation, video resolution normalization, unparseable override reporting, and image-to-video mode capabilities. (src/video-generation/runtime.test.ts:1127, 1f3d45b76f51)
  • Current main does not already contain the refactor: The PR head is not an ancestor of current main, and current-main changes do not overlap the touched media, TTS, or registry paths. (src/media-generation/geometry-normalization.ts:28, 1f3d45b76f51)
  • Exact-head behavior proof: The PR body includes terminal output from commit 972dde2 exercising actual image/video normalizers across 12 assertions; provided check context also records successful Real behavior proof and CI-gate runs. (972dde25d311)
  • Area provenance: Recent history shows continued media and TTS work by the likely owners, including media cache and shared provider-registry refactors. (src/media-generation/runtime-shared.ts:20, 22de30f99821)

Likely related people:

  • steipete: Recent history includes media playback-cache and TTS work, as well as this refactor's exact head. (role: recent media and TTS contributor; confidence: high; commits: 22de30f99821, 0babd1a73fce, 972dde25d311; files: src/media-generation/runtime-shared.ts, src/tts/tts-runtime-types.ts, src/media-generation/geometry-normalization.ts)
  • vincentkoc: History contains shared media normalization and provider-registry refactors on the same architectural seam. (role: shared media and provider-registry contributor; confidence: medium; commits: af7797b0adfa, 7c4ab782cb83; files: src/media-generation/runtime-shared.ts, src/image-generation/provider-registry.ts, src/video-generation/provider-registry.ts)

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 (2 earlier review cycles)
  • reviewed 2026-08-05T03:04:18.628Z sha 972dde2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T03:09:43.471Z sha 972dde2 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@steipete
steipete merged commit a5ebadc into main Aug 5, 2026
199 of 213 checks passed
@steipete
steipete deleted the codex/loc-0804-media-luem8u branch August 5, 2026 03:23
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 5, 2026
* origin/main:
  fix(channels): honor explicit preview streaming settings
  refactor(telegram): consolidate outbound contracts and targets (#119438)
  fix(qa): retry transport cleanup and always stop owned labs (#119442)
  fix(mcp): guard stdio stdout frame parsing against oversized-buffer crash (#119379)
  refactor(auto-reply): centralize delivery deduplication and routing (#119436)
  fix(qa): preserve scenario isolation in serial suites (#119439)
  perf(xai): lazy-load optional capability runtimes (#119374)
  refactor(browser): consolidate browser CLI and normalization helpers (#119432)
  fix(qa): require ready transport accounts (#119431)
  refactor(media): share image and video geometry normalization (#119416)
  fix(config): preserve plugin metadata for missing config (#119421)
  fix: retry delivery when outbound adapter is unavailable (#119371)
  fix(cli): retire invalid secret flags and prove doctor recovery (#118926)
  refactor(signal): share outbound and reaction transport (#119415)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

1 participant