Skip to content

test(media): avoid stale memory counters in base64 checks - #154808

Merged
steipete merged 1 commit into
mainfrom
codex/ci-base64-allocation-measurement-20260921
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/ci-base64-allocation-measurement-20260921

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: #154545

What Problem This Solves

Fixes false base64 memory-budget failures when Bun refreshes its last-collection heap counter during the measured operation.

User Impact

Internal test reliability only; production decoding behavior is unchanged.

Why This Change Was Made

Measure current heap and external memory through node:v8, construct the same 2 MiB whitespace fixture without a temporary split array, and keep assertions outside the measurement. Payloads, exact-output checks, and the 64 MiB/100 MiB budgets stay unchanged. No forced GC, retries, sleeps, or runtime exceptions are added.

Evidence

  • All 110 focused tests pass on Linux Node 24.19.0 and pinned Bun 1.4.3 (3ff0efc82); wrapper wall time: 2.16 s / 1.37 s.
  • A controlled collection at the real allocation boundary makes the old counter report 89,530,985 bytes and the current counter 11,251,250 bytes, with identical output and the unchanged 64 MiB limit.
  • Substituting the historical per-character implementation still fails the 100 MiB guard on both runtimes. Changed checks pass, including formatting, typechecking, lint and guards. Independent review is clean through P2.
  • Testbox evidence: base64 passes in the original 734-file Bun group. An unchanged history benchmark hit its 30-second child-process timeout; one standalone replay passed in 11.57 s. That does not establish a benchmark fix.

The exact timing of the original CI failure did not reproduce naturally. These remain coarse memory guards: the historical per-run implementation fits below 64 MiB in these probes, and Bun does not account for unexposed Buffer backing memory. Exposed backing memory is conservatively counted by both Bun fields.

Hosted CI run 35598468201 passed base64 but failed the unchanged cron handoff case holds adopted on-exit work until the previous scheduler drains (start): its heartbeat mock was still uncalled when vi.waitFor expired. The canonical cron fixture repair is now incorporated by a patch-identical refresh to 3c2ba0b79f435710d94c36cb764adb0e94f40789; the tested base64 file hash is unchanged. Fresh exact-head CI passed all 106 jobs, including the repaired cron shard (13 files / 283 tests).

@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 size: XS maintainer Maintainer-authored PR labels Sep 21, 2026
@steipete
steipete marked this pull request as ready for review September 21, 2026 12:15
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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, 11:32 AM ET / 15:32 UTC (Revision 4).

ClawSweeper review

What this changes

Updates base64 allocation tests to use current memory counters, avoid temporary fixture garbage, and measure canonicalization separately from assertions.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, focused test-reliability fix absent from current main and the latest release. No actionable correctness or security findings remain, and the reviewed head has successful CI.

Priority: P2
Reviewed head: 3c2ba0b79f435710d94c36cb764adb0e94f40789

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, adequately validated test repair with preserved assertions and candid measurement limitations.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored change only repairs tests around Media Core canonicalization; the external-contributor runtime-proof gate does not apply, and focused runtime measurements plus successful exact-head CI support the change.
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 change only repairs tests around Media Core canonicalization; the external-contributor runtime-proof gate does not apply, and focused runtime measurements plus successful exact-head CI support the change.
Evidence reviewed 8 items Pinned introduced change: The introduced patch changes only test measurement and fixture construction; exact-output assertions and the 64 MiB and 100 MiB limits remain intact. No production, dependency, workflow, or authority changes are introduced.
Current main still needs the repair: Fetched main retains process.memoryUsage measurements, split-array fixture construction, and assertions inside the measurement interval.
Latest release comparison: The supplied latest release, v2026.9.5, also retains the old measurement implementation. Its file was inspected through GitHub after the local release object was unavailable.
Findings None None.
Security None None.

How this fits together

Media Core validates and normalizes encoded attachments before downstream decoding. These tests check its output and coarse memory budgets without changing production behavior.

flowchart LR
  A[Encoded attachment fixtures] --> B[Base64 normalization]
  B --> C[Canonical output]
  D[Runtime memory counters] --> E[Allocation delta]
  B --> E
  C --> F[Exact output checks]
  E --> G[Memory budget checks]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests -2. Total -2 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 19 21 -2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 19 21 -2

Review metrics

None.

Technical review

Best possible solution:

Keep the existing allocation guards with current counters, low-garbage fixtures, unchanged budgets, and explicit limits on what the measurements prove.

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

No deterministic reproduction of the original CI timing is established; source confirms the stale-counter mechanism, and the body reports a controlled collection probe.

Is this the best way to solve the issue?

Yes. Repairing measurement and fixture allocation preserves the intended regression checks without relaxing thresholds, adding retries, or changing production code.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs a concrete allocation-test reliability problem with a bounded, test-only 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 change only repairs tests around Media Core canonicalization; the external-contributor runtime-proof gate does not apply, and focused runtime measurements plus successful exact-head CI support the change.

Evidence

What I checked:

  • Pinned introduced change: The introduced patch changes only test measurement and fixture construction; exact-output assertions and the 64 MiB and 100 MiB limits remain intact. No production, dependency, workflow, or authority changes are introduced. (packages/media-core/src/base64.test.ts:5, 3c2ba0b79f43)
  • Current main still needs the repair: Fetched main retains process.memoryUsage measurements, split-array fixture construction, and assertions inside the measurement interval. (packages/media-core/src/base64.test.ts:18, d61156bb5cfa)
  • Latest release comparison: The supplied latest release, v2026.9.5, also retains the old measurement implementation. Its file was inspected through GitHub after the local release object was unavailable. (packages/media-core/src/base64.test.ts:18, ec9c1a13db89)
  • Dependency contract supports the reported mechanism: The patch explicitly imports node:v8 and claims compatibility with pinned Bun. At the supplied Bun commit, process.memoryUsage reads heapSizeAfterLastCollection, while node:v8 getHeapStatistics obtains heapSize and extraMemorySize through jsc.heapStats. Repository ownership was verified through GitHub. (src/jsc/bindings/BunProcess.cpp:4226, 3ff0efc82217)
  • Validation and stated limits: The captured body reports 110 passing tests on Node and Bun, a controlled old/new counter comparison, and rejection of the historical per-character implementation by the unchanged 100 MiB guard. It explicitly discloses that natural failure timing was not reproduced and that Bun's backing-memory accounting is incomplete. These are coarse guards, not peak-memory proofs. (3c2ba0b79f43)
  • Successful CI on the reviewed head: GitHub confirms that run 35609840307 completed successfully for the exact reviewed head. No tests were executed during this read-only review. (3c2ba0b79f43)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: 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 (3 earlier review cycles)
  • reviewed 2026-09-21T12:23:01.126Z sha ad32230 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T12:59:22.933Z sha ad32230 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T14:17:30.556Z sha 3c2ba0b :: needs maintainer review before merge. :: none

Use current heap and external-memory statistics, build the same whitespace fixture without split-array garbage, and measure only canonicalization. Keep the existing payloads, output assertions, and memory budgets unchanged.
@steipete
steipete force-pushed the codex/ci-base64-allocation-measurement-20260921 branch from ad32230 to 3c2ba0b Compare September 21, 2026 14:05
@steipete
steipete merged commit 6e85e2b into main Sep 21, 2026
157 checks passed
@steipete
steipete deleted the codex/ci-base64-allocation-measurement-20260921 branch September 21, 2026 17:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
Use current heap and external-memory statistics, build the same whitespace fixture without split-array garbage, and measure only canonicalization. Keep the existing payloads, output assertions, and memory budgets unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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