You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(skills/bounding-heavy-commands): stop endless waits for free memory - #85
A bounded command whose budget did not fit in free memory waited with no end when no other bounded command ran, because only programs outside the queue could free that memory. It held its slots while it waited. Now the wrapper sees that no bounded command runs, prints one fixed no-memory line with the largest budget that fits, releases its slots, and exits 75. The skill tells the agent to run a smaller recorded row, or to tell the user. A first measurement with no --memory on a busy machine without the hard cap now stops at once instead of waiting, and goes to the user.
Changes
bounded_run.py: a wrapper holds run-<unit>.lock while its command runs. The memory wait counts the running commands (run files that another process holds, plus bounded scopes under the hard cap), and stops when none runs and the budget does not fit.
The stop prints bounded-run: no-memory budget=<n>M free=<n>M headroom=<n>M fits=<n>M and exits 75. A --measure-rows run ends at the first row that stops this way; a command that exits 75 by itself is an ordinary non-zero exit.
--check prints fits=<n>M as the last field of its first line, so an agent can choose a row before it runs.
SKILL.md: the wrapper section names exit 75; a new ### After exit code 75 section gives the next move (largest recorded row within fits, or report budget, free, and fits to the user); the subagent rule and the Red Flags table say the same.
Challenges
Only commands that have started count as running, not commands that hold slots. Two waiters that each hold slots would otherwise count each other and wait forever. A command started by an older version of the wrapper holds no run file. Under the hard cap its scope still counts, but without the cap it is not counted, so the new wrapper can stop where a wait would have ended, until every session runs this version.
Testing
The script tests pass: 361 tests, run through the wrapper at --memory 512M. New tests cover the run-file count (held, leftover, slot files ignored), largest_fit_mib at its edges, the stop and the waits around it (including a command that ends between the reads, a lock directory that cannot be listed, and cgroup scopes that cannot be listed), the exit code and fixed line, the rows behavior for both kinds of 75, the cap-path scope count, and fits in the check. A subprocess test replays the reproduction from #84: --memory 12288M on a simulated 28000 MiB machine with 14000 MiB free exits 75 in about a second with fits=11008M, and all 10 slots are free after. On this machine, with real bounded commands of other projects running under the hard cap, the same call keeps waiting as it should.
The skill text went through RED and GREEN with isolated subagents, three runs for each of two scenarios: a recorded command that exits 75, and a first measurement that exits 75. Before the edit, all six runs read exit 75 as a full queue, and two ran the same budget again. After it, all six named the cause; the recorded-command runs picked the largest row within fits, and the measurement runs ran nothing and reported the values to the user.
…he wrapper exits 75 (#84)
Exit code 75 means that no other bounded command ran, so programs
outside the queue hold the memory and the same budget fails again.
The skill now gives the next move: the largest recorded row within
fits, or a report to the user for a measurement or when no row fits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a precise fits (#84)
The steps after exit 75 sat between the wait rules and their bullets,
so the bullets read as part of them. They now have their own section,
which needs the no-memory line, since a command can exit 75 by itself.
fits counts memory only; starts also counts the slots and the line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…apper's own no-memory stop (#84)
- bounded_once re-raises NoMemory after the log line, so only the wrapper's own stop ends the rows. A command that exits 75 by itself is a normal non-zero exit.
- The usage text gives the 75 paragraph its own block and says that fits counts only memory.
- A test covers the older-wrapper scope count in read_running under the hard cap.
- The --check test asserts " line=busy fits=".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t section (#84)
The new section after exit 75 made "see the next section" point at it.
Name the section instead. The Red Flags row now says that the same
budget fails again only while programs outside the queue hold the
memory, as the section does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… every place (#84)
The check section and largest_fit_mib still said that fits would start
now, but it counts memory only. Also rewrap the stop-signal paragraph.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o-memory stop (#84)
The last bounded command can end between the read of the free memory
and the count of running commands, since it ends without the memory
lock. The wait now reads the memory again after a count of 0, and
starts when the budget fits. A row that stops for memory after a
failed row now exits 75, as its line says. The usage text says that a
command can exit 75 by itself, and the lock test accepts the count from
before the run file exists.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e everywhere (#84)
The Red Flags row read exit 75 alone as a memory stop, but a command can
exit 75 by itself. The --measure-rows entry now says that a memory stop
ends the list with 75.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1. Review base: 5b12fd9. All four findings were valid and are fixed in d41434e and 5ca7705; each thread has its reply. The review had no suppressed comments.
Comment changes in this round:
Declaration
Lines (base → now)
Sentence
Verdict
Source
Judge
module docstring, bounded_run.py:2 (text that users read)
86 → 90
"Exit code 75 with the line below means that the budget did not fit in the free memory while no other bounded command ran, so nothing in the queue could free it, and the command did not start."
KEEP
bounded_once logs the line and raises NoMemory; bounded returns 75
evaluator
"A command can also exit 75 by itself, without the line."
KEEP
run_command / exit_code_of pass the command's code through
evaluator
"A row that stops with the no-memory line ends the list with exit code 75."
KEEP
_bounded_rows returns EXIT_NO_MEMORY on NoMemory
evaluator
inline, bounded_run.py:740 in wait_for_memory
0 → 1
"A command ends without the memory lock, so the last one can free its memory after the reads above."
keep
a concurrency fact the code cannot show
author
inline, test_bounded_run.py:3035
0 → 1
"The command can list the lock directory before the wrapper makes its run file."
keep
why the test accepts two counts
author
The suite passes: 359 tests through the bounded wrapper.
Avoid attributing no-memory conditions to outside programs
skills/bounding-heavy-commands/SKILL.md:173
During a mixed-version rollout without the hard cap, an older wrapper has no run file and can remain active when this wrapper reports no-memory. The PR acknowledges that limitation, but this paragraph and step 2 tell agents that outside programs hold the memory. Qualify the diagnosis as no detected running command and report the observed budget, free, and fits without asserting who holds the memory. Apply the same qualification to the summary at line 51, the Red Flags row at line 223, and the Python module's exit-code documentation.
… who holds the memory (#84)
Without the hard cap, a command of an older wrapper holds no run file,
so a no-memory stop does not prove that programs outside the queue hold
the memory. The text now says that the wrapper found no bounded command
running, and the agent reports budget, free and fits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2. Review base: 5b12fd9. The review posted no inline comments and listed one previously missed finding, which has no thread.
Avoid attributing no-memory conditions to outside programs (SKILL.md:173, also lines 51 and 223 and the module docstring): applied in 7dbf8a1. Without the hard cap, an older wrapper's command holds no run file, so a stop does not prove who holds the memory. The four places now say that the wrapper found no bounded command running, and step 2 tells the agent to report that the budget does not fit while no bounded command runs, with budget, free, and fits.
Comment changes: the module docstring block of bounded_run.py changed (90 → 90 lines, no growth); its one sentence now states what the script observed. No flag from the comment gate.
The suite passes: 359 tests through the bounded wrapper.
A failed directory listing is not evidence that no command is running. Without the hard cap, an I/O error here makes read_running() return zero, so a low-memory request incorrectly exits 75 even when another command still holds its run lock. Report a WrapperError, consistent with other lock-directory failures, or propagate an unknown count through the callback instead of returning zero.
…not be listed (#84)
A failed listing of the lock directory gave a count of 0 running
commands, so an I/O error could end in a false no-memory stop. It now
gives no count, and the wrapper waits as it did before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preserve child liveness tracking after wrapper termination (thread): declined, with the reason in the thread. A hard-killed wrapper also loses its slot locks, so its orphaned child already runs outside the queue. Making the child count would need it to inherit a lock, which the suite forbids on purpose.
Handle directory listing errors without assuming no running commands (previously missed, no thread): applied in 8d5601e. running_commands returns None when the lock directory cannot be listed, read_running passes that on unless a bounded scope runs, and the wait treats None as "not known: wait". New test: test_a_directory_that_cannot_be_read_gives_no_count.
Comment changes, judged by a fresh evaluator:
Declaration
Lines (base → now)
Sentence
Verdict
Source
module docstring, bounded_run.py:2 (text that users read)
86 → 90
"Exit code 75 with the line below means that the budget did not fit in the free memory while the script found no other bounded command running, so nothing in the queue could free it, and the command did not start."
KEEP
wait_for_memory, bounded_once, bounded
running_commands, bounded_run.py:489
4 → 5
"Returns None when the directory cannot be read."
KEEP
except OSError: return None; the caller waits on None
The suite passes: 360 tests through the bounded wrapper.
…ot be listed (#84)
A failed listing of the scopes counted as no bounded command running,
but a command of an older wrapper shows only as a scope. The count is
now unknown in that case unless a run file shows a running command, so
the wrapper waits and does not stop with 75.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preserve unknown scope state when cgroup listing fails (thread): applied in ce14f07. A failed scope listing now gives an unknown count unless a run file shows a running command, so the wrapper waits and does not stop with 75. New test: test_a_scope_listing_that_fails_gives_no_count_when_no_run_file_shows_a_command.
Comment changes: two added blocks, no growth flag. The doc comment of bounded_scope_count states its None result, which the caller handles. The inline comment in read_running gives the reason that only a run file proves a count when the scopes cannot be listed.
The suite passes: 361 tests through the bounded wrapper.
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
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.
Description
Fixes #84
A bounded command whose budget did not fit in free memory waited with no end when no other bounded command ran, because only programs outside the queue could free that memory. It held its slots while it waited. Now the wrapper sees that no bounded command runs, prints one fixed
no-memoryline with the largest budget that fits, releases its slots, and exits 75. The skill tells the agent to run a smaller recorded row, or to tell the user. A first measurement with no--memoryon a busy machine without the hard cap now stops at once instead of waiting, and goes to the user.Changes
bounded_run.py: a wrapper holdsrun-<unit>.lockwhile its command runs. The memory wait counts the running commands (run files that another process holds, plus bounded scopes under the hard cap), and stops when none runs and the budget does not fit.bounded-run: no-memory budget=<n>M free=<n>M headroom=<n>M fits=<n>Mand exits 75. A--measure-rowsrun ends at the first row that stops this way; a command that exits 75 by itself is an ordinary non-zero exit.--checkprintsfits=<n>Mas the last field of its first line, so an agent can choose a row before it runs.SKILL.md: the wrapper section names exit 75; a new### After exit code 75section gives the next move (largest recorded row withinfits, or reportbudget,free, andfitsto the user); the subagent rule and the Red Flags table say the same.Challenges
Only commands that have started count as running, not commands that hold slots. Two waiters that each hold slots would otherwise count each other and wait forever. A command started by an older version of the wrapper holds no run file. Under the hard cap its scope still counts, but without the cap it is not counted, so the new wrapper can stop where a wait would have ended, until every session runs this version.
Testing
The script tests pass: 361 tests, run through the wrapper at
--memory 512M. New tests cover the run-file count (held, leftover, slot files ignored),largest_fit_mibat its edges, the stop and the waits around it (including a command that ends between the reads, a lock directory that cannot be listed, and cgroup scopes that cannot be listed), the exit code and fixed line, the rows behavior for both kinds of 75, the cap-path scope count, andfitsin the check. A subprocess test replays the reproduction from #84:--memory 12288Mon a simulated 28000 MiB machine with 14000 MiB free exits 75 in about a second withfits=11008M, and all 10 slots are free after. On this machine, with real bounded commands of other projects running under the hard cap, the same call keeps waiting as it should.The skill text went through RED and GREEN with isolated subagents, three runs for each of two scenarios: a recorded command that exits 75, and a first measurement that exits 75. Before the edit, all six runs read exit 75 as a full queue, and two ran the same budget again. After it, all six named the cause; the recorded-command runs picked the largest row within
fits, and the measurement runs ran nothing and reported the values to the user.🤖 Generated with Claude Code