Skip to content

fix: restore protocol declaration builds - #135360

Merged
steipete merged 2 commits into
mainfrom
codex/fix-protocol-declaration-size
Sep 1, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-protocol-declaration-size

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where developers building OpenClaw from current source encounter TS7056 during protocol declaration generation and cannot complete the build.

Why This Change Was Made

The public protocol registry's inferred type exceeds TypeScript's declaration serialization limit. Annotate that export with the exact intersection of its existing named fragment types. The composer remains the runtime owner, with identical fragment order, schema objects, and duplicate-key rejection.

Update the existing registry guard to recognize the annotated declaration and require its type fragments to match the composed fragments in order. This also prevents future edits from silently narrowing the exported registry type. No new parser or runtime path is introduced.

User Impact

Source builds complete while preserving the registry's closed keys and exact property types. There are no wire-schema, protocol-version, configuration, or persistence changes.

Evidence

  • Before: the protocol package build fails with TS7056 at the inferred registry export. After the annotation: the package build and full pnpm build pass. The guard-only follow-up was then checked through the complete pnpm protocol:check pipeline; Swift and Kotlin generated sources remain unchanged.
  • All 867 registry keys and property types are identical under the installed TypeScript checker, with mutual assignability and no owner semantic diagnostics. Erased JavaScript is byte-identical. The generated 3,563,224-byte schema document is byte-identical, including 867 definitions and 402 methods.
  • Three existing composer tests pass. Ten actual registry-guard CLI fixtures produce the expected results: one valid registry passes; missing, duplicate, extra, reordered, broad, and absent type annotations and malformed runtime fragment lists are rejected.
  • Independent review identified the old guard recognizer as an integration failure; that finding is fixed and the follow-up review is clear. Isolated Codex autoreview is also clear.

Production declaration source: +16 lines. Tooling: +11 lines. Tests/generated files: unchanged. The named type boundary preserves precise public types without widening them to an open record. This is a build repair; no memory or latency improvement is claimed.

The review's coupling concern is addressed by landing the exact annotation and its matching guard together. The existing required protocol-check pipeline enforces that correspondence; the ten actual CLI fixtures cover drift and malformed declarations. The composer remains the sole runtime owner. Exact-head CI is now green.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 12:56 PM ET / 16:56 UTC.

ClawSweeper review

What this changes

The PR explicitly types the public Gateway protocol schema registry and updates its structural guard to verify that the annotation exactly matches the ordered runtime fragments.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. The patch preserves the registry’s runtime composition while naming its exact fragment intersection for declaration emission; no concrete correctness or security defect was found. This is a member-authored, maintainer-labeled PR, so automated closure is not appropriate.

Priority: P2
Reviewed head: beb0a798c235f7c07a95e2f7d0bb6d194e982318

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-consistent build repair with a guard for the new declaration invariant.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored build repair has no user-visible runtime flow; the PR body supplies reported before/after build and protocol-check results, while this read-only review did not execute repository code.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored build repair has no user-visible runtime flow; the PR body supplies reported before/after build and protocol-check results, while this read-only review did not execute repository code.
Evidence reviewed 6 items Current-main failure surface: Current main exports the composed registry without a named type boundary, while the published package build emits declarations for its public entry points.
Exact type and runtime composition: The proposed annotation lists the same 16 fragment bindings, in the same order, as the unchanged composer input; the composer still preserves objects and rejects duplicate keys.
Guard covers the new invariant: The guard now extracts the annotation and fails unless every typeof binding exactly matches the ordered runtime fragment list; it retains the existing import, uniqueness, and runtime-key checks.
Findings None None.
Security None None.

How this fits together

Gateway protocol fragments form one registry consumed by declaration generation and native/schema generators. The registry guard validates its fixed composition before generated protocol artifacts are checked.

flowchart LR
  A[Protocol schema fragments] --> B[Public schema registry]
  B --> C[Declaration build]
  B --> D[Registry consistency guard]
  B --> E[Schema and native generators]
  D --> F[Protocol check pipeline]
Loading

Before merge

  • Resolve merge risk (P1) - The repair adds 27 net production/tooling lines with no new test file; the explicit 16-fragment intersection and matching guard are justified by the declaration boundary, but should remain tightly coupled.
Agent review details

Security

None.

PR surface

Source +16, Other +11. Total +27 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 17 1 +16
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 14 3 +11
Total 2 31 4 +27

Review metrics

Metric Value Why it matters
Production versus test delta production +27 net; tests +0 The build repair grows only the declaration boundary and its structural guard; no runtime schema, wire format, config, or generated artifact changes are introduced.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge the explicit exact-intersection annotation with its paired guard, retaining the composer as the sole runtime composition owner and the existing protocol-check pipeline as the regression boundary.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge the explicit exact-intersection annotation with its paired guard, retaining the composer as the sole runtime composition owner and the existing protocol-check pipeline as the regression boundary.

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

No direct reproduction was run because this read-only review prohibits builds. The PR evidence reports TS7056 before the change, and current source confirms the public declaration-emitting registry path.

Is this the best way to solve the issue?

Yes. The annotation preserves the composer’s exact intersection rather than widening the public registry, and the updated guard prevents its type list from drifting from runtime composition.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 83e75f5e3101.

Labels

Label changes:

  • add P2: This repairs a source-build declaration failure in a published protocol package without evidence of a runtime outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This repairs a source-build declaration failure in a published protocol package without evidence of a runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Current-main failure surface: Current main exports the composed registry without a named type boundary, while the published package build emits declarations for its public entry points. (packages/gateway-protocol/src/schema/protocol-schemas.ts:20, 83e75f5e3101)
  • Exact type and runtime composition: The proposed annotation lists the same 16 fragment bindings, in the same order, as the unchanged composer input; the composer still preserves objects and rejects duplicate keys. (packages/gateway-protocol/src/schema/protocol-schemas.ts:21, beb0a798c235)
  • Guard covers the new invariant: The guard now extracts the annotation and fails unless every typeof binding exactly matches the ordered runtime fragment list; it retains the existing import, uniqueness, and runtime-key checks. (scripts/check-protocol-registry.mts:41, beb0a798c235)
  • Generator consumer remains unchanged: Protocol generation passes the registry directly into the schema-document builder, so the type-only annotation does not alter the generator’s runtime input. (scripts/protocol-gen.ts:39, beb0a798c235)
  • Main has not already absorbed this PR: The fetched main commit descends from the PR base but does not contain the PR head; current main still has the unannotated export. (83e75f5e3101)
  • History limitation: A deeper blame/log pass for pre-PR ownership could not complete because this partial checkout attempted an unavailable promisor remote; the review therefore does not assert feature-introduction ownership.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 1, 2026
* fix(build): preserve protocol schema references in declarations

* build: validate typed protocol registry fragments
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
* fix(build): preserve protocol schema references in declarations

* build: validate typed protocol registry fragments
SebTardif added a commit to SebTardif/openclaw that referenced this pull request Sep 3, 2026
Replay onto current origin/main. Take main generated metadata, then
pnpm config:channels:gen. Keep ReplyToModeSchema.optional(). Skip
protocol restore already on main via openclaw#135360.

Signed-off-by: Sebastien Tardif <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR scripts Repository scripts size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant