Skip to content

refactor: make transport stream writer types honest - #124587

Merged
steipete merged 3 commits into
mainfrom
steipete/transport-stream-seam
Aug 16, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/transport-stream-seam

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a maintainer-requested type-safety gap where provider transports and the shared provider normalizer needed unsafe assertions to write valid assistant stream events. Those assertions obscured malformed partial snapshots and kept two files outside the chained-assertion guard.

Why This Change Was Made

The public creator already implements design A: it returns the concrete writer-capable assistant event stream, while consumer-only callers use the separate read-only contract. This change preserves that compatible public shape and makes each transport's mutable output structurally derive from the canonical assistant message. The generic plain-text tool-call normalizer now crosses one explicit adapter that restores required model identity, usage, stop state, and indexes before events reach the typed writer.

No creator return shape, public helper name, or Plugin SDK subpath changed.

User Impact

There is no intended user-visible behavior change. Provider and plugin developers now get compile-time checking for stream events instead of assertion-based type erasure, while legacy identity-light normalizer snapshots are materialized into the canonical event contract at one boundary.

AI-assisted; the implementation and evidence were reviewed with the repository autoreview workflow.

Evidence

  • Same-family unsafe assertions: 62 before, 0 after.
  • Assertion safety baseline: reduced by 62 across seven production files.
  • Chained-assertion ledger: removed the Google transport and provider stream normalizer entries (2 entries).
  • Production LOC: +183/-184 (net -1); tests: +236/-69; tooling/baseline: +7/-9.
  • pnpm run lint:no-chained-type-assertions
  • node --import tsx scripts/check-assertion-safety-ratchet.mts
  • node scripts/check-changed.mjs (green local fallback because no remote ci-fast provider was ready)
  • pnpm plugin-sdk:surface:check
  • Focused AI transport tests: 10 files, 208 tests passed.
  • Focused Plugin SDK/Google/Groq/Ollama/opencode-go/transport-helper tests: 8 files, 425 tests passed across 4 shards.
  • Exact CI provider-extension shard after fixture repair: 237 files, 3,827 tests passed (1 file/1 test skipped by design).
  • Partial-less delta contract: shared wrapper and agent-loop suites passed (181 tests), preserving append semantics and event omission.
  • Core and extension production/test TypeScript lanes passed.
  • Autoreview passed before commit and again on the rebased branch with no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 16, 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 scripts Repository scripts agents Agent runtime and tooling extensions: google size: L maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 13:05
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 9:45 AM ET / 13:45 UTC.

ClawSweeper review

What this changes

This PR replaces unsafe transport stream assertions with canonical assistant-event types and materializes legacy provider events at the shared plugin wrapper.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: the prior partial-less-delta blocker appears addressed by the latest commit, but this checkout cannot retrieve the PR head or declared current-main objects, and the exact-head extension check is failing.

Priority: P1
Reviewed head: 55868517c46a498307fe8ebf3038a8ee410e1c66

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The apparent repair is focused and addresses the prior finding, but unavailable exact-head source and a failed required shard prevent a stronger rating.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository state identifies this as a member-authored internal refactor; the contributor-proof gate does not apply, though exact-head validation is still required.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository state identifies this as a member-authored internal refactor; the contributor-proof gate does not apply, though exact-head validation is still required.
Evidence reviewed 4 items Stream contract: The canonical contract expressly permits text deltas without a partial snapshot, so wrappers must preserve that omission rather than synthesize an empty authoritative snapshot.
Current wrapper provenance: The current wrapper pushes normalized unknown events through an assertion-based writer seam; blame attributes this surrounding stream-wrapper path to Peter Steinberger.
Prior finding addressed in PR context: The supplied latest commit is fix(ai): preserve partial-less stream deltas, directly addressing the completed ClawSweeper P1 finding; its complete exact-head diff could not be loaded locally.
Findings None None.
Security None None.

How this fits together

Provider transports emit incremental assistant events, which plugin wrappers may normalize before the agent loop consumes them. Those events drive streamed assistant text and final tool-call results.

flowchart LR
  Provider[Provider transport] --> Events[Assistant stream events]
  Events --> Wrapper[Plugin stream wrapper]
  Wrapper --> Normalize[Event normalization]
  Normalize --> Agent[Agent loop]
  Agent --> Response[Assistant response]
Loading

Before merge

  • Resolve merge risk (P1) - Do not merge until the failed exact-head extension configuration shard is resolved and the complete head can be reviewed; the changed path carries live assistant stream events.
Agent review details

Security

None.

PR surface

Source -1, Tests +167, Other -2. Total +164 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 10 183 184 -1
Tests 9 236 69 +167
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 7 9 -2
Total 21 426 262 +164

Review metrics

Metric Value Why it matters
Production vs test LOC production net -1; tests net +167 The PR body reports assertion-removal refactoring with net-negative production code and expanded stream-contract coverage.

Merge-risk options

Maintainer options:

  1. Restore exact-head stream validation (recommended)
    Make the PR head available for review and resolve the failed extension shard before merge so streamed text delivery is verified on the submitted code.

Technical review

Best possible solution:

Validate the retrievable exact head, confirm the wrapper-to-agent partial-less-delta regression coverage, and land only after the failed extension shard is green.

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

Yes, source establishes the prior failure shape: text_delta.partial is intentionally optional. Exact after-fix reproduction could not be run because the PR head is unavailable in this checkout.

Is this the best way to solve the issue?

Unclear: the latest commit targets the prior blocker directly, but the exact PR-head implementation and its regression test could not be fully inspected locally.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2ceb18118ced.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository state identifies this as a member-authored internal refactor; the contributor-proof gate does not apply, though exact-head validation is still required.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The PR changes provider-to-agent streaming, where a regression can suppress live assistant output.
  • merge-risk: 🚨 message-delivery: The changed normalization boundary handles incremental text events that the agent loop uses for streamed responses.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository state identifies this as a member-authored internal refactor; the contributor-proof gate does not apply, though exact-head validation is still required.

Evidence

What I checked:

  • Stream contract: The canonical contract expressly permits text deltas without a partial snapshot, so wrappers must preserve that omission rather than synthesize an empty authoritative snapshot. (packages/llm-core/src/types.ts:423, 605dece17105)
  • Current wrapper provenance: The current wrapper pushes normalized unknown events through an assertion-based writer seam; blame attributes this surrounding stream-wrapper path to Peter Steinberger. (src/plugin-sdk/provider-stream-shared.ts:133, b9901605e83d)
  • Prior finding addressed in PR context: The supplied latest commit is fix(ai): preserve partial-less stream deltas, directly addressing the completed ClawSweeper P1 finding; its complete exact-head diff could not be loaded locally. (src/plugin-sdk/provider-stream-shared.ts:133, 55868517c46a)
  • Inspection limitation: The local partial clone is at 605dece rather than the declared current-main SHA and attempted PR-object retrieval failed because the promisor remote could not resolve; this review cannot attest the complete exact-head diff or its tests.

Likely related people:

  • steipete: Current-wrapper blame attributes the central path to Peter Steinberger, matching the PR author identity; the PR also contains the current fix for the previous stream-delta finding. (role: recent stream-wrapper contributor; confidence: medium; commits: b9901605e83d, 55868517c46a; files: src/plugin-sdk/provider-stream-shared.ts, src/plugin-sdk/provider-stream-event-normalization.ts)

Rank-up moves

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

  • Make the exact PR head reviewable and resolve the failed extension configuration check.
  • Confirm the partial-less text-delta regression test passes on that exact head.

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-16T13:12:59.303Z sha bb7423d :: found issues before merge. :: [P1] Preserve partial-less text deltas
  • reviewed 2026-08-16T13:33:54.459Z sha e613c8f :: found issues before merge. :: [P1] Preserve partial-less text deltas

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 16, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for head 55868517c46a498307fe8ebf3038a8ee410e1c66:

  • Exact-head CI run 31950382463 is green after rerunning failed job 95172924808. The first attempt's only failure was an unrelated memory-LanceDB mock observation; the isolated file passed locally (143/143) and the exact job rerun passed.
  • pnpm run lint:no-chained-type-assertions
  • node --import tsx scripts/check-assertion-safety-ratchet.mts
  • node scripts/check-changed.mjs (green local fallback; no remote ci-fast provider was ready)
  • pnpm plugin-sdk:surface:check
  • Focused AI transport proof: 10 files / 208 tests passed.
  • Focused SDK and provider proof: 8 files / 425 tests passed across four shards.
  • Exact provider-extension config proof: 237 files / 3,827 tests passed, with one file and one test skipped by design.
  • Partial-less delta proof: shared wrapper suite (115 tests) and agent-loop suite (66 tests) passed; text_delta.partial remains absent and the consumer accumulation test reaches Hello world.
  • Core and extension production/test TypeScript lanes passed.
  • Autoreview passed on the uncommitted patch, rebased branch, CI fixture repair, and P1 follow-up with no accepted/actionable findings.

Before/after: 62 same-family unsafe assertions to 0; assertion baseline -62; chained-assertion ledger -2. Production LOC +183/-184 (net -1); tests +236/-69; tooling/baseline +7/-9.

ClawSweeper's partial-less-delta move is applied. Its latest review has no actionable findings, and its exact-head CI concern is now resolved. No known proof gaps remain for this behavior-neutral type repair.

@steipete
steipete merged commit 99bda3d into main Aug 16, 2026
433 of 435 checks passed
@steipete
steipete deleted the steipete/transport-stream-seam branch August 16, 2026 14:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
* refactor(ai): give transport streams an honest writer type

* test(ai): use canonical transport stream fixtures

* fix(ai): preserve partial-less stream deltas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: google extensions: lmstudio extensions: xai maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts 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