Skip to content

fix(test): respect process memory limits in local scheduling - #146298

Merged
vincentkoc merged 1 commit into
mainfrom
fix-vitest-process-memory-admission-tranche4
Sep 13, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix-vitest-process-memory-admission-tranche4

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Resolves a problem where developers running local test suites inside a memory-constrained process could get more concurrent test shards than the process's memory budget warrants. Physical host RAM alone can overstate the memory available to that process.

Why This Change Was Made

Include native process memory constraints and available headroom in the existing scheduling snapshot and worker inference. Keep the tighter valid memory bound, distinguish unknown constraints from exhausted headroom, and prevent the moderate-load adjustment from raising a memory-limited worker count.

The resource reporter calls live detectVitestHostInfo() instead of duplicating the native memory reads; only the scheduler caches its scheduling snapshot. Explicit worker overrides, throttle opt-out semantics, the shared cross-module snapshot, raw telemetry fields, CI scheduling policy, and one Vitest worker per full-suite shard remain unchanged.

User Impact

Automatic local test scheduling respects the memory reported as available to its process. Application runtime behavior is unchanged. This is an admission-control fix, not a measured CPU/RSS improvement or a guarantee against every OOM.

Evidence

Remote proof used Node 24.19.0 on Linux x64, with baseline and candidate in separate processes and the same new regression tests:

Check Result
Original owners with the new tests 38 collected: 28 passed, 10 expected worker-admission assertion failures
Candidate 38 collected, 38 passed
Unhandled errors 0 in both legs
Actual 3 GiB process constraint Default outer shard admission changed from 2 to 1; one Vitest worker per shard in both legs

The tests cover exhausted and unknown readings, independent valid bounds, moderate load, explicit overrides, and stable scheduling across two separately loaded copies of the same module.

The Testbox Actions run records the lease lifecycle. Application stdout/stderr was retained client-side; the reviewer's inability to retrieve job logs is an evidence-access limitation, not an additional test failure. The complete retained captures were independently inspected.

Selected-field projections from those captures follow. Command/path fields are omitted, test-count lines have ANSI formatting removed, and no timings are presented as performance evidence:

P12_PROFILE {"label":"baseline","node":"v24.19.0","nativeMemory":{"constrained":3221225472},"outerProfile":{"shardParallelism":2,"vitestMaxWorkers":1},"cgroupBefore":{"memoryMax":"3221225472"}}
Tests  10 failed | 28 passed (38)
[vitest:run] {"reason":"failed","files":1,"unhandledErrors":0}
P12_LEG {"code":1,"profile":{"label":"baseline"}}
P12_PROFILE {"label":"candidate","node":"v24.19.0","nativeMemory":{"constrained":3221225472},"outerProfile":{"shardParallelism":1,"vitestMaxWorkers":1},"cgroupBefore":{"memoryMax":"3221225472"}}
Tests  38 passed (38)
[vitest:run] {"reason":"passed","files":1,"unhandledErrors":0}
P12_LEG {"code":0,"profile":{"label":"candidate"}}

Complete-capture SHA-256:

  • stdout, 80,423 bytes: fa056cc232d96754f1003d0ed6befc115163d3bef3e8081756efd7ace1b56d0c
  • stderr, 19,500 bytes: c5d0311ebbac9342b780026b3a32b2bc4efc902ac34c17ef01cfe52daf820add

The proof used source base 12c55d1650c07d07046c3a08462f5fd0960c6e67 and candidate capsule tree e4f7dc53f457c3ba001f2427bc16d1d23bc92ed2.
The subsequent change only collapses one test-data tuple's whitespace; production bytes are unchanged.

Fresh independent P2 review completed. Its single unknown-host-total finding was rejected after source inspection: the existing lowest-memory-tier fallback remains conservative, rather than increasing admission. The PR's ClawSweeper review found no actionable correctness or security issue; its log-access limitation is addressed by the retained evidence above.

Hosted CI: the native watcher completed with GREEN and zero pending checks for exact head 326681be20acdb8800e7be42dce815870e20ca59 in CI run 34711427239.

Landed: squash-merged on September 13, 2026 at 11:58:56 UTC as 533698353132. Native review, prepare, and merge completed successfully, with the exact head and landed source verified. The initial remote changed-check invocation stopped at test-file formatting and is not relabeled as a passing invocation. No additional full suite, stress/OOM test, or performance benchmark was run by this task.

@vincentkoc vincentkoc self-assigned this Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 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 maintainer Maintainer-authored PR labels Sep 12, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 12, 2026 18:30
@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 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 7:56 AM ET / 11:56 UTC (Revision 4).

ClawSweeper review

What this changes

Local test scheduling incorporates process memory limits and available headroom, shares those readings with resource reporting, and adds regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded fix absent from current main and the latest release. No actionable correctness or security findings remain, and the supplied process-limit evidence supports the change.

Priority: P2
Reviewed head: 326681be20acdb8800e7be42dce815870e20ca59

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful regression coverage and relevant before/after process-limit evidence.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Supplied Linux terminal output exercises the scheduler’s full-suite profile under a real 3 GiB process constraint and shows admission falling from two shards to one, preserving one worker per shard; this supports admission correctness without claiming OOM prevention or performance gains.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Supplied Linux terminal output exercises the scheduler’s full-suite profile under a real 3 GiB process constraint and shows admission falling from two shards to one, preserving one worker per shard; this supports admission correctness without claiming OOM prevention or performance gains.
Evidence reviewed 7 items Current main still needs the fix: Current main’s scheduler uses host total/free memory only. Comparing its two tooling owners with the pinned PR merge base produced no differences, confirming that the introduced repair remains relevant.
Latest release comparison: The scheduler in v2026.9.4 also lacks process constraint/headroom inputs; this is not an already-shipped repair.
Owner-level implementation: The complete scheduler and reporter preserve explicit overrides, use the tighter valid memory readings, keep scheduling snapshots separate from live reporting, and prevent moderate load from increasing a memory-limited budget. Unknown host total memory retains the conservative lowest tier, consistent with the PR’s explanation rejecting that earlier concern.
Findings None None.
Security None None.

How this fits together

OpenClaw’s local test scheduler converts CPU, load, memory readings, and explicit overrides into worker and shard limits. Vitest configuration and the full-suite runner consume those limits, while the resource reporter reads live telemetry.

flowchart TD
  A[Host and process memory] --> C[Shared scheduling snapshot]
  B[CPU and system load] --> C
  C --> D[Worker budget decision]
  E[Explicit worker overrides] --> D
  D --> F[Vitest workers and suite shards]
  A --> G[Live resource report]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +140, Other +28. Total +168 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 147 7 +140
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 36 8 +28
Total 3 183 15 +168

Review metrics

Metric Value Why it matters
Production versus regression coverage Tooling production net +28 lines; tests net +140 lines Production growth is justified by native memory admission handling; most added code exercises boundary cases and snapshot consistency.

Technical review

Best possible solution:

Keep memory-aware admission in the existing scheduler while preserving explicit overrides, stable per-process sizing, and live telemetry.

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

Yes: current main ignores process memory limits, and the supplied constrained-Linux baseline/candidate trace demonstrates the resulting admission difference. This read-only review did not execute tests.

Is this the best way to solve the issue?

Yes: extending the existing scheduler avoids a competing budget owner and preserves caller, override, and reporting contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs local test over-admission in constrained environments without changing application runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Supplied Linux terminal output exercises the scheduler’s full-suite profile under a real 3 GiB process constraint and shows admission falling from two shards to one, preserving one worker per shard; this supports admission correctness without claiming OOM prevention or performance gains.
  • proof: sufficient: Contributor real behavior proof is sufficient. Supplied Linux terminal output exercises the scheduler’s full-suite profile under a real 3 GiB process constraint and shows admission falling from two shards to one, preserving one worker per shard; this supports admission correctness without claiming OOM prevention or performance gains.

Evidence

What I checked:

  • Current main still needs the fix: Current main’s scheduler uses host total/free memory only. Comparing its two tooling owners with the pinned PR merge base produced no differences, confirming that the introduced repair remains relevant. (scripts/lib/vitest-local-scheduling.mts:65, 59773963d180)
  • Latest release comparison: The scheduler in v2026.9.4 also lacks process constraint/headroom inputs; this is not an already-shipped repair. (scripts/lib/vitest-local-scheduling.mts:65, 3a9d69db306c)
  • Owner-level implementation: The complete scheduler and reporter preserve explicit overrides, use the tighter valid memory readings, keep scheduling snapshots separate from live reporting, and prevent moderate load from increasing a memory-limited budget. Unknown host total memory retains the conservative lowest tier, consistent with the PR’s explanation rejecting that earlier concern. (scripts/lib/vitest-local-scheduling.mts:96, 326681be20ac)
  • Real process-limit evidence: The captured PR body reports separate baseline/candidate processes on Linux x64 with Node 24.19.0 and an actual 3221225472-byte cgroup limit. Its terminal projection shows outer shard admission changing from 2 to 1 while retaining one worker per shard; candidate tests pass 38/38 versus 10 baseline admission failures. Captured context identity is ae59dd2549d1ebc9c94658fbeb8fcba81426f8fe30c4955d092d3d5cb159ef16. Full-capture hashes identify retained stdout/stderr, but this review inspected the supplied projections, not those complete captures. (326681be20ac)
  • Regression coverage: Tests cover independent valid bounds, unknown versus exhausted readings, moderate load, explicit overrides, throttle opt-out, full-suite budgets, and consistent scheduling across separately loaded modules. The snapshot test restores process spies, OS functions, and the previous global descriptor. (test/scripts/vitest-local-scheduling.test.ts:10, 326681be20ac)
  • Scheduling history and review continuity: Main history identifies the shared-snapshot work at 3af7d29 and prior reporter maintenance at 8e5a3f3. GitHub commit reads confirmed the corresponding patches and author handles after local historical blob inspection failed. The previous completed review covered this same head and retained no findings; the new human comment requests re-review. (scripts/lib/vitest-local-scheduling.mts:79, 3af7d292eed7)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • vincentkoc: 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-12T18:37:04.947Z sha 326681b :: blocked before merge. :: none
  • reviewed 2026-09-12T18:51:44.327Z sha 326681b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T19:04:55.312Z sha 326681b :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 12, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 13, 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:

@vincentkoc
vincentkoc merged commit 5336983 into main Sep 13, 2026
159 checks passed
@vincentkoc
vincentkoc deleted the fix-vitest-process-memory-admission-tranche4 branch September 13, 2026 11:58
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (1537 commits)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  perf(sessions): keep cleanup responsive and reuse workers (#140897)
  fix(sessions): prevent stranded writers after abort and restart (#146792)
  refactor: reuse deferred owners in Gateway and infra fixtures (#146809)
  fix: prevent queued conversation replies from switching storage (#146984)
  test(ui): preserve nested failure summaries in CI logs (#146864)
  fix(test): respect process memory limits in local scheduling (#146298)
  fix: validate large media data URLs without regexp stack exhaustion (#146972)
  fix(ui): label model usage contributions as messages (#146735)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (30 commits)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  perf(sessions): keep cleanup responsive and reuse workers (#140897)
  fix(sessions): prevent stranded writers after abort and restart (#146792)
  refactor: reuse deferred owners in Gateway and infra fixtures (#146809)
  fix: prevent queued conversation replies from switching storage (#146984)
  test(ui): preserve nested failure summaries in CI logs (#146864)
  fix(test): respect process memory limits in local scheduling (#146298)
  fix: validate large media data URLs without regexp stack exhaustion (#146972)
  fix(ui): label model usage contributions as messages (#146735)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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