Skip to content

refactor(infra): consolidate bounded HTTP body reads - #99744

Merged
RomneyDa merged 2 commits into
mainfrom
refactor/http-body-consolidation
Jul 4, 2026
Merged

RomneyDa merged 2 commits into
mainfrom
refactor/http-body-consolidation

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Bounded HTTP response reads were owned by the private media package even though the primitive is transport infrastructure used across agents, gateway, plugins, media, and provider flows. That left HTTP lifecycle behavior coupled to a media-domain package and duplicated its ownership alongside request-body handling.

Why This Change Was Made

Moves the existing exact Web Response byte-limit implementation into src/infra/http-body.ts, preserving overflow, idle-timeout, cancellation, reader-lock, fallback, decoding, and caller-provided error behavior. Core callers and the existing Plugin SDK facades now use the infra owner; JSON/text interpretation, status handling, retries, logging, and provider policy remain with callers. The private @openclaw/media-core/read-response-with-limit subpath and its build/alias scaffolding are removed.

The deprecated plugin-sdk/infra-runtime barrel is pinned to its pre-existing request-body exports so the relocated response readers remain available only through the focused response-limit-runtime and existing media-runtime surfaces.

User Impact

No user-visible behavior change. Maintainers and plugin authors keep the same supported Plugin SDK response-limit APIs, with one canonical core owner for bounded HTTP request and response reads.

Evidence

  • Exact head: b5ed973ce800463d49e27067c620682f4c7f6657.
  • CI failure triage: checks-node-compact-small-whole-2 on the prior head failed deterministically in test/scripts/plugin-sdk-surface-report.test.ts; the relocation made existing package-backed exports source-resolvable and accidentally leaked two response readers through deprecated infra-runtime. This was branch-caused, not flaky or unrelated.
  • Fix proof: infra-runtime now preserves its exact prior request-body surface; source budgets are pinned to 10,414 public exports, 5,230 callable exports, and a reduced 212 wildcard re-exports.
  • node scripts/run-vitest.mjs test/scripts/plugin-sdk-surface-report.test.ts src/infra/http-body.test.ts src/infra/http-body.response.test.ts src/plugins/sdk-alias.test.ts src/plugins/contracts/plugin-sdk-subpaths.test.ts — 4 shards passed, 126 tests.
  • pnpm build — passed, including tsdown, Plugin SDK export checks, runtime postbuild, and Control UI build.
  • Blacksmith Testbox tbx_01kwndqmfeptbxbstfh2t85yy0 — pnpm check:changed passed full typecheck, core/extensions/scripts lint, guards, and runtime import-cycle checks.
  • Testbox Actions run: https://github.com/openclaw/openclaw/actions/runs/28691540557
  • .agents/skills/autoreview/scripts/autoreview --mode local --prompt-file tmp/notes.md --stream-engine-output — clean; no accepted/actionable findings, correctness confidence 0.98.
  • Production/config diff remains net-negative.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes security Security documentation scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: xai size: L maintainer Maintainer-authored PR labels Jul 4, 2026
@clawsweeper

clawsweeper Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 4, 2026, 2:50 PM ET / 18:50 UTC.

Summary
The PR moves bounded Web Response body reads from @openclaw/media-core into src/infra/http-body.ts, retargets core callers and Plugin SDK facades, and removes the old media-core response-reader subpath and aliases.

PR surface: Source +9, Tests -18, Config -11, Other -9. Total -29 across 40 files.

Reproducibility: not applicable. This PR is an owner-boundary refactor of an existing bounded response-reader, not a bug report with a failing user reproduction path.

Review metrics: 1 noteworthy metric.

  • Plugin API/package surface: 1 private package subpath removed; 2 public facades retargeted; 1 deprecated barrel pinned. The preserved public facades look intentional, but the removed package subpath and broad-barrel pin are the compatibility-sensitive surfaces maintainers should review.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🌊 off-meta tidepool
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] Protected security and maintainer labels require human owner handling before merge.
  • [P1] Removing the private @openclaw/media-core/read-response-with-limit subpath and resolver/build aliases can break any supported bundled-development or package-boundary workflow still relying on that path.
  • [P1] The helper now sits on shared provider, media, gateway, plugin, CLI, and ClawHub HTTP paths, so drift in byte caps, cancellation, or reader lock cleanup would be availability-sensitive.

Maintainer options:

  1. Owner/security review then land (recommended)
    Proceed once a human owner/security reviewer confirms the private media-core subpath removal is intentional and required checks are green on the current head.
  2. Keep a temporary private bridge
    If maintainers are not comfortable with immediate private subpath removal, preserve a narrow private bridge while still moving runtime ownership to infra.
  3. Pause the boundary cleanup
    Pause or close the PR if maintainers decide the internal ownership cleanup is not worth changing package alias and build scaffolding now.

Next step before merge

  • [P2] Protected labels and the intentional private package subpath removal require human owner/security review; there is no narrow automated repair finding.

Security
Cleared: No concrete security or supply-chain regression was found; the diff relocates an existing bounded-reader helper, removes a stale scanner exclude, and does not add dependencies, permissions, secrets handling, downloads, or lifecycle hooks.

Review details

Best possible solution:

Land the refactor only after owner/security review confirms the private media-core subpath removal is intentional and the documented openclaw/plugin-sdk/response-limit-runtime and media-runtime contracts remain stable.

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

Not applicable; this PR is an owner-boundary refactor of an existing bounded response-reader, not a bug report with a failing user reproduction path.

Is this the best way to solve the issue?

Yes, the owner-boundary shape looks maintainable: shared Web Response reads move to the existing infra HTTP-body owner while focused Plugin SDK facades remain. The unresolved decision is maintainer/security acceptance of removing the private media-core subpath.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5304d006e5f6.

Label changes

Label justifications:

  • P2: This is a normal-priority infrastructure/API-boundary refactor with limited intended user-visible impact but meaningful Plugin SDK and security-sensitive HTTP reader review needs.
  • merge-risk: 🚨 compatibility: The diff removes the private @openclaw/media-core/read-response-with-limit package subpath and alias/build scaffolding while preserving public Plugin SDK facades.
  • merge-risk: 🚨 availability: The relocated helper enforces byte limits, idle-timeout cancellation, and reader cleanup across multiple HTTP response paths.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor real-behavior proof gate is not applicable because this is a member PR with no claimed user-visible behavior change; PR body CI/Testbox evidence is still useful validation context.
Evidence reviewed

PR surface:

Source +9, Tests -18, Config -11, Other -9. Total -29 across 40 files.

View PR surface stats
Area Files Added Removed Net
Source 28 246 237 +9
Tests 3 2 20 -18
Docs 0 0 0 0
Config 3 1 12 -11
Generated 0 0 0 0
Other 6 6 15 -9
Total 40 255 284 -29

What I checked:

Likely related people:

  • steipete: GitHub commit metadata and blame connect this handle to the Plugin SDK response-limit surface and recent response-reader helper cleanup. (role: historical Plugin SDK and shared helper contributor; confidence: high; commits: 418056f7a0c8, 49cc59b1e88e; files: src/plugin-sdk/response-limit-runtime.ts, packages/media-core/src/read-response-with-limit.ts, src/infra/http-body.ts)
  • vincentkoc: Current-main blame attributes most of packages/media-core/src/read-response-with-limit.ts and the focused response-limit-runtime export to this handle. (role: bounded response-reader contributor; confidence: high; commits: 020f44aba867; files: packages/media-core/src/read-response-with-limit.ts, src/plugin-sdk/response-limit-runtime.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (2 earlier review cycles)
  • reviewed 2026-07-04T03:52:43.914Z sha b37b780 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-04T18:41:44.166Z sha d5430dc :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 4, 2026
@RomneyDa
RomneyDa force-pushed the refactor/http-body-consolidation branch from ca29db5 to b5ed973 Compare July 4, 2026 02:06
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 4, 2026
@RomneyDa
RomneyDa force-pushed the refactor/http-body-consolidation branch from b5ed973 to b37b780 Compare July 4, 2026 03:47
@RomneyDa

RomneyDa commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@RomneyDa
RomneyDa force-pushed the refactor/http-body-consolidation branch from b37b780 to d5430dc Compare July 4, 2026 18:37
@RomneyDa

RomneyDa commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@RomneyDa
RomneyDa merged commit 6c53dfa into main Jul 4, 2026
98 checks passed
@RomneyDa
RomneyDa deleted the refactor/http-body-consolidation branch July 4, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations extensions: xai gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts security Security documentation 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