Skip to content

refactor(video): deduplicate generation contracts - #130635

Merged
steipete merged 2 commits into
mainfrom
codex/cleanup20k-video-type-owner-20260826
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/cleanup20k-video-type-owner-20260826

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Video-generation contracts were duplicated between core and the plugin SDK, with a private assignability tuple and unused runtime binding keeping the copies in sync. This cleanup removes 223 net production lines while retaining the existing SDK contract.

Why This Change Was Made

The existing src/video-generation/types.ts contract module is the canonical owner. The SDK reexports its 15 shared types, matching image/music ownership. The declaration bodies and JSDoc are preserved exactly; both internal normalization types, the SDK builder-options type, and all runtime helper bodies are unchanged. No new module or SDK export is introduced.

The first published version incorrectly made the SDK runtime facade canonical. Ordinary CI caught a static type-import cycle despite zero runtime value cycles. That failure was reproduced locally and retained as evidence; this revision removes the reverse dependency instead of weakening the architecture guard. It addresses the ClawSweeper finding and rank-up move using the existing contract-only owner, so an additional neutral module is unnecessary.

The original local SDK copies came from a package-boundary repair. This revision therefore checks the generated declaration graph and real plugin package projects, not just source-level assignability. The ClawSweeper vector/embedding storage heuristic does not apply: this change has no persistent-store, schema, migration, or runtime-state surface.

User Impact

No intended behavior or API change. Provider contracts, export names and type/value namespaces, request fields, runtime helpers, private workspace declaration bridge, and package exclusions remain unchanged. Tests are retained. There is no external provider API change or live video-generation claim.

Production: +68/-291, net −223. Tests: 0. One required, canonically pruned assertion-baseline line is bookkeeping and excluded from the production count.

Evidence

Revised implementation proof, fresh independent published-head review and exact-head CI are complete as described below. Native preparation and merge remain separate steps; this is not a merge assertion.

  • Local canonical static and runtime import-cycle guards both pass with zero cycles. Pinned Linux repeats both checks successfully.
  • Targeted typed lint and 134 focused tests across seven files pass locally. The same 134 tests pass on Linux with Node 24.19.0, pinned Vitest 4.1.11, TypeScript 6.0.3 and tsdown 0.22.14.
  • Source AST/erasure checks prove all 15 declaration/JSDoc blocks, two internal types and the SDK builder contract/body are preserved; runtime output changes only by deletion of the unused compatibility binding.
  • Fresh clean-machine proof: Blacksmith Testbox run 33036055043, exact frozen base plus three-file patch, dependency/source equality and candidate-root aliases verified. The owned environment was cleaned and stopped after collecting the proof.
  • Full canonical changed gate passes all 33 selected checks, including types, lint, three Knip scans, SDK surface, ratchets and boundary guards. Fresh complete precommit Codex review reports no findings. Independent inspection of the actual generated source/declaration/package artifacts also passed.
  • Fresh canonical before/after builds pass. Built video SDK JavaScript is byte-identical. The same two pre-existing UI dynamic-import warnings occur on both sides, with unchanged UI sources.
  • Generated declarations pass strict compiler checks for all 31 exports, matching names, aliases, type/value namespaces, bidirectional assignability and no top-level any. The declaration files are not byte-identical: 15 existing type-only aliases gain explicit type qualifiers and move into the core-owned generated chunk. Both complete 27-file declaration closures resolve inside the package; actual package inventories preserve the private video declaration exclusion, workspace bridge and runtime export. Built SDK cold import and provider construction pass with source fallback disabled.
  • Four real plugin package projects pass: xai, alibaba, qwen and google. DeepInfra and OpenRouter hit the same existing generated private PinnedDispatcherPool identity error on both the untouched baseline and candidate; both implicated declaration chunks are byte-identical before/after. This is a named declaration-builder follow-up, not a six-project pass. No checker suppression or consumer workaround was added.
  • Fresh independent full published-head Codex review passed without findings. Exact-head CI run 33039188417 completed successfully on attempt 2. Attempt 1's compact job stopped before tests because Control UI startup gzip was 343,457 B against a 343,442 B budget; another job built the same merge at 343,416 B and passed. One standard failed-jobs retry passed with no source change, budget increase or suppression. The 41 B variability is observed; build-metadata attribution is an inference. UI-budget fragility is a separate follow-up.
  • Historical failures retained: the first published version's architecture-cycle failure; an initially over-strict declaration export-line byte assertion, corrected to exact parsed export/type semantics; and the reproduced baseline consumer declaration failures. Prior reviews/builds of the SDK-owner direction do not cover this revision.

AI-assisted implementation and review using Codex.

@clawsweeper

clawsweeper Bot commented Aug 27, 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: M maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete steipete self-assigned this Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 12:35 AM ET / 04:35 UTC.

ClawSweeper review

What this changes

The PR makes core’s video-generation types the single declaration owner and has the plugin SDK re-export those existing contracts while deleting the duplicate SDK copies.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking source-level finding remains: the revised topology resolves the prior SDK-to-core back-edge while preserving the public type names. Keep this maintainer-owned PR open for exact-head CI completion and normal maintainer review.

Priority: P3
Reviewed head: 18830f3a32ac7ad19fdbfcfc839949f997c3e4e0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The revised source topology is clean and preserves the package declaration path, with no actionable patch defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: repository context identifies this as a maintainer-authored, behavior-neutral refactor; exact-head CI remains a separate merge gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: repository context identifies this as a maintainer-authored, behavior-neutral refactor; exact-head CI remains a separate merge gate.
Evidence reviewed 8 items Prior finding resolved: The SDK now imports the two types used by its retained helper and re-exports all shared public video contracts from the core leaf; the prior reverse dependency is absent.
Core contract leaf is acyclic: The canonical contract file imports only core/media/config/auth types and has no plugin-SDK import.
Package declaration boundary includes the leaf: Both root and private SDK declaration programs explicitly include the core video type file, while the package keeps its public video-generation declaration entrypoint.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

$ node scripts/run-node.mjs --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 89.71 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.5s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ fun
… output truncated …
ry, scanning, and configuration
  node *               Run and manage the headless node host service
  nodes *              Manage gateway-owned nodes (pairing, status, invoke, and media)
  onboard *            Guided setup for auth, models, Gateway, workspace, channels, and skills
  pairing *            Secure DM pairing (approve inbound requests)
  plugins *            Manage OpenClaw plugins and extensions
  promos *             Discover and claim promotional model offers from ClawHub
  proxy *              Run the OpenClaw debug proxy and inspect captured traffic
  qr                   Generate a mobile pairing QR code and setup code
  reset                Reset local config/state (keeps the CLI installed)
  resume               Resume a recent Gateway session in the TUI
  sandbox *            Manage sandbox containers (Docker-based agent isolation)
  secrets *            Secrets runtime controls
  security *           Audit local config and state for common security foot-guns
  sessions *           List stored conversation sessions
  setup                Chat with OpenClaw; onboard when setup is incomplete
  skills *             List and inspect available skills
  status               Show channel health and recent session recipients
  system *             System tools (events, heartbeat, presence)
  tasks *              Inspect durable background tasks and TaskFlow state
  telemetry *          Inspect and manage anonymous usage telemetry
  terminal             Open a local terminal UI (alias for tui --local)
  transcripts *        Inspect stored transcripts
  triage               Collect sanitized diagnostics and prepare an agent debugging handoff
  tui                  Open a terminal UI connected to the Gateway
  uninstall            Uninstall the gateway service + local data (CLI remains)
  update *             Update OpenClaw and inspect update channel status
  users *              Manage durable user profiles and email alia
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw

How this fits together

Video provider plugins consume the public video-generation SDK contract, while core validates provider requests and dispatches generation. The PR changes declaration ownership between those layers without changing provider execution.

flowchart LR
  P[Provider plugins] --> S[Plugin SDK contract]
  S --> C[Core video contracts]
  C --> V[Video runtime validation]
  V --> O[Provider generation result]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI is still incomplete, and the supplied check state includes one failed compact job; its attribution cannot be established from the available read-only evidence.
Agent review details

Security

None.

PR surface

Source -223, Other -1. Total -224 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 68 291 -223
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 3 68 292 -224

Review metrics

Metric Value Why it matters
Production footprint production +68/-291 (net -223); tests 0; assertion baseline -1 The change removes duplicated declaration maintenance rather than adding a runtime path.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the core type leaf as the sole contract definition, retain the SDK’s stable re-export path, and merge only after the exact-head package/declaration checks are green or any failure is resolved as unrelated.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the core type leaf as the sole contract definition, retain the SDK’s stable re-export path, and merge only after the exact-head package/declaration checks are green or any failure is resolved as unrelated.

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

Not applicable: this is a declaration-ownership refactor rather than a reported runtime failure; source inspection traces the unchanged runtime and package declaration boundary.

Is this the best way to solve the issue?

Yes: core is already the runtime contract owner, and the SDK’s type-only re-export preserves its public path without the prior facade cycle. Exact-head generated-declaration verification remains required before merge.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 71d4a8c3e305.

Labels

Label changes:

  • add P3: This is a behavior-neutral declaration and ownership cleanup with no demonstrated user-facing regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: repository context identifies this as a maintainer-authored, behavior-neutral refactor; exact-head CI remains a separate merge gate.

Label justifications:

  • P3: This is a behavior-neutral declaration and ownership cleanup with no demonstrated user-facing regression.
  • 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: Not applicable: repository context identifies this as a maintainer-authored, behavior-neutral refactor; exact-head CI remains a separate merge gate.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the duplicate SDK and core contract declarations to Peter Steinberger, who also authored the revised contract-ownership commit. (role: recent video-contract contributor; confidence: high; commits: 682ddcb28cbe, 18830f3a32ac; files: src/plugin-sdk/video-generation.ts, src/video-generation/types.ts)

Rank-up moves

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

  • Complete exact-head CI and inspect or resolve the failed compact check if it is attributable to this PR.
  • Confirm the generated SDK declaration and package-boundary gates on the merge candidate.

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 (1 earlier review cycle)
  • reviewed 2026-08-27T03:07:26.713Z sha b5042af :: found issues before merge. :: [P2] Move shared contracts out of the SDK runtime facade

@steipete steipete changed the title refactor(video): reuse SDK generation types refactor(video): deduplicate generation contracts Aug 27, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

The revised cleanup keeps the existing core video contract module as the single owner and makes the SDK a type-only reexport. This removes 223 net production lines (tests unchanged) without adding a module or changing the 31 SDK export identities. The old SDK-owner back-edge was caught by CI, reproduced, and removed; the architecture guard was not weakened.

Validation for head 18830f3a32ac7ad19fdbfcfc839949f997c3e4e0:

  • node --import tsx scripts/check-madge-import-cycles.ts and node --import tsx scripts/check-import-cycles.ts: zero cycles, locally and pinned Linux.
  • node scripts/run-vitest.mjs src/video-generation/capabilities.test.ts src/video-generation/capability-overlays.test.ts src/video-generation/runtime.test.ts src/video-generation/dashscope-compatible.test.ts extensions/alibaba/video-generation-provider.test.ts extensions/qwen/video-generation-provider.test.ts src/plugins/contracts/extension-package-project-boundaries.test.ts: 134 tests across seven files passed.
  • node scripts/check-changed.mjs --staged --timed: all 33 selected checks passed on the exact frozen three-file candidate.
  • node --import tsx scripts/build-all.mts: fresh baseline and candidate builds passed. Strict generated TypeScript comparison preserves all 31 names, aliases and type/value namespaces; both full 27-file declaration closures and actual package inventories pass. Built video SDK JavaScript is byte-identical.
  • Clean-machine proof: Blacksmith Testbox run 33036055043, with complete source/dependency fingerprints, candidate aliases and all 99 generated AI artifact bytes verified. The owned environment was cleaned and stopped.
  • Complete precommit and independent published-head Codex reviews passed without findings. An independent source/generated-package artifact challenge also passed.

Four full consumer package projects pass. DeepInfra and OpenRouter reproduce the same existing nominal private-dispatcher declaration error on both baseline and candidate; both implicated generated chunks are byte-identical. This is a separate declaration-builder follow-up, not a six-project pass. No external provider API was invoked and no live generation behavior is claimed.

Exact-head CI run 33039188417 completed successfully on attempt 2. Attempt 1's compact test job stopped before tests because UI startup gzip was 343,457 B against a 343,442 B budget; another job in the same run built the same merge at 343,416 B and passed. One standard failed-jobs retry passed, including the aggregate gate, with no budget increase, source change or suppression. The 41 B variability is observed; its attribution to per-build metadata is an inference. UI-budget fragility is recorded as a separate follow-up.

ClawSweeper's updated review of this exact head reports no source findings. Its first rank-up move is satisfied by completed green exact-head CI and the inspected compact-job failure/recovery. For its second move, the same merge-candidate build actually executed the SDK declaration writer and export check: the declaration graph was 3,387,415 B and all 147 public plugin-SDK subpaths were verified. The hosted plugin-contract shards passed the nine extension-package project-boundary tests and 19 SDK package-contract guardrails (1,071 tests across 45 files overall). Built-plugin singleton smoke and the core-support boundary suite (120 tests across 11 files) also passed. The dedicated before/after private video declaration closure and package inventory proof is described above; the two reproduced baseline consumer failures remain explicit.

@steipete
steipete merged commit a678ed6 into main Aug 27, 2026
361 of 363 checks passed
@steipete
steipete deleted the codex/cleanup20k-video-type-owner-20260826 branch August 27, 2026 05:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 27, 2026
…-retirement-v13

* origin/main: (243 commits)
  fix: preserve Gateway error reasons in text logs (#130645)
  refactor(video): deduplicate generation contracts (#130635)
  fix(agents): preserve direct-message sender identity (#124548)
  fix(agents): preserve silent reply after settled tools (#130675)
  fix(talk): preserve replacement speech when an old utterance is canceled (#130687)
  fix(browser): preserve literal names and formatter-owned snapshot refs (#130599)
  fix(auth): reset only the profile replaced by a successful login (#124014)
  fix: bind session creation to admitted Gateway (#130686)
  refactor(qa-lab): reuse model reference splitter (#130317)
  docs(gateway): clarify independent HTTP endpoint switches (#130690)
  fix(ui): Control UI smooth scrolling ignores the reduced-motion preference (#130428)
  refactor(lmstudio): remove unreachable catalog merge (#130689)
  fix(crabbox): restore cloud machine CPU and RAM (#130684)
  fix(secrets): compare proxy bearer tokens directly (#127054)
  fix(matrix): show recovery key availability in text status (#128051)
  fix(ios): restore approval settings navigation and remove duplicate shell state (#130651)
  refactor(agents): use fixed tool-loop defaults directly (#130681)
  refactor(qa-lab): share process tree metric reader (#130419)
  refactor(models): simplify prepared owner access (#130683)
  fix(parallels): main install and update smoke cannot complete (#130658)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
* refactor(video): reuse SDK generation types

* refactor(video): keep shared contracts in core type leaf
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. 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.

1 participant