Skip to content

test(gateway): speed up large-buffer assertions - #154351

Merged
steipete merged 1 commit into
mainfrom
codex/test-pdf-buffer-assertion
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-pdf-buffer-assertion

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two Gateway tests spend more time deeply comparing 9 MiB buffers than exercising attachment parsing and workspace materialization.

User Impact

No user-visible behavior changes. Both test files finish about twice as fast with lower peak memory.

Why This Change Was Made

Use Node's native exact-byte assertion instead of Vitest's per-byte object comparison. Keep the full 9 MiB inputs, decoded-byte expectations, real Git staging, bounded reads, permissions, corruption checks, and cleanup assertions.

Evidence

Linux Blacksmith Testbox comparisons against d68811807904, one Vitest worker, A/B/B/A order. Each value below is the mean of the two runs for that version:

Test file Cases per run Before command wall After command wall Mean peak RSS before → after
src/gateway/chat-attachments.test.ts 69 29.305s 13.731s 3,912 → 2,480 MiB
src/gateway/worker-environments/workspace-result-staging.reads.test.ts 12 32.476s 16.606s 3,949 → 2,463 MiB

The attachment comparison ran on tbx_01m30wbrkdtexvewzbcx1phrb7 (run); the workspace comparison ran on tbx_01m30xdahk8j0yky1arcs788m6 (run). Commands used pnpm test <file> --maxWorkers=1, including wrapper and collection costs.

All 81 focused cases remained unchanged and passed in every comparison. Focused and related policy, MIME, staging-concurrency, and manifest-worker suites passed 105 cases. A temporary mutation of the final decoded PDF byte failed the intended assertion. The selected two-file changed gate passed, including types, formatting, lint, and guards. Independent P2 review is clean. Exact-head CI passed. The attachment file passed 69 cases in 22.05s wrapper wall (19.60s Vitest duration); workspace reads passed 12 in 6.51s wrapper wall (4.62s Vitest duration). These hosted timings are separate from the controlled comparison above.

@clawsweeper

clawsweeper Bot commented Sep 21, 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 gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Sep 21, 2026
@steipete
steipete marked this pull request as ready for review September 21, 2026 03:19
@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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 2:31 PM ET / 18:31 UTC (Revision 3).

ClawSweeper review

What this changes

Replaces two Gateway test buffer comparisons with Node’s native assertions to reduce execution time and memory while preserving exact-byte checks.

Merge readiness

✅ Ready for maintainer review

The refreshed review found no actionable defects on the unchanged head. This remains useful, narrowly scoped work that is absent from fetched main and is protected from cleanup by maintainer context.

Priority: P3
Reviewed head: 25cb37bef9e8a8f2d9d43509ae04dd116515c6cf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct optimization with preserved regression coverage, reported performance measurements, and successful exact-head CI.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR changes test comparisons only; no production owner or user flow changes. Reported test benchmarks and mutation validation address its execution-cost claim, with exact-head CI independently verified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR changes test comparisons only; no production owner or user flow changes. Reported test benchmarks and mutation validation address its execution-cost claim, with exact-head CI independently verified.
Evidence reviewed 8 items Introduced patch and preserved coverage: The pinned introduction delta changes only assertion imports and two comparisons. Both 9 MiB fixtures remain; the workspace test still exercises actual Git operations, file contents, modes, bounded reads, corruption rejection, and cleanup. No production code changes.
Native assertion dependency contract: The introduced node:assert/strict imports directly depend on Node’s comparison contract. Node v24.16.0 compares typed-array byte lengths and calls its native byte comparator; it does not sample the payload.
Still useful on fetched main: Both affected test files on fetched main retain the previous Vitest comparisons. The file-scoped comparison contains exactly this PR’s assertion changes; it is behavioral context, not evidence that unrelated base changes belong to this PR.
Findings None None.
Security None None.

How this fits together

Gateway attachment parsing converts uploaded content into managed media, while workspace staging restores worker-produced files from Git. These tests verify the resulting bytes and retain checks for bounded reads, permissions, corruption rejection, and cleanup.

flowchart LR
  A[Uploaded attachment fixture] --> B[Attachment parser]
  B --> C[Decoded media bytes]
  D[Worker workspace fixture] --> E[Git staging and restoration]
  E --> F[Restored file bytes]
  C --> G[Native exact-byte assertions]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +4. Total +4 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 6 2 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 6 2 +4

Review metrics

Metric Value Why it matters
Reported test wall time Attachments 29.305→13.731 s; workspace reads 32.476→16.606 s The PR’s controlled comparisons report roughly halving execution cost while retaining the existing cases and full-size payloads.

Technical review

Best possible solution:

Keep the full-size regression fixtures and use native exact-byte comparisons without changing production behavior or weakening surrounding assertions.

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

Not applicable to a product bug: this optimizes test execution. The PR reports controlled before/after measurements; this review verified source semantics and exact-head CI without rerunning tests.

Is this the best way to solve the issue?

Yes. Using the existing Node assertion API preserves full byte comparison and avoids shrinking fixtures, sampling content, or introducing another helper.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a low-risk test-performance improvement with no user-visible runtime change.
  • 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 maintainer-authored PR changes test comparisons only; no production owner or user flow changes. Reported test benchmarks and mutation validation address its execution-cost claim, with exact-head CI independently verified.

Evidence

What I checked:

  • Introduced patch and preserved coverage: The pinned introduction delta changes only assertion imports and two comparisons. Both 9 MiB fixtures remain; the workspace test still exercises actual Git operations, file contents, modes, bounded reads, corruption rejection, and cleanup. No production code changes. (src/gateway/chat-attachments.test.ts:399, 25cb37bef9e8)
  • Native assertion dependency contract: The introduced node:assert/strict imports directly depend on Node’s comparison contract. Node v24.16.0 compares typed-array byte lengths and calls its native byte comparator; it does not sample the payload. (lib/internal/util/comparisons.js:194)
  • Still useful on fetched main: Both affected test files on fetched main retain the previous Vitest comparisons. The file-scoped comparison contains exactly this PR’s assertion changes; it is behavioral context, not evidence that unrelated base changes belong to this PR. (src/gateway/worker-environments/workspace-result-staging.reads.test.ts:132, d34acf900f16)
  • Latest-release check: The GitHub contents response for v2026.9.5 still uses expect(...).toEqual(bytes) in the multi-megabyte PDF test. No shipped replacement for that assertion was established. (src/gateway/chat-attachments.test.ts:317, ec9c1a13db89)
  • Exact-head CI: GitHub confirms the linked CI run completed successfully for the exact reviewed head. Tests were not executed during this read-only review. (25cb37bef9e8)
  • Reported performance and regression evidence: The captured PR body reports Linux Testbox A/B/B/A comparisons with one worker: attachment wall time 29.305→13.731 seconds and workspace wall time 32.476→16.606 seconds, with lower peak RSS. It reports all 81 focused cases passing, 105 focused/related cases passing, and rejection of a mutation to the final decoded PDF byte. These are contributor-reported measurements; the linked Testbox allocation runs have cancelled conclusions and do not independently authenticate those measurements. (25cb37bef9e8)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (2 earlier review cycles)
  • reviewed 2026-09-21T03:30:04.656Z sha 25cb37b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T03:57:49.619Z sha 25cb37b :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please refresh the completed review for unchanged head 25cb37bef9e8a8f2d9d43509ae04dd116515c6cf. The previous review is older than the native landing gate's twelve-hour freshness window; required CI remains green.

@clawsweeper

clawsweeper Bot commented Sep 21, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit 18b98eb into main Sep 21, 2026
172 checks passed
@steipete
steipete deleted the codex/test-pdf-buffer-assertion branch September 21, 2026 19:16
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 21, 2026
* commit '3d4033fbe0aca10c9eec45a7c088540607181d79': (42 commits)
  fix(windows): prevent update readiness failures on fractional timeouts (#155051)
  fix(test): await approval readiness and request cleanup (#155111)
  test(update): preserve published plugin archives in survivor fixtures (#155093)
  fix(ci): recover security review from inconsistent file lists (#155129)
  fix(crabbox): skip unused startup and preserve provisioning waits (#154321)
  fix(qa-lab): refresh Control UI links on URL updates (#152397)
  fix(maintainer): recover locally refused auto-merge requests (#154988)
  test(ui): advance debug tray polling with the browser clock (#155091)
  fix(snapshot): preserve concurrently recovered backups (#155075)
  fix(anthropic): preserve context-window-limited responses (#155029)
  fix(ui): stop redundant actions crowding mobile session titles (#154493)
  test(gateway): compare large buffers with native assertions (#154351)
  chore(ci): resync pull request head after the Actions incident
  fix: join local provider child cleanup before releasing ownership
  fix(test): isolate MXC host environment fixtures
  fix(test): prevent Windows worker pipe inheritance
  test(update): use supported reasoning in live survivor probe (#155085)
  fix(firecrawl): omit impossible publication dates from search results (#155032)
  fix(sessions): order WAL recovery and join probe release
  fix(logs): retain severity and subsystem from JSON console records (#153890)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime 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.

1 participant