Skip to content

fix(test): expose full GC for portable retention checks - #195064

Merged
steipete merged 3 commits into
mainfrom
test/retention-gc-support
Nov 8, 2026
Merged

steipete merged 3 commits into
mainfrom
test/retention-gc-support

Conversation

@steipete

@steipete steipete commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Retention tests need a full-GC primitive that works without V8 heap inspection, and Node test workers currently do not expose globalThis.gc.

User Impact

This changes test infrastructure only. Caller migrations follow separately.

Why This Change Was Made

Extend the existing retention helper with Bun.gc(true) / exposed Node GC, specific-instance WeakRef assertions, and an explicit collection budget. Existing collector users retain eight passes; instance-count assertions use one. Collection runs inside the native immediate callback: collecting from a promise continuation can retain a completed caller in JavaScriptCore even after a full GC. The existing Node-argument owner adds --expose-gc unconditionally, so the existing Bun argument filter removes it. Node eval fixtures can request their own arguments through their existing helper. The independent compiler-based routing oracle runs through that real-Node helper because TypeScript’s synchronous IPC requires Node pipe handles; the planner under test still runs on each selected runtime.

Reference: oven-sh/bun#46709

Evidence

  • Verified on head b25bb5ae2ad47e1494c06090ee289f7aa1673c01: git diff origin/main -- src/test-utils/node-process.test.ts is empty (main 60b66097c5a6b39f40924a081e20c16842e11dc5). The actual-process probe was temporary and is absent from the PR.

  • Rebased onto the merged declaration repair from fix(ai): preserve OpenAI types in packed declarations #195098. The complete PR patch is byte-identical across the base update, so the local runtime proof is reused. Exact-head CI run 42461542237 passed on b25bb5ae2ad47e1494c06090ee289f7aa1673c01.

  • Actual before/after process captures passed on Node 26.12.1, stock Bun 2596ac5d3, and the pinned fork 191755ec1, in the same checkout. Each probe ran inside a real Vitest test and spawned a child through node-process.ts.

  • On both Buns, the top-level command, worker execArgv/argv, and child execArgv/argv are byte-identical. Node adds only --expose-gc to the top-level command. The measured execNodeEvalSync child is real Node even when Vitest runs on Bun. Direct createNodeEvalArgs consumers that choose process.execPath can spawn Bun; their unchanged default options add no GC flag.

  • Five real retention suites reject all eight deliberately retained test cases on Node, stock and fork; the same five restored suites pass all 64 tests on each runtime with the final native-callback helper (Node 62.97s, fork 49.95s, stock 52.70s and 42.90s on the required repeat). Areas: embedded attempt callbacks, plugin service runners, gateway scheduler callers, live-text delivery runs and browser import-state stores.

  • The WebSocket consumer also rejects both deliberate strong-reference cases on all three runtimes, then passes all 12 tests after release on Node, fork and two stock runs, with the original two collections.

  • Isolated strict typecheck of both support modules, the tooling test typecheck, formatting, and Codex review pass. The test-line ratchet passes with zero net test-line growth. The three existing runner/argument suites pass on Node and the pinned fork; the repaired full routing suite also passes on stock Bun (111 tests).

Runtime Top-level argv Worker argv Child argv
Node Adds --expose-gc before the CLI Identical Identical
Stock Bun Identical Identical Identical
Fork Bun Identical Identical Identical
SHA-256 of the actual captured argv values, before and after

Hashes include full, unshortened paths. Worker/child values include both execArgv and argv; process IDs are not argv and are excluded.

Runtime / boundary Before After
node / top ac56b433e975b62fbbf3a80dfbbfaffaf1c29e8b0c69bc7c020287d5108af2e4 628cd4d57deb329a1868278d127e7ddace5e86bd0ea26d6361a431495bc75b65
node / worker 6beff3c1329fdf9115cabe60a1a5ecdb7f58ee8aba19175ebcedeb4361188125 6beff3c1329fdf9115cabe60a1a5ecdb7f58ee8aba19175ebcedeb4361188125
node / child d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322 d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322
stock / top adc7bca6465c7eac4e8e97ce4a7b5b717c7d6d2e924798b4234a55cf4bb94f86 adc7bca6465c7eac4e8e97ce4a7b5b717c7d6d2e924798b4234a55cf4bb94f86
stock / worker 4253aa44dbdb3183e9d5a69d0cf52924dc5d46d03a96fd0b3fd641d16de5ba8a 4253aa44dbdb3183e9d5a69d0cf52924dc5d46d03a96fd0b3fd641d16de5ba8a
stock / child d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322 d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322
fork / top 0231e97f75456a121ceb7e90bb1367bb730d747b9ee879ead5b44b5ead3386ad 0231e97f75456a121ceb7e90bb1367bb730d747b9ee879ead5b44b5ead3386ad
fork / worker 44a157e2b9fce14c038c728641e787f0ad0175e11e92f55b7373c3887b3b24ba 44a157e2b9fce14c038c728641e787f0ad0175e11e92f55b7373c3887b3b24ba
fork / child d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322 d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322

The actual-process probe was repeated after the native-callback correction: Node 3.14s, stock 2.62s, fork 2.58s. All captured argv values equal the original after captures above. These short runs prove argument routing, not a performance claim.

Matched five-suite Node timing in one checkout (64 tests, both runs pass): 61.94s before → 56.48s after, 8.8% lower wall time. The original queryObjects test files and migrated files use the same common support dependencies. A separate matched WebSocket run passes all 12 tests at 5.46s before → 2.79s after. Each is one measurement pair, not a statistical benchmark.

No new test cases or net counted test lines were added in this support PR.

@clawsweeper

clawsweeper Bot commented Nov 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 scripts Repository scripts size: S labels Nov 8, 2026
@steipete
steipete marked this pull request as ready for review November 8, 2026 06:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T08:09:03.396722Z b25bb5a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds portable full garbage collection and WeakRef assertions to shared retention helpers and exposes GC in Node test processes.

Example: A retention fixture runs in a Node Vitest worker.

  • Before: The shared Vitest arguments omit --expose-gc, so the fixture can fail because globalThis.gc is unavailable.
  • After: The existing argument owner supplies --expose-gc, and retention checks use exposed Node GC or Bun.gc(true).

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation has no identified defect; validation is primarily reported harness evidence, and the existing CI failure remains unattributed.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored test-infrastructure PR is outside the ordinary contributor proof gate; its body reports actual Vitest process probes and retention negative controls, without independently inspectable raw captures.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Developers cannot reliably run portable retention checks when Node workers lack exposed GC or assertions depend on V8 heap inspection.
Reason: The maintainer-authored direction provides a focused foundation for portable retention tests while leaving caller migrations explicitly separate.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR provides useful test infrastructure, and no concrete introduced defect was found.

Priority: P3
Reviewed head: 55bdd38ca654550503e079ee689b1dba9299b321

Before merge

None.

Findings

None.

Agent review details

How this fits together

The test runner constructs runtime arguments, Vitest starts workers, and shared retention fixtures collect objects before checking their WeakRefs.

flowchart LR
  A[Test invocation] --> B[Shared Node argument owner]
  B --> C[Runtime selection]
  C --> D[Vitest workers]
  D --> E[Shared retention helper]
  E --> F[Node GC or Bun GC]
  F --> G[WeakRef assertions]
Loading

Technical review

Best possible solution:

Keep portable collection and runtime flags in their existing shared owners, preserving the declared separation from caller migrations.

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

Current-main source shows the Node-only GC requirement and missing shared exposure flag; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch uses the existing owners, preserves existing collection budgets and subprocess defaults, and retains the independent routing assertions without unnecessary new machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared Vitest runtime arguments keeps the original intent (6869e37: Separate Node execution flags from test inventories and watchdog policy; the subsequent native-byte API change retained that owner.)
  • Node eval subprocess helpers keeps the original intent (1586085: Share Node eval argument construction and execution; later Bun portability work selected a real Node executable.)
  • Retention collector keeps the original intent (65829ea: Prove completed callers collect while their lifecycle resources remain usable, with bounded GC passes and an unowned control.)
  • Independent routing oracle keeps the original intent (b4e0c53: Replace a brittle frozen importer inventory with independently derived routing coverage; the later compiler migration supplied native AST parsing.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduction reviewed: The introduced diff extends existing argument, subprocess, and retention owners; the other endpoint differences are base movement. (55bdd38ca654)
  • Current main still lacks the support: Fetched main retains the Node-only collector and omits --expose-gc from shared Vitest arguments. (src/test-utils/retention.ts:8, 9b8aa392679f)
  • Existing runtime cutover retained: Bun removes Node-only flags through the existing resolver-derived filter; fork workers already obtain arguments from the same owner through global setup. (scripts/lib/vitest-test-runtime.mts:53, 55bdd38ca654)
  • Collection invariant preserved: Existing callers keep eight collection passes and the collectible control assertion; the new instance assertions explicitly request one pass. (src/test-utils/retention.ts:31, 55bdd38ca654)
  • Routing oracle preserves its original purpose: History establishes that the independent importer inventory protects complete routing without brittle frozen lists; the PR moves that same oracle into real Node while retaining planner execution in the selected runtime. (test/scripts/test-projects-routing.test.ts:459, b4e0c5306cd0)
  • CI failure remains unattributed: The reviewed-head checks-node-changed job fails in the external packed AI consumer with TS2456 circular declaration aliases, and ci-gate reports that failure. No matching base failure or head-versus-revert comparison was established. Full logs redirect to a blocked host, but GitHub annotations expose the failure. (packages/ai/src/package.e2e.test.ts:63, 55bdd38ca654)

Likely related people:

  • Vincent Koc: Raw commit 9651d63 adds scripts/lib/vitest-node-args.mts:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9651d6347b1a; files: scripts/lib/vitest-node-args.mts)

PR surface

Tests +29, Other 0. Total +29 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 78 49 +29
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 6 79 50 +29

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P3: This improves development test infrastructure without changing shipped user behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This improves development test infrastructure without changing shipped user behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Establish whether the packed AI declaration failure also occurs without this patch.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 8, 2026, 1:52 AM ET / 06:52 UTC.

Keep the runtime capability check in the existing retention helper. Node test processes expose GC while Bun keeps its current argv and uses Bun.gc(true). Add instance-level retention assertions without changing the existing collector budget, and let Node eval fixtures request explicit runtime arguments.
Run the independent TypeScript AST oracle through the real-Node test helper while preserving planner coverage on each Vitest runtime. TypeScript synchronous IPC requires Node pipe handles. Remove the test-line allocation now that the support change has no net test-line growth.
@steipete
steipete force-pushed the test/retention-gc-support branch from 55bdd38 to b25bb5a Compare November 8, 2026 08:07
@steipete
steipete merged commit 754b41c into main Nov 8, 2026
164 of 166 checks passed
@steipete
steipete deleted the test/retention-gc-support branch November 8, 2026 08:20
@steipete

steipete commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
)

* fix(test): expose full GC for portable retention checks

Keep the runtime capability check in the existing retention helper. Node test processes expose GC while Bun keeps its current argv and uses Bun.gc(true). Add instance-level retention assertions without changing the existing collector budget, and let Node eval fixtures request explicit runtime arguments.

* fix(test): isolate native compiler oracle on Node

Run the independent TypeScript AST oracle through the real-Node test helper while preserving planner coverage on each Vitest runtime. TypeScript synchronous IPC requires Node pipe handles. Remove the test-line allocation now that the support change has no net test-line growth.

* fix(test): collect retention checks from native callbacks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S 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