Skip to content

refactor(outbound): reuse prepared sendability facts - #142252

Merged
steipete merged 1 commit into
mainfrom
codex/perf17-outbound-prepared-content
Sep 8, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf17-outbound-prepared-content

Conversation

@steipete

@steipete steipete commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Closes #142251

Additional instructions

Maintainer edits are enabled on this repository-owned branch.

What Problem This Solves

This is a maintainer-authored and requested optimization. Command delivery normalizes rich reply content while building its outbound plan, then clones the payload and repeats rich-content normalization when deciding which transport entries to produce. The fresh plan already records the facts needed for that decision.

Why This Change Was Made

The internal outbound projector now reuses the prepared text/media, presentation, interactive and channel-data flags, together with the existing location-nullness check. Its sole production caller creates and consumes the plan synchronously, before another modifier or external callback runs. Output construction and object references remain unchanged.

Plans remain publicly mutable. The public SDK creator and delivery projector keep their existing behavior; this optimization applies only to the internal fresh-plan transport path. A bare audioAsVoice marker still produces a delivery/JSON tracking entry while producing no outbound transport entry. Actual voice media remains sendable.

User Impact

Less transient allocation while preparing rich command replies, with the same text, media, rich content, status and delivery behavior. Production changes by +6/-7 lines in one file; no tests, public API, configuration, queue or persistence behavior changes.

The actual full plan-plus-projection rich workloads measured approximately 27–30% lower sampled JavaScript allocation. For example, 750 rich-card operations changed from 14,099,488 to 10,165,792 sampled bytes. Separate already-prepared projection measurements showed 89–99% reductions for rich workloads; those exclude plan creation and are not full-path savings.

Evidence

  • 128 existing payload and command-delivery tests passed before and after. The complete selected changed-file gate and direct independent P2 review passed.
  • 216 lossless differential cases preserve plan, delivery, outbound, JSON and mirror values, input preservation, optional own fields, reference relationships, continuation markers and public mutable delivery projection. The audio-only tracking/transport distinction is explicitly checked. V8 snapshot hashes identify artifacts; equality is checked after deserialization rather than inferred from binary encoding.
  • Measurements use one A/B/B/A sequence per workload and mode, two observations per arm, with separate timing and 16 KiB V8 allocation sampling. Sampling includes collected objects. Plain-text controls vary, timing samples are not statistically conclusive, and larger tables/buttons deliberately amplify normalization work. No retained-heap, RSS, Gateway-memory or general latency claim is made.
  • Owner and command-caller bytes match the accepted baseline at captured main e321e32abde7b91f3ec1e83f599ea78e98c53673. Source and proof identities remain pinned.

Active #137530, #127653 and #80396 change plan construction independently. Preserve their text/media normalization and new plan facts if they land first, then recheck the corresponding output/reference cases. Release-note context: reuse prepared sendability facts for internal command transport while preserving public SDK and audio-only tracking behavior.

@clawsweeper

clawsweeper Bot commented Sep 8, 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 size: XS maintainer Maintainer-authored PR labels Sep 8, 2026
@steipete
steipete marked this pull request as ready for review September 8, 2026 15:00
@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 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 11:05 AM ET / 15:05 UTC.

ClawSweeper review

What this changes

Reuses prepared content flags when selecting command replies for transport, avoiding repeated payload copying and rich-content normalization.

Merge readiness

✅ Ready for maintainer review

This remains a useful, narrowly scoped optimization absent from current main. Source inspection supports equivalent filtering on the fresh-plan path, with no actionable correctness findings or outstanding prior findings.

Priority: P3
Reviewed head: 5fb42f127a6fc100c30f2f03a085d727e98724fc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving optimization with a verified caller invariant and appropriately bounded validation claims.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary external-contributor proof gate does not apply to this maintainer-requested internal refactor. The body reports differential and allocation checks of plan creation and projection; this review verified the production boundary from source without executing those checks.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary external-contributor proof gate does not apply to this maintainer-requested internal refactor. The body reports differential and allocation checks of plan creation and projection; this review verified the production boundary from source without executing those checks.
Evidence reviewed 8 items Pinned introduced change: The verified merge-base-to-head diff changes only the transport sendability predicate; output construction remains unchanged.
Prepared facts preserve the predicate: Plan creation computes text/media sendability and the same presentation, interactive, and channel-data predicates used by the former check. Media normalization retains nonempty attachments, and the patch preserves the explicit location-nullness condition.
Fresh synchronous consumption: The sole production caller constructs the final plan after asynchronous media normalization and immediately projects JSON and transport entries. No intervening modifier, await, or external callback runs on the successful projection path.
Findings None None.
Security None None.

How this fits together

Command delivery prepares reply text, attachments, and rich content into an outbound plan. The transport projector selects sendable entries from that plan before channel delivery.

flowchart LR
  A[Command replies] --> B[Normalize text and media]
  B --> C[Prepare content facts]
  C --> D[JSON tracking]
  C --> E{Sendable content?}
  E -->|Yes| F[Channel delivery]
  E -->|No| G[No transport entry]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1. Total -1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 6 7 -1
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 6 7 -1

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #142251
Summary: This PR implements the linked optimization request; the other referenced PRs address distinct plan-construction behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep the optimization confined to synchronous fresh-plan transport projection while preserving mutable SDK delivery behavior and existing output references.

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

Not applicable as a functional bug reproduction: source confirms redundant normalization, while the reported allocation measurements were not independently rerun.

Is this the best way to solve the issue?

Yes. Reusing facts at the sole fresh-plan consumer removes redundant work without changing public APIs, payload construction, or mutable delivery semantics.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is an internal allocation optimization with preserved behavior and no reported user-facing outage.
  • 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 ordinary external-contributor proof gate does not apply to this maintainer-requested internal refactor. The body reports differential and allocation checks of plan creation and projection; this review verified the production boundary from source without executing those checks.

Evidence

What I checked:

  • Pinned introduced change: The verified merge-base-to-head diff changes only the transport sendability predicate; output construction remains unchanged. (src/infra/outbound/payloads.ts:302, 5fb42f127a6f)
  • Prepared facts preserve the predicate: Plan creation computes text/media sendability and the same presentation, interactive, and channel-data predicates used by the former check. Media normalization retains nonempty attachments, and the patch preserves the explicit location-nullness condition. (src/infra/outbound/payloads.ts:256, 5fb42f127a6f)
  • Fresh synchronous consumption: The sole production caller constructs the final plan after asynchronous media normalization and immediately projects JSON and transport entries. No intervening modifier, await, or external callback runs on the successful projection path. (src/agents/command/delivery.ts:884, 5fb42f127a6f)
  • Public mutable-plan contract preserved: The plugin SDK exports plan creation and delivery projection, but not the changed transport projector. Delivery projection still returns each current payload directly. The implementation depends on OpenClaw-owned reply helpers, with no affirmative Codex dependency signal. (src/plugin-sdk/channel-outbound.ts:78, 5fb42f127a6f)
  • Existing behavior coverage: Inspected existing assertions for transport suppression, attachment preservation, channel-data-only payloads, status notices, and location projections. Source also preserves the distinction between audio-only tracking and actual sendable media. Tests were not executed in this read-only review. (src/infra/outbound/payloads.test.ts:692, 5fb42f127a6f)
  • Current main and release still repeat normalization: The fetched main source retains the original hasReplyPayloadContent call and payload spread. Inspection of v2026.9.3 shows the same original predicate, so neither inspected revision already contains this optimization. (src/infra/outbound/payloads.ts:302, 225845acbfe8)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • EricCai: 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 (1 earlier review cycle)
  • reviewed 2026-09-08T14:59:03.990Z sha 5fb42f1 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 7791e2b into main Sep 8, 2026
245 checks passed
@steipete
steipete deleted the codex/perf17-outbound-prepared-content branch September 8, 2026 15:48
@steipete

steipete commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 8, 2026
* commit '04869ae4899ad0524c3287759798362b0d62fef8': (677 commits)
  fix(release): pin Kova census refresh (#142104)
  fix: doctor read-only database inspections time out on large agent databases (#142179)
  docs: align v2026.9.3 framing with release announcement (#142307)
  fix(ui): discover models when default-model pickers open (#142105)
  fix(ci): keep Docker upgrade seed baseline older than target (#142273)
  refactor(tests): reuse named OAuth credential fixtures (#142272)
  fix(ci): keep mobile release helpers out of source checks (#142115)
  chore(ui): refresh control ui locales (#142147)
  fix(active-memory): explain why recall was skipped (#138658)
  fix(media): preserve converted images with HEIC filenames (#142263)
  docs: add v2026.9.3 release notes (#142277)
  fix(ui): retire picker focus listeners together (#142258)
  fix(ui): keep menu hover colors consistent across themes (#142243)
  fix(release): keep changelog credits within verified history (#142261)
  fix: keep tool-finalizer placeholders private in message-only groups (#138645)
  perf(tui): carry prepared URL membership through rendering (#142262)
  test(ui): await activity cache imports before teardown (#142282)
  fix(qa): align auth and Workshop proofs with runtime contracts (#142280)
  feat(xai): use one curated catalog and concrete setup default (#142136)
  refactor(outbound): reuse prepared sendability facts (#142252)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: XS 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.

Command transport projection repeats prepared rich-content normalization

1 participant