-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Feature]: Consolidate Wave 1 internal type contracts #100977
Copy link
Copy link
Open
Labels
P3Low-priority cleanup, docs, polish, ergonomics, or speculative work.Low-priority cleanup, docs, polish, ergonomics, or speculative work.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.enhancementNew feature or requestNew feature or requestimpact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.maintainerMaintainer-authored PRMaintainer-authored PRmaturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.
Description
Metadata
Metadata
Assignees
Labels
P3Low-priority cleanup, docs, polish, ergonomics, or speculative work.Low-priority cleanup, docs, polish, ergonomics, or speculative work.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.enhancementNew feature or requestNew feature or requestimpact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.maintainerMaintainer-authored PRMaintainer-authored PRmaturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.
Type
Fields
Priority
None yet
Summary
Consolidate the first low-conflict set of duplicated and stale internal type contracts identified by the repository-wide type-surface audit.
Problem to solve
Three internal areas currently maintain parallel type descriptions instead of one canonical owner:
.d.mtscompanions omit live exports, so tests copy shadow module interfaces and useas unknown ascasts.src/gateway/client.tsredeclares the gateway-client package option/event contract, while the package repeats protocol guards and error shapes.PluginRegistrymarks collections optional even though the loader always initializes them, producing widespread defensive fallback branches.These duplicate contracts can drift silently, obscure real invariants, and add substantial review/navigation overhead.
Proposed solution
Implement three independently reviewable PRs:
packages/gateway-clientandpackages/gateway-protocolthe canonical client/guard owners, leaving only core-owned construction policy insrc/gateway/client.ts.PluginRegistrycollections required and delete unreachable fallback branches. Lifecycle-state union work is explicitly out of scope for this wave.Each PR should preserve runtime behavior, include focused regression/type proof, and avoid compatibility aliases unless a shipped public contract is demonstrated.
Alternatives considered
Impact
Affected: OpenClaw maintainers and contributors working on scripts/CI, gateway clients, and plugin loading.
Severity: Medium maintainability and correctness risk.
Frequency: Every change to the duplicated contracts requires manual synchronization; drift is already present in declaration companions.
Consequence: unsafe casts, redundant branches, slower review, and increased chance of contract divergence.
Evidence/examples
The read-only audit identified the primary surfaces at:
scripts/test-projects.test-support.d.mts,scripts/docs-link-audit.d.mts,scripts/ci-changed-scope.d.mts,scripts/lib/vitest-local-scheduling.d.mtssrc/gateway/client.ts,packages/gateway-client/src/client.ts,packages/gateway-protocol/src/index.tssrc/plugins/registry-types.tsConservative expected reduction for this wave: approximately 305-345 net lines while reducing the number of canonical type paths.