Skip to content

fix(test): make retention checks portable across runtimes - #195091

Merged
steipete merged 7 commits into
mainfrom
test/queryobjects-retention
Nov 8, 2026
Merged

steipete merged 7 commits into
mainfrom
test/queryobjects-retention

Conversation

@steipete

@steipete steipete commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Uses the shared GC support landed in #195064 (754b41c65df0f72d3a6df1eb6abd810644b60190). Local runtime proof and fresh exact-head CI pass for the selected migrations.

What Problem This Solves

Stock Bun lacks V8's queryObjects, so these retention suites fail before checking whether callers and resources are released.

User Impact

This changes tests and test support only. It migrates 68 test files, preserving the existing release checks and exact zero/one/multiple live-instance counts.

Why This Change Was Made

Use the existing shared retention owner and track each instance the test creates with WeakRefs. GC-only sites keep their existing job boundaries and collection budgets, including the conditional 20-turn inventory ceiling. The WebSocket test uses two native-callback collections so a suspended promise frame does not create false retention. The nested runner fixture uses the existing real-Node compiler resolver while its tests continue on the selected runtime. Extension tests consume the same GC owner through the existing SDK test-env entrypoint; fixture factories track plain objects where class identity is no longer needed.

The cutover removes 45 GC-only query sites and 36 class-count query sites, including the shared helper whose 15 assertions now use explicit WeakRef registries. No production hook, runtime version check, dependency, pin, or Bun admission change is added.

Reference: oven-sh/bun#46709

Evidence

  • Required runtimes: Node 26.12.1, stock Bun 2596ac5d3, and pinned fork 191755ec1, through scripts/run-vitest.mjs with one worker. At head 837a8bae394, full 72-file runs pass Node (547.93s), fork (534.91s) and first stock (493.57s). Second stock completes in 375.92s with one failure in the now-held registry file. All 71 files in the landing selection (68 caller tests plus three runner suites) pass in all four runs. The failed full stock run remains recorded as failed.

  • CI repairs for private extension-test imports, constructor-only fixture classes, and three shadowed WeakRef bindings pass configured lint/boundary checks, fresh Codex review and the full runtime selections above. The additional hold has fresh scoped P0–P2 review; its complete file matches main.

  • Previous runs hit pinned-Bun staging before tests/lint. Main now includes the release-asset fallback (fix(ci): cache verified Bun release assets across test jobs #195139) and lint/docs/boundary setup (fix(ci): prepare verified Bun before parity checks #195155). Merged current main be0b106c3a9 (including ea133a4a4d40) as 36c23a67954, without conflicts or any change to the reviewed caller diff. All seven held files match main. Fresh exact-head CI run 42473537578 passes on 36c23a67954; no old runs were rerun.

  • Five real retention suites were temporarily given strong references. All three runtimes rejected all eight affected identities at the intended live-instance assertion. After restoring the source bytes, all five suites (64 tests) passed on Node, fork and two stock runs. Areas: embedded attempt callbacks, plugin service runners, Gateway scheduler callers, live-text delivery and browser import-state stores.

  • The new WebSocket migration rejects both deliberate strong-reference cases on all three runtimes. Its restored 12-test file passes Node, fork and two stock runs with the original two collections.

  • Matched five-suite Node wall time in one checkout: 61.94s before → 56.48s after (8.8% lower), with both 64-test selections passing. A matched WebSocket comparison passes all 12 tests at 5.46s before → 2.79s after. Each comparison is one measurement pair, not a statistical benchmark. A final-head repeat after the SDK test-entrypoint repair also passes all 64 tests in 53.00s.

  • No JIT override, extra retry, longer settle budget, or weaker assertion was used. The native callback changes where the same collection runs. The final combined caller patch has a scoped-clean P0–P2 Codex review. The exact counted test-line increase is 15 LF, with its own allocation; no new test cases were added.

These seven files remain byte-identical to main. Their migrations are held rather than weakening assertions:

File Disposition and evidence
packages/ai/src/transports/openai-responses-continuation.retention.test.ts held: runtime gap — stock retains one caller; Node/fork clear it.
src/agents/embedded-agent-runner/run.session-prompt-state.test.ts held: runtime gap — stock retains one message payload; Node/fork clear it.
src/plugins/services.scheduler-context.test.ts held: runtime gap — stock retains one registry; Node/fork clear it.
src/plugins/http-registry.test.ts held: runtime gap — stock retains a leased HTTP registry; Node/fork clear it.
src/agents/prepared-model-catalog-worker.heap.integration.test.ts held: runtime gap — stock misses a borrowed-model result even on the unchanged baseline. The helper-import regression is resolved by a test-only entry-module bootstrap; the focused snapshot check passes Node, fork and two stock runs. That diagnostic migration is not included while the baseline runtime gap remains.
src/plugins/plugin-instance-module-loader.failed-acquisition.test.ts held: runtime gap — stock lacks Module.registerHooks before reaching collection.
src/plugins/registry.runtime-config.test.ts held: stock-only intermittent retention — pending custody release passes Node/fork/first stock, but second stock retains one instance. Isolated and cohort replays pass and do not prove repair or confirm #44438. The entire migration is excluded.

The four repeatable stock-only retention observations and the additional intermittent registry observation are recorded alongside oven-sh/bun#44438; they are not treated as proven product leaks. No runtime admission lists were changed.

The Node-run perf tools retain intentional heap censuses: scripts/lib/gateway-bench-profile-preload.ts and scripts/perf/{attempt-abort-retention,audio-queue-pool-retention,context-engine-factory-retention,local-workspace-retention,plugin-generation-retention,transcript-listener-entry,transcript-listener-owner}.ts. The browser DevTools Runtime.queryObjects test uses a different API and remains unchanged.

@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.

@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 replaces V8 heap queries in retention tests with portable garbage collection and specific-instance WeakRef assertions.

Example: A plugin retention test has two pending registry instances.

  • Before: The assertion requires V8 queryObjects to observe counts of 2, 1, then 0.
  • After: Tracked WeakRefs preserve the same counts using the shared portable collector.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused test migration has no identified defect; confidence in runtime results relies on the reported harness evidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored test-only PR is outside the ordinary contributor proof gate; its body reports actual runner passes across three runtimes and deliberate retention failures followed by restored passes, without linked raw captures.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Developers cannot run the affected retention checks on stock Bun because their assertions depend on V8 heap inspection.
Reason: The maintainer-authored direction improves supported-runtime testing while preserving the bounded scope and explicitly holding unsuccessful migrations.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR provides useful test portability work, with no actionable defect found, and remains under the author’s explicit draft hold.

Priority: P3
Reviewed head: 34d0599b482110231a76316cbd1c8648793588cc

Before merge

None.

Findings

None.

Agent review details

How this fits together

Retention fixtures exercise lifecycle owners, trigger collection through shared test support, and assert which created objects remain reachable.

flowchart LR
  A[Retention fixtures] --> B[Lifecycle owners]
  B --> C[Tracked WeakRefs]
  C --> D[Shared retention helper]
  D --> E[Node or Bun collection]
  E --> F[Exact live-instance assertions]
Loading

Technical review

Best possible solution:

Land the bounded caller migration after the support PR clears its hold, preserving the unchanged suites that still need runtime investigation.

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

Current-main tests directly depend on V8 queryObjects, and the body reports the affected Node, stock Bun, and fork runs; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch uses the existing shared collector, preserves exact counts and bounded collection, and removes duplicate assertion implementations without production hooks.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Lifecycle instance-retention assertions keeps the original intent (cb06c05: Detect retired plugin graphs retained through reload callers and lazy error stacks.)
  • Plugin registry custody checks keeps the original intent (40d735e: Prove active selections survive pending work while completed scopes release retired inventories.)
  • Session collection support changes intended behavior with a stated reason (79f147258b6145c4cc6f01c8ddc7d83f94118: Keep forced-collection checks reliable without weakening their zero-live-target assertions; this PR replaces the collection primitive while retaining assertions and routing.)
  • Non-isolated mock-retention fixtures keeps the original intent (6ceb202: Keep presence and release witnesses before broad imports make heap censuses expensive; their order and distinct cleanup boundaries remain.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit cb06c05 adds src/plugins/plugin-instance.retention.test.ts:29 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cb06c051a505; files: src/plugins/plugin-instance.retention.test.ts)

PR surface

Tests +20, Other +1. Total +21 across 73 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 72 332 312 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 73 333 312 +21

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 portability 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 portability 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.

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, 2:28 AM ET / 07:28 UTC.

@steipete
steipete force-pushed the test/retention-gc-support branch from 55bdd38 to b25bb5a Compare November 8, 2026 08:07
Base automatically changed from test/retention-gc-support to main November 8, 2026 08:20
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Nov 8, 2026
@steipete
steipete force-pushed the test/queryobjects-retention branch from 34d0599 to 1bc780d Compare November 8, 2026 08:23
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Nov 8, 2026
@steipete
steipete marked this pull request as ready for review November 8, 2026 08:31
@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-08T10:58:47.649397Z 36c23a6 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.

@steipete
steipete merged commit 4365481 into main Nov 8, 2026
156 of 158 checks passed
@steipete
steipete deleted the test/queryobjects-retention branch November 8, 2026 11:08
steipete added a commit that referenced this pull request Nov 8, 2026
#195158 un-exported forceFullGc and removed expectCollected as dead while #195091 concurrently added consumers (plugin-sdk/test-env, gateway session-collection test support, prepared-model-catalog inspection worker), breaking prod/test typecheck on main. Restore both exports; keep expectLiveObjects module-local so the dead-export scan stays clean.
@steipete

steipete commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Nov 8, 2026
Completes 34d5b3f: #195091 also imports expectLiveObjects from test-utils/retention in ten test files; keeping it module-local left test typecheck red on main. Verified with all 29 core test tsgo shards plus core tsgo.
vincentkoc added a commit that referenced this pull request Nov 8, 2026
…tooling-lint-selection-20261108

* commit 'b0e90e6a4b359fff7756698067fdce4758b1907b': (38 commits)
  fix(android): Talk button demands a realtime provider on a native Talk setup (#191194)
  chore: trace first-run Gateway work and verify later replies (#195185)
  fix(knowledge): keep deleted messages out of reply previews (#195126)
  fix(agents): preserve streamed replies across Gateway restarts (#195164)
  perf(ci): reuse SDK transport path boundaries (#195180)
  fix(sandbox): avoid pauses for unchanged command checkpoints (#195120)
  fix(test): make retention checks portable across runtimes (#195091)
  fix(knowledge): clarify temporal kind filters (#194995)
  improve: reduce Gateway allocation while draining SQLite receipts (#195129)
  fix: reduce streaming CPU after reply and voice directives (#195145)
  fix: reduce Markdown reparsing during streamed tool-call checks (#195161)
  fix: restore the main dead-export gate (#195158)
  improve(ci): pack small UI selections into fewer jobs (#195107)
  fix(muse): quota and sign-in failures end with no reply (#195148)
  fix: allow first release push with shipped patch bytes (#195174)
  fix(ci): narrow single-config tooling selections (#195147)
  fix(packaging): reject incompatible prepublish plugin cohorts (#195152)
  fix(ci): prepare verified Bun before parity checks (#195155)
  fix: Incognito agent turns stall before execution (#195005)
  fix: credentialed search and speech providers work without picking a provider (#195169)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
…95091)

* test: use portable retention checks across test suites

* test: collect WebSocket callers outside promise frames

* test: keep retention fixtures on supported test surfaces

* test: distinguish retained instances from weak references

* test: hold intermittent stock registry retention migration
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
openclaw#195158 un-exported forceFullGc and removed expectCollected as dead while openclaw#195091 concurrently added consumers (plugin-sdk/test-env, gateway session-collection test support, prepared-model-catalog inspection worker), breaking prod/test typecheck on main. Restore both exports; keep expectLiveObjects module-local so the dead-export scan stays clean.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
Completes e003968: openclaw#195091 also imports expectLiveObjects from test-utils/retention in ten test files; keeping it module-local left test typecheck red on main. Verified with all 29 core test tsgo shards plus core tsgo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: browser extensions: diagnostics-prometheus extensions: openai gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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