Skip to content

feat(skills/bounding-heavy-commands): queue the heavy commands of all sessions - #47

Merged
sourcehawk merged 66 commits into
mainfrom
feat/bounded-heavy-commands
Sep 29, 2026
Merged

sourcehawk merged 66 commits into
mainfrom
feat/bounded-heavy-commands

Conversation

@sourcehawk

@sourcehawk sourcehawk commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Description

Closes #45

Agents in different sessions and projects start test suites and builds at the same moment, none of them can see the others, and together they use all the memory of the machine until it stops responding. This PR adds the skill bounding-heavy-commands and a wrapper script that puts each heavy command of each session into one queue for the memory of the machine. The protection depends on agents that obey the skill: no hook stops a plain command, and an explicit instruction from the user or from the project's instruction file still sends a command around the queue.

Changes

  • New skill bounding-heavy-commands. Each heavy command that an agent starts goes through the wrapper, also in a session that looks alone and for a part of a command such as one test file.
  • New script bounded_run.py, Python standard library only. It takes memory slots from a queue that all projects of the user share and that counts the memory limit of a container, waits until the budget is free, runs the command, and prints the budget and the measured peak. Its exit code is the exit code of the command.
  • On Linux, a hard kill of the wrapper also stops the command, through the parent-death signal. Where the kernel refuses that signal, the wrapper prints a warning and the command runs.
  • A slot is an empty lock file whose lock the kernel holds. The lock goes away when the wrapper stops for any reason, so no stale state exists and no cleanup is necessary.
  • On Linux with a user session of systemd, the command also runs under a hard cap with no swap, and a command that passes its budget ends with exit code 137. On macOS the queue and the wait for free memory are the full protection, and the measured peak is approximate.
  • --exclusive <name> makes commands of one repository take turns on a fixed port or a tool's lock, across all worktrees.
  • The budgets and the bounded command lines of a project live in the project memory of the agent, not in the repository. An agent with no record measures each command with --measure on its first run.
  • The dispatch prompts of fanning-out-with-worktrees and developing-a-feature carry the bounded command lines, because a subagent does not see the memory of its orchestrator. reviewing-feature-progress runs the project-wide checks through the wrapper.
  • The README recommends that the user keeps project memory on, because the record lives there.
  • An orchestrator does not start fewer subagents to protect the machine. Subagents that wait in the queue cost time, not memory.
  • Python 3.9 or later is a requirement of the plugin for the scripts that it ships. A new workflow runs the tests of each script on Linux and macOS, on Python 3.9, on the current release, and on the system Python of macOS.

Challenges

A lock file of this wrapper holds no process ID, and a deleted lock file stays locked for its holder while the next caller makes and locks a new file with the same name. An agent that "cleans up a stale lock" thus makes two commands hold one slot. A baseline agent planned that cleanup by itself, so the skill forbids each touch of the lock files, and a reviewer must not read the missing cleanup code as a gap.

The cap process inside the systemd scope must outlive the command, because the peak of a cgroup is readable only from inside it. With the default OOM policy, systemd stops the full scope after the kernel kills one process for memory, and that signal can reach the cap process before it writes the peak. The wrapper sets OOMPolicy=continue where systemd accepts it for a scope (from version 253) and keeps its signal handlers until the peak is written.

Related

  • feat(skills/addressing-review-feedback): stop comment growth in review rounds #48, the second PR of the epic Keep code comments short through review rounds #42, is merged and added the workflow file, the .gitignore line, and the lines about scripts in CLAUDE.md. This branch has main merged in, so its diff does not show them.
  • Known limit: when the first probe of the hard cap fails for a reason other than the OOM policy (for example a timeout under load), the wrapper uses the cap without that policy and prints no line about it.
  • Known limit: a stop signal in the last instant of the cap process, after the peak is written, can give exit code 143 in place of 137.
  • Known limit: the test test_a_stop_signal_while_the_peak_is_read_does_not_end_the_process failed one time in about 66 runs of the full suite, and the message was lost. It passed 300 of 300 runs alone. The test prints the error stream of its child on a failure, so a failure in CI shows the cause.
  • Known limit: on macOS a command lives on after a hard kill of the wrapper (SIGKILL), and the queue counts its slots as free. On Linux the same is true for a process that the command started; on the capped path such a process stays under the memory limit of its scope.
  • Known limit: the wrapper waits for the command and not for a process that the command leaves running. Such a process is outside the queue, and the wrapper prints a warning. The warning covers the process group of the command: a process that left that group, as a daemon does, gets no warning. It does not wait, because a tool that leaves a helper process would hold its slots with no end.
  • Known limit: a bounded command that calls the wrapper again runs its command directly, and the inner call takes no lock, also not for --exclusive. Locks in the inner call can make two outer commands wait for each other with no end.
  • Known limit: the wrapper does not find the memory limit of a container that uses cgroup v2 with no cgroup namespace of its own, or cgroup v1 with the memory controller under a combined name. It then uses the physical memory, as it did before it read a limit.
  • Known limit: on a machine with no runtime directory of the user (macOS, for example), the lock files are in /tmp. Each lock sets the times of its file to now, and the wrapper does not use a file that was deleted before the lock. A cleaner that deletes a lock file while a command holds it, which needs a command that runs longer than the age limit of the cleaner, still lets a second command take the same slot.
  • Known limit: when the reserve is not less than the memory of the machine, the queue cannot keep it. It gives out the memory of the machine, up to one slot, and prints a warning.
  • Known limit: when the free memory stays below the budget for the full time limit (300 seconds), the wrapper prints a warning and starts the command. A wait with no end blocks each agent when a process outside the queue holds the memory.
  • Not in this PR: a hook that refuses a plain heavy command, and a config file for the tuning values.
  • A person must check three points that CI cannot: the hard cap on a Linux desktop session other than mine, the quality of the sampled peak on a Mac against Activity Monitor, and the free-memory line of the wrapper on a real Mac.

Testing

The suite of the wrapper has 187 tests and takes about 12 seconds. It passes on this machine (Linux, systemd 255, hard cap available, no test skipped), also under 16 busy processes with a load average of 14 to 39. Ten capped runs under that load all ended with exit code 137. The tests cover the limit on commands that run together, the release of the slots after a hard kill of the wrapper, a nested call, the exit codes and the signals, and the two-step probe of the cap. The five jobs of the workflow pass: no test is skipped on Linux, and 6 tests of the hard cap are skipped on macOS.

Five review rounds of the last wrapper task found tests that could not fail, a test helper that lost a line of output under load, and the exit code 143 in place of 137. Each fault was reproduced before its correction, except the exit code 143, which was seen one time in 12 runs and is corrected on the evidence of the journal of systemd.

The skill was written against a baseline. Each test ran in a fresh agent that was told to read only the skill file. The harness still shows such an agent the instructions of this repository, so the tests are a little easier than a project that never saw this plugin. Without the skill, agents ran the plain commands in parallel after a sum of the budgets against an empty machine (3 of 3 runs), put the plain commands into a dispatch prompt and cut four subagents to two, tried one more time after a port collision, and answered a slow machine with "look at the load first". Under heavy pressure, one agent planned to delete a lock file and offered a small test run outside the queue.

With the skill, 21 scenarios pass, and the core scenario passes 5 of 5 times. The scenarios include a user who orders the plain command, a rule in the project's instruction file that exempts one command, a subagent with a port collision, a wrapper path that an update of the plugin made old, commits and pushes whose hooks run the tests, a machine with no Python, and a wrapper that cannot lock its files.

The first text failed one scenario: the agent refused an explicit instruction of the user. Four cold reads by fresh agents then found 6, 3, 4 and 1 cases in which two rules gave opposite orders, and one instruction that gave empty values (a variable of the wrapper that the calling shell replaced before the wrapper started). Each is corrected, and the corrected form of that instruction ran against the real wrapper. The behavior scenarios ran again after the corrections.

The JSON in .claude-plugin/ parses. A search of the added markdown finds no name of a project, a product, or a toolchain.

🤖 Generated with Claude Code

sourcehawk and others added 30 commits September 28, 2026 17:09
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…er (#45)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…hine (#45)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…ory of the user (#45)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
#45)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…a busy lock (#45)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…no slot held (#45)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ch repository (#45)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…e limit (#45)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…it (#45)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…mmand (#45)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
… code and signals (#45)

Adds the command line parsing, the run of the command with its exit
code and signal forwarding, the nested-call path, and main. Also
dedupes repeated --exclusive names in parse_arguments so a later task
does not lock the same file twice and wait on its own lock forever.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…r fails after the start (#45)

An exception between Popen and wait4 (a broken on_start hook, a future
caller's error) left the command running with no parent: neither
killpg call guarded PermissionError, which macOS raises for a group
that holds only zombies, and nothing reaped the command on a failure.
run_command now guards both killpg calls and wraps the run from the
start to the end of the wait so any exception kills the command's
process group and reaps it before the exception propagates.

Also check the command against the PATH of the environment it will
run in, not the wrapper's own PATH; they can differ.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The command runs in a new session, so a SIGHUP of the wrapper's
terminal never reaches it. A closed agent shell is a normal way for
this to happen. The wrapper took the default action and died, leaving
the command running with nothing to stop it. run_command and
inside_cap now handle SIGHUP the same way as SIGTERM: the first
hangup goes to the command's process group, a second signal kills the
group, and the wrapper stops with status 129.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… signal that is not forwarded (#45)

The command in the two stop-signal tests held for 30 seconds while
the wait had a timeout of 60 seconds. A wrapper that never forwards
the signal still lets the command end by itself inside that window,
so the test passes even though the property it checks is broken.
Both tests now hold for 300 seconds, so a broken forward times out
the wait and fails the test instead.

Also drop a line that sets process.stdin to None after
communicate() already closed it; it has no effect.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… fails (#45)

test_an_error_after_the_start_stops_the_command started a command
that holds for 300 seconds and relied on run_command's own guard to
stop it. When the assertion failed, or if that guard ever regresses,
the command kept running with no cleanup. The test now registers an
addCleanup, before the call to run_command, that sends SIGKILL to the
command's process group and reaps it; addCleanup callbacks run on
every path, including a failing assertion. Also gave the command's
argument list a marker unique to this test, for a pgrep check.

Checked every other test class that starts a process: ExclusiveNameTest
and MeasurementTest only use synchronous subprocess.run calls that
finish before returning. InsideCapTest's inside_cap already waits for
its child before returning. WrapperProcessCase (and its subclass
WrapperProcessTest) already kill every process they start, and every
pid recorded in the events file, from their own tearDown. None of
those needed a change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… the machine (#45)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…peak (#45)

Replaces bounded() to apply the hard cap where systemd-run --user
--scope can create a cgroup, measure the peak memory (from the
cgroup when capped, sampled otherwise), print the report line, and
support a measure mode that suggests a budget.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…n an interrupt in the queue (#45)

An interrupt while the wrapper waits in the queue or waits for free
memory raised KeyboardInterrupt out of main() and printed a
traceback, breaking the rule that the wrapper never prints one. main()
now catches KeyboardInterrupt around the call to bounded(), logs one
line, and returns 130; the locks are still released by bounded()'s
finally or by the kernel.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…l on a signal that is lost (#45)

test_a_stop_signal_stops_a_capped_command held the command for only
30 seconds, so a regression that stops the signal from reaching the
command (e.g. os.kill to the tracked pid instead of os.killpg to its
group) could still pass: the command would finish on its own inside
the 60-second wait and the wrapper would still report 143, since
run_command reports 128+signal once a signal was sent regardless of
what actually stopped the command. Holding for 300 seconds makes a
lost signal show up as a timeout instead.

test_no_peak_file_is_left_behind_after_a_failing_command asserted
only that no peak- file remained, which is also true when no such
file was ever written. It now also asserts the report line says
"(cgroup)", proving a file existed and was read before removal.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…th (#45)

bounded() read and removed the peak file after the try/finally that
holds the reservation, so an exception between run_command's return
and that read (or a run_command that raises outright, as with an
on_start callback that fails) left the peak-<unit> file behind in
the lock directory. The read and removal now happen inside the
finally block, before the reservation is released, so the file is
gone on every path on which the wrapper still runs. The report line
still says "cgroup" only when that read returned a value.

Proven with test_the_peak_file_is_removed_when_the_run_fails_after_the_start,
which calls bounded() in the test process with run_command and
cap_usable replaced by stubs (no real subprocess, no real cgroup),
makes the stub write the peak file at the path it is given and then
raise RuntimeError, and asserts the file is gone and both slots are
free afterward.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…, between two processes (#45)

test_a_waiting_command_holds_no_slot used time.sleep(0.3) to let the
large command try and fail to reserve before starting the small one.
Replaced it with waiting for "waiting for" on the large command's
own error stream, a fact instead of a fixed pause.

test_an_interrupt_in_the_queue_gives_130_and_no_traceback already
waited for the holder's start event (a fact) before launching the
second wrapper, so the reservation was never the issue: a probe
placed right after that event, in a standalone repro, confirmed the
two needed slots were always still held. Reproducing under real CPU
load (up to ~100 runnable processes on 16 cores) showed the second
wrapper's own "waiting for" log line reaching its stderr pipe more
than 30, and occasionally more than 60, seconds after it started,
while remaining alive and correct the whole time: the code between
its two log calls is a handful of non-blocking syscalls with nothing
in it that should take that long, so this is the OS failing to
schedule a fully correct process under heavy contention, not a bug
in bounded_run.py's reservation or logging. Extracted the inline
30-second wait into a shared wait_for_stderr helper (default 60
seconds, matching every other timeout in this suite) and used it
here in place of the ad hoc loop.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ess with no buffer between (#45)

wait_for_stderr used select() on process.stderr (a buffered text
stream) and then readline(). select() only reports the descriptor
ready; it says nothing about how many lines are already sitting in
the pipe. When two lines arrive before the first read, readline()
pulls both out of the pipe and returns only the first, leaving the
second sitting in Python's own buffer where select() can no longer
see it. The loop then waits for a line it already holds, until its
deadline. Proved this before changing anything: a temporary
time.sleep(3) placed right before the wait_for_stderr call, so both
lines are reliably in the pipe first, made
test_an_interrupt_in_the_queue_gives_130_and_no_traceback fail the
same way three times in a row on an otherwise quiet machine (load
average 2.7-22), with the exact message seen under real load. This
replaces the "OS scheduling latency" cause recorded for this test in
the Fix round 2 section of the task report, which was not confirmed
and is superseded by this cause.

Fixed wait_for_stderr to select() on the raw descriptor
(process.stderr.fileno()) and read it with os.read(), never through
process.stderr's own buffered readline()/read(), so select() and the
read always agree on what is still in the pipe. An empty read means
the stream closed; that now fails immediately with the buffer so
far, instead of waiting out the deadline. Kept the partial read in
self._stderr_buffers, keyed by process, and added stderr_of(process)
to combine it with a final raw read after the process has stopped,
so a test that reads the same stream twice (once through
wait_for_stderr, once to check the full output) never loses or
re-reads a byte between the two. Updated
test_an_interrupt_in_the_queue_gives_130_and_no_traceback, the one
test that reads a stream both ways, to use it.

Searched the file for the same fault (select() paired with a
buffered readline(), read(), or iteration): wait_for_stderr was the
only place that did this.

Re-ran the three-failures-in-a-row proof with the fix in place and
the temporary sleep still there: passed three times. Removed the
sleep.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… hold until the test stops the command (#45)

Two more tests had the same two faults already fixed elsewhere in
this file: ordering two events with a fixed sleep, and a "runs until
stopped" hold short enough that its own natural end could rescue a
buggy result.

test_a_second_stop_signal_kills_a_command_that_ignores_the_first used
time.sleep(0.3) between the first and second SIGTERM. Under load the
two signals can coalesce into one delivery before the sleep even
starts, failing the test with no fault in the wrapper; a wrapper that
wrongly stops on the first signal could still look alive after 0.3
seconds, passing a test that should have caught it. Made the ignoring
command write a "signaled" event when it receives SIGTERM, and made
the test wait for that fact (with the existing wait_for_event helper,
60-second deadline) before sending the second signal. Added the
missing assertion that the command's own process is actually gone
afterward, matching every other signal test in this file. Proved the
new test has teeth: temporarily changed run_command's forward() to
resend the first signal instead of SIGKILL on the second delivery,
and watched the test fail by timeout; reverted before committing.

test_a_waiting_command_holds_no_slot gave its long-running holder
hold="60" while waiting up to 60 seconds for the small command to
end. If a bug let something wrongly keep a slot, the holder's own
natural expiry at the same 60-second mark could still free a slot
just in time and mask the bug. Changed the hold to 300 seconds; the
holder still ends early via its release file on every correct run.
Proved it: temporarily made a failed try_reserve() keep the slots it
had already taken instead of releasing them (matching a real leak
bug shape), and watched the test fail by timeout with the fixed
300-second hold; reverted before committing.

Also, from the same review pass:
- test_a_hard_kill_of_the_wrapper_frees_the_slots_at_once used
  hold="120" for a holder that is unconditionally killed right after
  its start event; never 120 by design, so normalized it to the same
  300-second convention as every other "runs until stopped" hold.
- test_the_tracker_survives_a_reader_that_fails asserted only that
  the tracker's peak stayed None, which is also true if the reader
  never ran at all. Now counts the reader's calls, waits for at
  least one (a fact, not a fixed sleep), and asserts that count.
- Added a one-line comment to every hold that is genuinely short and
  that the test waits to end, so the two patterns ("runs until the
  test stops it" vs "short, waited out") are no longer distinguished
  only by tribal knowledge.

Audited every hold= and time.sleep in the file for these two faults;
the two above were the only other instances found. Full list in
task-12-report.md.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ped command before the kernel does (#45)

Under load, the controller measured test_the_cap_stops_a_command_that_passes_its_budget
end with exit 143 (SIGTERM) instead of 137 (SIGKILL) in 1 of 12 full
suite runs. inside_cap returns the real exit status of the command
it runs, so a 143 there means the command, or the --inside-cap
process standing in front of it, was itself stopped by a signal
other than the kernel's own OOM kill.

This machine has DefaultOOMPolicy=stop (systemctl --user show -p
DefaultOOMPolicy) and systemd-oomd active. With OOMPolicy=stop (the
default cap_prefix left unset), when the kernel OOM-kills one process
of a scope, systemd additionally stops the whole scope, which means
sending SIGTERM to every process still in it. On a quiet machine the
kernel's SIGKILL reaches the heavy command first and inside_cap,
which ignores SIGTERM by design, is long past installing that
ignore-handler by the time systemd's own SIGTERM would arrive, so it
keeps running and reports 137. Under load, process startup and
signal delivery both become less predictable, and systemd's SIGTERM
can arrive at inside_cap before it has installed its ignore-handler
(default disposition terminates it), or reach the command through a
different path than the kernel's SIGKILL, producing 143 instead.

I could not reproduce the 143 result myself: 40 isolated runs of the
one test and 40 full-suite runs, all under the load of 16 busy
processes (load average 13-48) and with this machine's swap
consistently near full throughout (a condition present in every
attempt), all passed. The failure the controller measured is real
(they quoted it directly) and every fact checked here is consistent
with their hypothesis, but I have no journal capture of an actual
143 run of my own to include. Fixed the cause the evidence supports
rather than leave it unaddressed.

Fix: added "-p", "OOMPolicy=continue" to cap_prefix(), so systemd
only logs the kernel's OOM kill and leaves the rest of the scope
alone; inside_cap stays alive to see its child die from the kernel's
own SIGKILL and to write the peak file, and the command's exit
status is the kernel's 137. cap_usable()'s probe already builds its
command from cap_prefix(), so the probe declares this property too
with no extra code.

man systemd.scope documents OOMPolicy as a scope-unit property added
in systemd 243 (this machine runs 255). Checked what an older
systemd does with a property it does not recognize: `systemd-run
--user --scope -p ThisPropertyDoesNotExist=1 -- true` exits 1 with
"Unknown assignment", never running the command. cap_usable() already
treats any nonzero probe exit as "no cap"; an systemd older than 243
would report cap_usable() == False through this same existing path,
with no special case needed.

Test first: added "-p", "OOMPolicy=continue" to the expected list in
CapTest.test_prefix_holds_the_limits (a unit test of cap_prefix());
left the process-level test's expected exit code at 137 unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…he wrapper (#45)

The usage text listed eight environment variables as settings without
saying who sets them, which read as an invitation to set any of them
on a single call. In normal use nobody sets them: the tests set most
of them, and a person can set the tuning values in a shell profile so
every session on the machine agrees. A call that sets one for itself
stops sharing the queue with the machine's other sessions (a smaller
BOUNDED_RUN_SLOT_MIB, an empty BOUNDED_RUN_LOCK_DIR, or
BOUNDED_RUN_NO_CAP get around the queue or the cap for that one call).

Replaced the environment-variable part of the module docstring with
text that says this first, then splits the variables into the three
tuning values (with their defaults) and the values for tests and for
diagnosis. Kept every variable's existing description and default;
changed no behavior. Added test_says_who_sets_the_environment_variables
so a later edit cannot drop the who-sets-them sentence again.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…s of the cap process are restored (#45)

inside_cap put the old signal handlers back before it read the peak of
the cgroup. With the default OOM policy, systemd stops the scope after
the kernel kills a process of it for memory, and sends SIGTERM to each
process that is left. A SIGTERM after the restore ended inside_cap, and
the wrapper gave 143 in place of the 137 of the command.

The handlers that do nothing now stay in place until the peak file is
written.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…hat has no OOM policy for a scope (#45)

A scope unit accepts OOMPolicy= only from systemd 253 (NEWS, changes
with 253: "Scope units now support OOMPolicy="). On systemd 249 to 252
the probe of the cap failed, and each call ran with no hard cap.

The wrapper now probes the prefix with OOMPolicy=continue first, and
then the prefix without it. It uses the first one that works, and
applies no cap only when both fail.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 29, 2026 08:42
@sourcehawk

Copy link
Copy Markdown
Owner Author

Review of 08:41 UTC: no finding, and one under "previously missed".

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Exclusive-lock identification and signal escalation still have failure paths that can break coordination or termination.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Escalate repeated signals during child startup

skills/​bounding-heavy-commands/​scripts/​bounded_run.py:661

A second stop signal received while Popen is still starting the child is recorded but not escalated: this branch always forwards received[0]. If the command ignores that first signal, the wrapper can wait indefinitely even though the user sent the documented second signal to force termination. Mirror forward() here by sending SIGKILL when more than one signal is already pending, and cover the pre-registration race in the signal test.

sourcehawk and others added 2 commits September 29, 2026 09:50
…name the repository in time (#45)

When the git call took too long, the wrapper used the directory in place of the repository. Each worktree then had its own lock for one --exclusive name, and two commands ran together on the same resource. The wrapper now ends with an error. A machine with no git still uses the directory.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… signal during its start (#45)

Two stop signals that came while the command started were both recorded, and the wrapper sent only the first to the command. A command that ignores that signal then ran to its end. The wrapper now sends SIGKILL, as it does for a second signal after the start.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 29, 2026 08:50
@sourcehawk

Copy link
Copy Markdown
Owner Author

Review of 08:46 UTC: one inline comment, which has a reply in its thread, and one finding under "previously missed".

  • bounded_run.py:661, a second stop signal during the start of the command: correct, corrected in fcaf35f. The wrapper sends SIGKILL when more than one signal came before the command ran. The test starts a command that ignores the first signal, and it failed before the change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

A valid large memory argument can currently cause an uncaught overflow and traceback.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Avoid float overflow when clamping large memory values

skills/​bounding-heavy-commands/​scripts/​bounded_run.py:205

parse_size_mib accepts arbitrary-size integers, but this / converts the budget to a float before the queue-cap clamp. A sufficiently large syntactically valid --memory value therefore raises OverflowError, escapes the WrapperError handling, and prints a traceback instead of returning the documented wrapper error. Use integer ceiling division so every accepted size remains bounded by count without a float conversion.

…budget with whole numbers (#45)

The count of slots divided the budget as a float. A budget too large for a float gave a traceback in place of the budget of the queue.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 29, 2026 08:57
@sourcehawk

Copy link
Copy Markdown
Owner Author

Review of 08:55 UTC: no finding, and one under "previously missed".

  • bounded_run.py:205, a budget too large for a float: correct, corrected in 7419ff6. The count of slots uses whole numbers, and such a budget gets the budget of the queue with the usual warning. Two tests failed first.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Repository detection can break exclusive locking, and fan-out guidance contradicts the wrapper-unavailable fallback.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Serialize heavy commands when wrapper fallback is unavailable

skills/​fanning-out-with-worktrees/​SKILL.md:147

This rule omits the wrapper-unavailable exception and directly conflicts with bounding-heavy-commands lines 130 and 140. In that fallback there is no queue, so dispatching the full wave can let multiple subagents run plain heavy commands together—the exact load this change is meant to prevent. Preserve the full wave only when the wrapper works; otherwise serialize subagents' heavy-command execution as the fallback requires.

sourcehawk and others added 2 commits September 29, 2026 10:04
… a reason other than no repository (#45)

Each result of git other than success counted as "not a repository", and the wrapper used the directory. A fault such as an owner that git does not trust then gave each worktree its own lock for one --exclusive name. The wrapper now uses the directory only when git says that the directory is not a repository.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… wrapper cannot run (#45)

The rule against a smaller wave gave the queue as its reason and did not say what holds when no queue exists.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 29, 2026 09:05
@sourcehawk

Copy link
Copy Markdown
Owner Author

Review of 09:02 UTC: one inline comment, which has a reply in its thread, and one finding under "previously missed".

  • skills/fanning-out-with-worktrees/SKILL.md:147, the wave on a machine with no wrapper: correct, corrected in 187f49e. The rule now says that on such a machine no queue exists, that the wave stays the same, and that only one subagent at a time runs a heavy command, as bounding-heavy-commands says. A fresh agent with only the two skill files dispatched four subagents in both cases, and on the machine with no Python it let one at a time run a heavy command and gave the plain commands with the fallback rules.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Detached descendants can remain alive without the documented warning after the reservation is released.

Review effort: Balanced
Findings: None

Resolved since last review (1)

Copilot AI review requested due to automatic review settings September 29, 2026 10:29
@sourcehawk
sourcehawk merged commit 0e68383 into main Sep 29, 2026
6 checks passed
@sourcehawk
sourcehawk deleted the feat/bounded-heavy-commands branch September 29, 2026 10:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unbudgeted measurements and fallback dispatch can still run unsafe concurrent work, while SIGQUIT can orphan commands on macOS.

Review effort: Balanced
Findings: 1 High severity · 3 Medium severity · 2 Low severity

Open (6)

Comment thread skills/bounding-heavy-commands/SKILL.md Resolved
Comment thread README.md Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run the heavy commands of agents under a machine-wide memory limit

2 participants