Skip to content

refactor(http): share bounded response byte consumption - #140654

Merged
steipete merged 1 commit into
mainfrom
steipete/dedup-infra-http-format-0906
Sep 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/dedup-infra-http-format-0906

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Bounded HTTP response readers in core, AI transports, the memory host, and the Dashboard repeat their chunk loop and byte accounting. Fixes to exact-byte limits can drift between these paths.

Why This Change Was Made

A browser-safe consumeResponseBytes leaf in @openclaw/normalization-core owns the shared loop, retained byte prefix, and limit notification. Callers keep their decoding, header validation, timeout and abort errors, cancellation lifetime, and reader cleanup. Memory JSON and snippet reads also share their existing reader adapter.

The core operation timer and AI per-read timer remain separate: they have different clamping, refresh, error, and cancellation contracts. Core/memory snippets still discard partial UTF-8; AI still emits the decoder replacement character; memory JSON still uses fatal UTF-8 decoding. Dashboard streaming decoding and its empty-chunk accounting are retained.

Related: #109245. That open PR correctly bounds the body-less error-snippet path by changing its fallback to empty text. This consolidation builds around it and does not duplicate that policy change. Inspected #136508 and #137230 too; those concern inbound Slack/Feishu request admission and do not overlap this response-reader change.

User Impact

None intended. Existing exported reader names and caller behavior are preserved. No configuration, dependency, schema, or protocol change.

Evidence

Fresh validation at 8b1054c820bebec32381a78515aba973e25722b6, rebased onto main e9a2a0298557451d28704b900bf3c4dfb0a4a99d. git range-diff confirms an identical patch; concurrent AI transport changes and the node-host umask correction (#140771) are retained.

  • node scripts/run-vitest.mjs src/infra/http-body.response.test.ts src/infra/http-error-body.test.ts packages/memory-host-sdk/src/host/response-snippet.test.ts ui/src/lib/response-body.test.ts ui/src/app/browser-bootstrap.test.ts ui/src/pages/chat/realtime-talk-webrtc-support.test.ts: 6 files, 103 tests passed.
  • node scripts/check-changed.mjs: passed, including core/test/UI types, lint, dead-export scans and ratchets. No baseline change.
  • pnpm build: passed in 7m 15.6s, including package and SDK declarations, plugin builds, runtime closure checks, and Dashboard assets/performance budgets.
  • Fresh Codex autoreview: scoped-clean at the requested command's default P0 threshold, zero findings. Prior P0–P2 review and 1,232 old/new reader comparisons are recorded in the original validation.
  • Production +109/-145 (net -36); tests +26/-0.
  • Exact-head CI passed on this exact head, with no reruns.

The former Workshop geometry CI failures are historical; this revision is being verified on current main. The ClawSweeper migration-proof checklist is inapplicable: only transient HTTP body consumption changes, with no schema or persistent-store semantics. No existing public export was removed or renamed. No live external-provider test is required for the unchanged transport policy; proof is at the response-reader/caller boundary.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 02:31
@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 Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 7, 2026, 7:52 AM ET / 11:52 UTC.

ClawSweeper review

What this changes

Shares HTTP response byte accounting across core, AI transports, memory-host, and Dashboard readers while retaining their existing decoding, timeout, and cancellation behavior.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this remains a useful consolidation, with no actionable introduced defect found. The previous migration-proof blocker is unsupported because the diff changes only transient response consumption.

Priority: P3
Reviewed head: 8b1054c820bebec32381a78515aba973e25722b6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused consolidation with preserved caller contracts and useful reported validation; no blocking defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this internal refactor from the external-contributor proof gate. Reported differential reader checks and focused tests support behavior preservation; they are not classified as live transport proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this internal refactor from the external-contributor proof gate. Reported differential reader checks and focused tests support behavior preservation; they are not classified as live transport proof.
Evidence reviewed 7 items Shared loop preserves caller policy: The helper accounts for bytes and invokes caller callbacks; core preserves exact-limit snippet termination, overflow rejection, deadline refresh, non-blocking cancellation, and deferred buffer allocation.
Memory and browser contracts: Memory JSON retains fatal UTF-8 decoding, header validation, abort propagation, and overflow errors. Dashboard retains streaming decoding and explicitly counts empty chunks; the added test protects rejection and reader unlock for negative budgets. These are transient buffers, with no database, persisted-format, migration, or plugin API change.
Current main and release necessity check: Fetched main still contains separate core and Dashboard loops. The shared response-bytes module is absent from both fetched main and the supplied latest-release commit, so this consolidation is not already implemented there.
Findings None None.
Security None None.

How this fits together

HTTP response readers turn incoming response streams into bounded diagnostic snippets, JSON, or browser text. Shared byte accounting enforces their limits while each caller controls decoding, errors, and reader cleanup.

flowchart TD
  A[HTTP response stream] --> B[Caller headers and deadlines]
  B --> C[Shared byte accounting]
  C --> D{Byte limit reached}
  D -->|No| E[Caller text or JSON decoding]
  D -->|Yes| F[Caller cancellation and limit handling]
  F --> G[Bounded snippet or size error]
  E --> H[Decoded response]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -36, Tests +26. Total -10 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 6 109 145 -36
Tests 1 26 0 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 135 145 -10

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: packages/memory-host-sdk/src/host/response-snippet.ts, unknown-data-model-change: packages/memory-host-sdk/src/host/response-snippet.ts, vector/embedding metadata: packages/memory-host-sdk/src/host/response-snippet.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep byte accounting shared while preserving caller-owned decoding, deadlines, errors, and cancellation lifetimes.

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

Not applicable: this refactor addresses duplicated implementation rather than a reported runtime failure; no target code was executed during review.

Is this the best way to solve the issue?

Yes: sharing the byte loop while leaving different decoder and lifecycle policies with their callers is a bounded consolidation of the existing implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ff599bc8f736.

Labels

Label justifications:

  • P3: This is internal consolidation with no intended user-visible behavior change or demonstrated urgent 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: The supplied MEMBER association exempts this internal refactor from the external-contributor proof gate. Reported differential reader checks and focused tests support behavior preservation; they are not classified as live transport proof.

Evidence

What I checked:

  • Shared loop preserves caller policy: The helper accounts for bytes and invokes caller callbacks; core preserves exact-limit snippet termination, overflow rejection, deadline refresh, non-blocking cancellation, and deferred buffer allocation. (packages/normalization-core/src/response-bytes.ts:2, 8b1054c820be)
  • Memory and browser contracts: Memory JSON retains fatal UTF-8 decoding, header validation, abort propagation, and overflow errors. Dashboard retains streaming decoding and explicitly counts empty chunks; the added test protects rejection and reader unlock for negative budgets. These are transient buffers, with no database, persisted-format, migration, or plugin API change. (packages/memory-host-sdk/src/host/response-snippet.ts:55, 8b1054c820be)
  • Current main and release necessity check: Fetched main still contains separate core and Dashboard loops. The shared response-bytes module is absent from both fetched main and the supplied latest-release commit, so this consolidation is not already implemented there. (src/infra/http-response-body.ts:35, ff599bc8f736)
  • Release tree check: Neither tree lists packages/normalization-core/src/response-bytes.ts; no fixing release is claimed. (3928bad9badf)
  • Validation and review continuity: The captured body at sourceRevision 4cdfb690e99deb7e2c64820d9599c844ce80eac4bd02a0ab8c00fde4627ccbd8 reports 103 focused tests, 1,232 differential cases, build, and UI performance validation on earlier revisions. These were not rerun. Previous review contains no findings; its migration request does not correspond to a changed storage boundary. Comparing the earlier reviewed SHA failed because its object was unavailable and GitHub DNS resolution failed; rebase equivalence therefore remains an author-reported claim. (8b1054c820be)
  • Related work remains distinct: Bound HTTP error body snippets to readable streams #109245 addresses the body-less diagnostic fallback, which this PR intentionally leaves unchanged. The supplied context identifies fix(ci): stabilize Workshop blank-line height checks #140718 as the merged correction for the historical Workshop geometry failure; it does not implement this response-reader consolidation. (src/infra/http-response-body.ts:96, 8b1054c820be)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • xingzhou: 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-07T02:36:41.994Z sha c14ddfaa934db1416d87cf8049ee015390335485 :: blocked before merge. :: none
  • reviewed 2026-09-07T02:55:04.815Z sha c14ddfaa934db1416d87cf8049ee015390335485 :: blocked before merge. :: none
  • reviewed 2026-09-07T03:12:14.976Z sha 67ec11a :: blocked before merge. :: none
  • reviewed 2026-09-07T03:18:23.780Z sha 67ec11a :: blocked before merge. :: none

Preserve caller byte caps, decoder modes, abort errors, and cancellation lifetimes. Keep distinct operation and per-read timeout policies.

Proof: focused response and Dashboard suites (103 tests), changed checks, and 1232 differential reader cases passed.
@steipete
steipete force-pushed the steipete/dedup-infra-http-format-0906 branch from 67ec11a to 8b1054c Compare September 7, 2026 11:46
@steipete
steipete merged commit a7e0881 into main Sep 7, 2026
193 checks passed
@steipete
steipete deleted the steipete/dedup-infra-http-format-0906 branch September 7, 2026 12:06
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 7, 2026
* commit 'b07b7d8bd1293c4e70ece7281b9cb8422318ae5a': (30 commits)
  fix(ui): keep reopened select menus visible (#141047)
  test(ui): fix dashboard gallery client fixtures (#141203)
  refactor(links): remove unused understanding results (#141200)
  refactor(plugins): share manifest contribution projection (#141193)
  refactor(logging): share portable redaction pattern mechanics (#140742)
  chore(ui): refresh control ui locales (#141208)
  refactor(minimax): reuse generated video asset downloader (#141094)
  fix(test): await Telegram loopback prompt reception (#141204)
  refactor(acp): remove unused in-memory event ledger (#141145)
  improve(models): reduce overhead in catalog discovery (#141154)
  refactor(channels): share approval reaction settlement (#140645)
  chore(i18n): refresh native locales (#141089)
  refactor: share one-shot tickets and WebSocket helpers across desktop, node, and browser streams (#141185)
  refactor(google-meet): share browser open and recovery setup (#140972)
  refactor(plugins): share npm version queries (#141166)
  refactor(http): share bounded response byte consumption (#140654)
  refactor(whatsapp): share prompt selection (#141195)
  fix: bound temporary storage for terminal upload batches (#141116)
  perf(markdown): reuse image parser configuration (#141126)
  fix(policy): align tool requirements with core vocabulary (#140628)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
)

Preserve caller byte caps, decoder modes, abort errors, and cancellation lifetimes. Keep distinct operation and per-read timeout policies.

Proof: focused response and Dashboard suites (103 tests), changed checks, and 1232 differential reader cases passed.
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 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