Repository navigation
fix(exec): stop runaway Linux host command memory usage - #182111
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesAdds a sampled Linux host-command memory watchdog that kills over-budget process trees and preserves actionable failure diagnostics. Example: A Linux command descendant allocates 384 MiB under a 256 MiB memory budget.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain Keep this PR open: the watchdog addresses a real gap, but the patch introduces an import cycle, a stale baseline entry, and broken launch-authority test coverage. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway exec prepares host commands, the process supervisor owns their transport and cleanup, and command outcomes flow into foreground results, background polling, and diagnostics. flowchart TD
A[Gateway exec] --> B[Process supervisor]
B --> C[Child relay or PTY]
B --> D[Procfs memory sampler]
D --> E[Existing tree cancellation]
C --> F[Exec outcome]
E --> F
F --> G[Foreground results and background polling]
Technical reviewBest possible solution: Keep the supervisor-owned watchdog, share its failure type through a leaf contract, and repair the baseline and relay-boundary tests. Do we have a high-confidence way to reproduce the issue? Current main has no host-command memory budget, and the added Linux regression identifies a concrete allocating descendant; no target code was executed during this review. Is this the best way to solve the issue? The existing supervisor is the appropriate watchdog owner, and the documented sampled safeguard is proportionate, but the dependency and consumer-test repairs are necessary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d7e7e402df15. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +155, Tests +148, Docs +8. Total +311 across 14 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 23, 2026, 10:52 PM ET / October 24, 2026, 02:52 UTC. |
Monitor resident and swapped memory of supervised host command trees, kill over-budget work, and preserve actionable memory-limit failures in foreground and background results. Keep sandbox policy and OOM victim preference with their existing owners. Document sampled protection and PTY reparenting limits.
5db471a to
a256dc4
Compare
|
Landing under the authorized inherited/unrelated-failure exception on exact head The three remaining non-aggregate failures in CI 40056137055 are documented in the PR body:
All changed execution-owner checks and security-fast pass. The exact-head real memory-hog tests pass in 1.200 s (non-PTY) and 1.041 s (PTY), with |
) * fix(exec): bound Linux host command memory usage Monitor resident and swapped memory of supervised host command trees, kill over-budget work, and preserve actionable memory-limit failures in foreground and background results. Keep sandbox policy and OOM victim preference with their existing owners. Document sampled protection and PTY reparenting limits. * fix(exec): keep outcome types and launch policy proof with their owners
What Problem This Solves
A runaway Linux Gateway exec child can exhaust host memory before the global OOM killer intervenes. Existing OOM-score adjustment changes victim preference, but does not bound allocation.
User Impact
Linux Gateway-hosted foreground, background, and live PTY command trees get an RSS-plus-swap watchdog. The default limit is the smallest of 8 GiB, one quarter of physical/cgroup-constrained memory, and half the memory remaining after the Gateway's resident usage. A sample over the bound immediately requests the existing tree-kill operation and returns
memory-limit, observed usage, the bound, and recovery advice. Background polling/logs retain that explanation. No new config, dependency, or service changes.This is sampled protection, not hard containment. The one-second interval allows overshoot; concurrent commands have independent budgets and shared pages may be counted repeatedly. Non-PTY commands retain a descendant owner. Reparented PTY daemons are outside the live ancestry monitor; use supervised non-PTY background execution for long-running work. Remote
host=node, Codex-native shell commands, non-Linux hosts, and sandbox backends are outside this watchdog.Design and Simplification
The existing supervisor owns cancellation, background lifetime, cleanup, and now memory sampling. The service relay exposes its retained tree root so the monitor includes adopted descendants. Procfs sampling avoids subprocess polling and virtual-address limits that interfere with V8/Go runtime reservations. Cgroup containment requires delegation and spawn-time placement; this safeguard requires neither. RLIMIT_AS/RLIMIT_DATA do not provide a tree RSS bound, and RLIMIT_RSS does not provide a modern Linux RSS bound (getrlimit).
Production LOC: +155 (324 added / 169 removed); test LOC: +196. Growth implements the missing watchdog and failure propagation. Outcome shaping and its types now live together in the existing output owner; the duplicated diagnostic failure union and obsolete max-lines exemption are removed. No second execution owner or cache was added.
The retained owner already reports uncertified cleanup and fences the supervisor when admission is revoked before command launch. The launch-policy regression explicitly asserts both denial of execution and that cleanup failure. This behavior already applied to service-hosted execution; distinguishing confirmed local refusal from uncertain launch delivery remains a separate lifecycle repair.
Proof
a256dc489d9b38b5e562e34865404ede1d0aadd7: a real descendant allocating 384 MiB under a scaled 256 MiB default is killed before its 8-second timeout, returnsmemory-limit, and retains background guidance. Whole-test times: 1.200 s non-PTY / 1.041 s PTY. Actual terminal selection is asserted. Existing PTY/OOM-score behavior and all 11 launch-policy cases pass. These are reliability results, not latency/GC performance claims.38bf89ccf774preserved the upstream error formatter in an import-only conflict; range-diff confirms no other patch changes.Remaining CI Failures: Attributed Baseline / Unrelated
Final CI run 40056137055 has three non-aggregate failures; security-fast and all changed execution-owner checks pass. The CI gate is red because of these failures. No CI reruns were requested.
test/clawrouter-managed-gateway.e2e.test.ts:109: catalog returnscount: 0, missing the configured model. Reproduced identically on unchanged main1fead915921e307018bdb7b8d2a2e7d80c9d8d4ausing that revision's official CI runtime and matching packaged plugins from main run 40054969997. Failure occurs before the agent turn; fixture CLI uses the unchanged managed-child owner.test/gateway.multi.e2e.test.ts, scheduler-disabled Gateway edit: cron.add rejects the fixture's model override against its single-model allowlist. Same exact rejection reproduced on unchanged main1fead915921ewith the same official artifacts. The fixture and model-selection owner are unchanged by this PR.src/gateway/server-methods/chat-send-message-injection.isolated-gateway.test.ts:220: a 1-second chat.send timeout. Initial focused PR run reproduced it; then five main-parent runs (38bf89ccf774) and five PR-head runs passed, six tests each. This synthetic steering flow does not execute a shell child; diagnostic-events changes are type-only. Meets the lane's explicit unrelated-flake criterion; the original failures remain recorded, not claimed fixed.Baseline E2E commands used the supported
OPENCLAW_E2E_USE_PREBUILT_DIST=1mode, one worker, and only the failing file/case. Artifact build-info matched the checked-out main SHA; original generated directories were preserved and restored. An earlier attempt omitted that flag and began automatic build preparation; it was stopped (143) and excluded from evidence, then official artifacts were restored afresh. No Team production changes or sandbox writes.