Skip to content

refactor: canonicalize correctness-critical UI and channel contracts #102258

Description

@RomneyDa

Summary

Canonicalize the three correctness-critical type contracts identified by the repository-wide type-surface audit: channel account status, Control UI gateway frames/payloads, and Workboard's plugin-to-UI model.

Problem to solve

OpenClaw currently maintains parallel hand-written descriptions of runtime contracts across core, gateway protocol, plugins, and Control UI:

  1. Channel account status is independently described by plugin/core status types, the gateway schema, sanitizer/projection code, and UI DTOs. These shapes have drifted, while public contribution types can still represent credential-shaped fields that status output must never expose.
  2. Control UI manually restates gateway request/response/event frames and protocol payload DTOs, relying on casts at the websocket boundary even where fields already disagree with the protocol owner.
  3. Workboard maintains separate plugin and Control UI model inventories that have diverged.

The duplication creates correctness and credential-redaction risk, permits silent drift, and forces changes to be synchronized across multiple mutable type owners.

Proposed solution

Deliver three independently reviewable contract consolidations in dependency order:

  • Establish the gateway schema-derived channel status DTO as the canonical output contract; separate plugin contribution/input types; project through one credential-dropping boundary; migrate channel status fixtures and Control UI rendering.
  • After the status owner lands, replace Control UI gateway frame/payload mirrors with protocol-derived types and protocol guards/projectors, keeping only genuine UI view models local.
  • Publish a narrow Workboard contract through a supported plugin/package seam and make Control UI consume it, while keeping presentation-only state local and avoiding core imports of plugin internals.

Each PR must inspect current main first, preserve runtime behavior unless a documented drift is being corrected, stay net-negative where practical, include focused proof, and avoid compatibility aliases unless a shipped public contract is demonstrated.

Alternatives considered

  • Add synchronization tests while keeping duplicate type inventories: rejected because multiple mutable owners and unsafe casts remain.
  • Create a broad shared common-types package: rejected because ownership and dependency direction differ across channel protocol, Control UI, and Workboard.
  • Combine all three changes into one PR: rejected because Workboard is independent while the UI gateway migration depends on the channel-status owner.
  • Use an external schema/code-generation service: rejected; current gateway schema, plugin package, and repository build seams are sufficient, and no overlapping maintained implementation was found in the current issue/PR search.

Impact

Affected: channel/plugin maintainers, Control UI maintainers, Workboard maintainers, and contributors changing gateway/status contracts.

Severity: High correctness and maintainability risk; the channel status boundary also carries credential-redaction sensitivity.

Frequency: Every change to these contracts currently requires manual synchronization across owners.

Consequence: silent DTO drift, unsafe casts, inconsistent UI behavior, redundant review surface, and increased risk of credential-shaped data reaching status projections.

Evidence/examples

Audit surfaces:

  • Channel status: src/channels/plugins/types.core.ts, src/channels/account-snapshot-fields.ts, packages/gateway-protocol/src/schema/channels.ts, ui/src/api/types.ts, ui/src/pages/channels/view.ts
  • Control UI gateway: ui/src/api/gateway.ts, ui/src/api/types.ts, packages/gateway-protocol/src/schema/frames.ts, packages/gateway-protocol/src/schema/types.ts
  • Workboard: extensions/workboard/src/types.ts, ui/src/lib/workboard/index.ts

Conservative expected reduction for this wave: approximately 485-535 net lines after canonical owners and necessary tests/build wiring.

Existing-solutions preflight on July 8, 2026 found no overlapping open implementation PR or issue. The repository's existing gateway protocol schema, plugin package seams, and source/build resolution mechanisms are the intended solution boundaries.

Additional information

Execution order:

  1. Channel status contract and Workboard contract may proceed in parallel because their write sets and owners are independent.
  2. Control UI gateway frame/payload consolidation starts after the channel-status contract lands or from a deliberately stacked branch if maintainers explicitly choose that review shape.
  3. Every PR requires focused tests, relevant TSGo/build/boundary gates, fresh autoreview, exact-head CI, and current ClawSweeper feedback before human merge.

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.enhancementNew feature or requestimpact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PRmaturity:stableIssue affects a taxonomy feature currently scored M4/M5.

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions