Repository navigation
#3120: 0.2.0 AD6: agent-safe process environment on Linux hosts (OOM order, CPU quota) - #3221
Open
jparker2006 wants to merge 5 commits into
Open
jparker2006 wants to merge 5 commits into
jparker2006 wants to merge 5 commits into
Conversation
…quota sizes its workers
…quota worker counts
… checks the turn GitHub's runner starts each step at oom_score_adj 500, so the test could not tell the turn's shells from the harness and failed under CI. The test now lowers its own value to 0 for its length when the host allows it, and puts it back afterwards. Co-Authored-By: Claude Opus 5.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3120
Part of #3120
Source and credit: idea only (no upstream code was read or ported).
Summary
On Linux, each local-driver turn now runs with an owner-only shell helper (
BASH_ENV, plusCLAUDE_ENV_FILEforclaude, sourcing any existing file) that raises starting shells'/proc/self/oom_score_adjto 500 while the harness process keeps its default. When the driver's cgroup sets a CPU quota (cpu.maxon v2 orcpu.cfs_quota_us/cpu.cfs_period_uson v1), the turn also receivesOMP_NUM_THREADS,PYTHON_CPU_COUNTandCARGO_BUILD_JOBSset toceil(quota / period)unless already set. Nothing changes on macOS or when no quota is set.Evidence
docs/evidence/3120/red.md— running the newadapters/local/test_driver.pycases against the baseadapters/local/driverfailed all 4 CPU-quota assertions (returningNoneinstead of'2'), with the OOM test skipped because the local sandbox starts processes atoom_score_adj500 (runs underCI).python3 -I adapters/local/test_driver.py -vpassed 26 tests with 1 skipped (OOM test skipped on local host with defaultoom_score_adj500; runs underCI).Self-check
git worktree add --detach /tmp/build/probe-undo HEAD && git -C /tmp/build/probe-undo checkout origin/main -- adapters/local/driver && python3 -I adapters/local/test_driver.py Local.test_a_cpu_quota_sizes_the_turns_workers_and_an_owner_set_value_winsprintedFAILED (failures=4)at its own assertions (None != '2').python3 -I -c "...d.cpu_quota() / d.agent_environment(...)..."printederror-paths: ok (unwritable OSError=Permission denied, cpu_quota=None, non-linux={})(unwritable state dir raisesOSErrorcaught asRefusedinlaunch, missing/zero cgroup returnsNone, non-Linux returns{}).python3 -I adapters/local/test_driver.py -v Local.test_with_no_cpu_quota_or_without_proc_as_on_macos_the_turn_environment_is_unchangedprintedOK(unlimited/missing cgroup and macOS/no-proc leave env unchanged; helper is created mode0o600atomically and never lowers a higheroom_score_adj).python3 -I tools/privacy-check/hook.py --url https://github.com/openwizdev/OpenWiz --repo /tmp/build/OpenWiz --head HEAD --base origin/mainprintedliterals: not usedand exited 0.git diff origin/main...HEAD -- adapters/local/driverprinted helper paths written only underSTATE(<run>.bash-env,<run>.claude-env), sourcing any existingBASH_ENV/CLAUDE_ENV_FILEwithout modifying or deleting user files.python3 -I adapters/local/test_driver.py -vprintedRan 27 tests ... OK (skipped=1);launch()is only called internally bystartandwakeinadapters/local/driver.python3 -I .wizskills/skills/review-ticket/scripts/comments.py --base origin/main --head HEADprinted nothing and exited 0.Merge danger
Door: two-way. Blast radius: local
Rulings
none
Facts
ticket/3120-agent-safe-env93aadfd1228fdd923019fd08006fd430b0c58d23061a96b49161347d3f54148b5d2b07233791fef0changed: 145 lines in 4 files; tests apart: 105 lines in 2 files(plan:S: about 200 lines and 10 files;size: ok)adapters/local/driver,adapters/local/fixtures/fake-harness,adapters/local/test_driver.py,adapters/local/README.md(shared: one bullet),changes/3120.md; supporting edit:docs/evidence/3120/red.md(kind: own evidence folder; supports all acceptance criteria andadapters/local/test_driver.py)test_on_linux_a_turns_shells_go_first_under_memory_pressure_and_the_harness_keeps_its_default— catches: Linux turns leaving shelloom_score_adjequal to the harness default, losing an owner-setBASH_ENV, omittingCLAUDE_ENV_FILEforclaude, or creating world-readable helper files.test_a_cpu_quota_sizes_the_turns_workers_and_an_owner_set_value_wins— catches: missing or miscalculated cgroup v2/v1 CPU quota worker limits (OMP_NUM_THREADS,PYTHON_CPU_COUNT,CARGO_BUILD_JOBS), ignoring tighter parent cgroup quotas, or overriding owner-set values.test_with_no_cpu_quota_or_without_proc_as_on_macos_the_turn_environment_is_unchanged— catches: injecting CPU variables when no quota is set (max, missing,-1) or altering the turn environment on macOS / non-Linux hosts.docs/evidence/3120/red.md(FAILED (failures=4, skipped=1)on base driver)oom_score_adjto 500 while harness keeps default; cgroup v2/v1 CPU quotas setOMP_NUM_THREADS,PYTHON_CPU_COUNT,CARGO_BUILD_JOBStoceil(quota/period)unless owner-set; macOS and no-quota paths are unchanged.cpu_quota(),shells_go_first(), andagent_environment()are isolated functions inadapters/local/driverso AD2 merges cleanly alongside AD6.oom_score_adj500 so the OOM test skips locally and is exercised by Linux CI.