From 1d6eb1e40b436ef05606e217a705c89f4b57e0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86gir=20M=C3=A1ni=20Hauksson?= <54936225+sourcehawk@users.noreply.github.com> Date: Tue, 29 Sep 2026 14:49:52 +0100 Subject: [PATCH 1/6] fix(skills/bounding-heavy-commands): run a first measurement alone in the queue (#49) A measurement with no budget took the default budget, a quarter of the machine, while the peak of the command was not known. Several sessions could measure several commands together, and with no hard cap nothing stopped them. Such a measurement now takes each slot of the queue. It waits for the free memory of the default budget only, because the memory of the full queue is seldom free. Co-Authored-By: Claude Fable 5.1 --- .../scripts/bounded_run.py | 7 +++- .../scripts/tests/test_bounded_run.py | 42 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/skills/bounding-heavy-commands/scripts/bounded_run.py b/skills/bounding-heavy-commands/scripts/bounded_run.py index 2639961..a5bb6a6 100755 --- a/skills/bounding-heavy-commands/scripts/bounded_run.py +++ b/skills/bounding-heavy-commands/scripts/bounded_run.py @@ -785,6 +785,7 @@ def bounded(options: Options, environ: Mapping[str, str]) -> int: budget = parse_size_mib(options.memory) else: budget = default_budget_mib(settings.total_mib, settings.slot_mib) + wait_budget = budget command = list(options.command) if shutil.which(command[0], path=environ.get("PATH")) is None: raise WrapperError("cannot start '%s': the command does not exist" % command[0]) @@ -794,9 +795,13 @@ def bounded(options: Options, environ: Mapping[str, str]) -> int: if settings.reserve_mib >= settings.total_mib: log("WARNING: the reserve of %d MiB leaves no memory of the %d MiB of the machine; the queue does not keep the reserve" % (settings.reserve_mib, settings.total_mib)) most = queue_mib(settings.total_mib, settings.slot_mib, settings.reserve_mib) + if options.measure and options.memory is None: + # The peak of this command is not known yet, so no other command runs beside it. + budget, needed = most, count if budget > most: log("WARNING: the budget of %d MiB is more than the %d MiB of the queue; the budget is %d MiB" % (budget, most, most)) budget = most + wait_budget = min(wait_budget, budget) uid = os.getuid() directory = lock_directory(environ, uid) ensure_lock_directory(directory, uid) @@ -842,7 +847,7 @@ def read_sample() -> Optional[int]: reported: Optional[int] = None reservation = reserve(directory, count, needed, exclusive_files, settings.poll_seconds) try: - wait_for_memory(budget, settings.memory_wait_seconds, settings.poll_seconds) + wait_for_memory(wait_budget, settings.memory_wait_seconds, settings.poll_seconds) code, maxrss = run_command(command, child_environ, start_tracker) tracked = trackers[0].finish() if trackers else None finally: diff --git a/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py b/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py index 9b3aade..d00a786 100644 --- a/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py +++ b/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py @@ -1734,6 +1734,48 @@ def test_without_a_cap_the_output_says_so(self): output, errors = process.communicate(timeout=60) self.assertIn("no hard cap is available here", errors) + def test_a_first_measurement_runs_alone_in_the_queue(self): + command = [sys.executable, "-c", WORKER, "measured"] + first = self.wrapper(["--measure"], command, HOLD="1.0") + self.wait_for_event("start", "measured") + second = self.worker("second", "2G", hold="0.1") + self.assertEqual(first.wait(timeout=60), 0) + self.assertEqual(second.wait(timeout=60), 0) + self.assertEqual(self.peak_concurrency(), 1) + self.assertIn("bounded-run: budget 4096 MiB, peak ", self.stderr_of(first)) + + def test_a_first_measurement_waits_for_the_commands_that_run(self): + first = self.worker("first", "2G", hold="1.0") + self.wait_for_event("start", "first") + second = self.wrapper(["--measure"], [sys.executable, "-c", WORKER, "measured"], HOLD="0.1") + self.assertEqual(first.wait(timeout=60), 0) + self.assertEqual(second.wait(timeout=60), 0) + self.assertEqual(self.peak_concurrency(), 1) + + def test_a_measurement_with_a_budget_takes_the_slots_of_the_budget(self): + first = self.wrapper(["--measure", "--memory", "2G"], [sys.executable, "-c", WORKER, "measured"], HOLD="1.0") + self.wait_for_event("start", "measured") + second = self.worker("second", "2G", hold="0.1") + self.wait_for_event("start", "second") + self.assertEqual(first.wait(timeout=60), 0) + self.assertEqual(second.wait(timeout=60), 0) + self.assertEqual(self.peak_concurrency(), 2) + + def test_a_first_measurement_waits_for_the_memory_of_the_default_budget_only(self): + reads = [] + + def wait(budget, limit, poll): + reads.append(budget) + return True + + options = bounded_run.Options() + options.measure = True + options.command = [sys.executable, "-c", "pass"] + environ = dict(self.environ, BOUNDED_RUN_TOTAL_MIB="34816", BOUNDED_RUN_RESERVE_MIB="2048") + with mock.patch.object(bounded_run, "wait_for_memory", wait), mock.patch.object(bounded_run, "log"): + self.assertEqual(bounded_run.bounded(options, environ), 0) + self.assertEqual(reads, [bounded_run.default_budget_mib(34816, 2048)]) + def test_measure_mode_reports_a_peak_and_a_budget(self): script = "import time\ndata = bytearray(150 * 1024 * 1024)\nfor index in range(0, len(data), 4096):\n data[index] = 1\ntime.sleep(1.0)\n" process = self.wrapper(["--measure"], [sys.executable, "-c", script]) From 0c6465abc265581a764934b5668c3b5b36bd238a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86gir=20M=C3=A1ni=20Hauksson?= <54936225+sourcehawk@users.noreply.github.com> Date: Tue, 29 Sep 2026 14:49:52 +0100 Subject: [PATCH 2/6] fix(skills/bounding-heavy-commands): send SIGQUIT to the command (#49) The quit signal of the terminal ended the wrapper and not the command. On a system with no parent-death signal the command lived on, and the queue counted its slots as free. Co-Authored-By: Claude Fable 5.1 --- skills/bounding-heavy-commands/scripts/bounded_run.py | 4 ++-- .../bounding-heavy-commands/scripts/tests/test_bounded_run.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/skills/bounding-heavy-commands/scripts/bounded_run.py b/skills/bounding-heavy-commands/scripts/bounded_run.py index a5bb6a6..988fd7b 100755 --- a/skills/bounding-heavy-commands/scripts/bounded_run.py +++ b/skills/bounding-heavy-commands/scripts/bounded_run.py @@ -655,7 +655,7 @@ def forward(signum: int, frame: object) -> None: except (ProcessLookupError, PermissionError): pass - previous = {signum: signal.signal(signum, forward) for signum in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP)} + previous = {signum: signal.signal(signum, forward) for signum in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP, signal.SIGQUIT)} try: try: process = subprocess.Popen(list(command), env=dict(environ), start_new_session=True, preexec_fn=parent_death_signal()) @@ -704,7 +704,7 @@ def inside_cap( def keep_running(signum: int, frame: object) -> None: pass - previous = {signum: signal.signal(signum, keep_running) for signum in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP)} + previous = {signum: signal.signal(signum, keep_running) for signum in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP, signal.SIGQUIT)} try: try: process = subprocess.Popen(list(command), preexec_fn=parent_death_signal()) diff --git a/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py b/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py index d00a786..43ef74d 100644 --- a/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py +++ b/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py @@ -1487,7 +1487,7 @@ def test_a_nested_call_of_a_command_that_does_not_exist_gives_125(self): self.assertNotIn("Traceback", errors) def test_a_stop_signal_stops_the_command(self): - for signum, code in ((signal.SIGTERM, 143), (signal.SIGINT, 130)): + for signum, code in ((signal.SIGTERM, 143), (signal.SIGINT, 130), (signal.SIGQUIT, 131)): with self.subTest(signal=signum): name = "stopped-%d" % code process = self.worker(name, "2G", hold="300") From 4f118471254cd919f5fc76e6278dffcaa646c870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86gir=20M=C3=A1ni=20Hauksson?= <54936225+sourcehawk@users.noreply.github.com> Date: Tue, 29 Sep 2026 14:49:52 +0100 Subject: [PATCH 3/6] refactor(skills/bounding-heavy-commands): remove test comments that describe the next line (#49) Co-Authored-By: Claude Fable 5.1 --- .../scripts/tests/test_bounded_run.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py b/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py index 43ef74d..5a8da68 100644 --- a/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py +++ b/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py @@ -405,11 +405,8 @@ def sleep(seconds): def test_a_lock_error_that_is_not_a_busy_lock_is_reported(self): with mock.patch.object(bounded_run.fcntl, "flock") as mock_flock: def flock_side_effect(fd, flags): - # Call the real flock for the turn lock, raise ENOLCK for slot files if flags & bounded_run.fcntl.LOCK_EX and not (flags & bounded_run.fcntl.LOCK_NB): - # This is the turn lock (blocking), allow it return None - # This is a slot lock (non-blocking), fail with ENOLCK raise OSError(errno.ENOLCK, "No locks available") mock_flock.side_effect = flock_side_effect @@ -427,8 +424,6 @@ def test_a_lock_error_of_the_turn_file_is_reported(self): self.assertIn("No locks available", str(caught.exception)) def test_a_lock_error_leaves_no_slot_held(self): - # Prove that when try_reserve fails mid-way, all locks it took are released. - # Wrap os.open to track fd -> path mapping, then use it in a flock stub. fd_to_path = {} real_os_open = os.open @@ -437,7 +432,6 @@ def tracked_open(path, *args, **kwargs): fd_to_path[fd] = path return fd - # flock will count calls and fail on the second slot file. flock_calls_per_file = {} real_flock = bounded_run.fcntl.flock @@ -447,25 +441,20 @@ def counting_flock(fd, flags): flock_calls_per_file[path] = 0 flock_calls_per_file[path] += 1 - # Allow the turn lock and first slot to succeed. if "reserve.lock" in path or "slot-000.lock" in path: return real_flock(fd, flags) - # Fail on the second slot with ENOLCK. if "slot-001.lock" in path: raise OSError(errno.ENOLCK, "No locks available") - # Any other file succeeds. return real_flock(fd, flags) with mock.patch.object(os, "open", tracked_open): with mock.patch.object(bounded_run.fcntl, "flock", counting_flock): - # Call try_reserve for 2 slots; it should fail after locking slot-000. with self.assertRaises(bounded_run.WrapperError): bounded_run.try_reserve(self.directory, 2, 2, []) - # Now call try_reserve again with real functions (no patches). - # If the first slot was not released, this will fail to get 2 slots. + # A slot that the failed call still held makes this call fail. second_try = bounded_run.try_reserve(self.directory, 2, 2, []) self.assertIsNotNone(second_try) self.addCleanup(second_try.release) @@ -496,14 +485,12 @@ def test_an_open_error_leaves_no_slot_held(self): second.release() def test_the_turn_lock_is_free_while_the_wrapper_waits(self): - # Hold all slots so reserve has to wait blocker = bounded_run.try_reserve(self.directory, 1, 1, []) self.addCleanup(blocker.release) turn_lock_acquired = [] def sleep_and_check(seconds): - # Try to acquire the turn lock while reserve is waiting turn_path = os.path.join(self.directory, "reserve.lock") turn_fd = os.open(turn_path, os.O_RDWR | os.O_CREAT, 0o600) try: @@ -514,7 +501,6 @@ def sleep_and_check(seconds): turn_lock_acquired.append(False) finally: os.close(turn_fd) - # Release the blocker so reserve can succeed blocker.release() reservation = bounded_run.reserve(self.directory, 1, 1, [], 0.2, sleep=sleep_and_check) From 3b88368e53475249a014d12a298eb05ee98f14dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86gir=20M=C3=A1ni=20Hauksson?= <54936225+sourcehawk@users.noreply.github.com> Date: Tue, 29 Sep 2026 14:50:02 +0100 Subject: [PATCH 4/6] docs(README): say what a session with no project memory costs (#49) The text said that the queue still protects the machine with memory off. For a command that was never measured, on a machine with no hard cap, the default budget can be less than the command needs. Co-Authored-By: Claude Fable 5.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d436373..1839f7a 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ A local path also works for development: `/plugin marketplace add /path/to/featu No further setup is required; the skills derive your repo and build commands from context. Optionally, paste [`templates/project-CLAUDE.md`](templates/project-CLAUDE.md) into your project's `CLAUDE.md` to give every session the workflow overview and the operational rules (commit conventions, safe git staging, GitHub-mutation confirmation). -Keep project memory on to get the most from `bounding-heavy-commands`. In Claude Code that is auto memory, which is on by default. The skill saves the measured memory budget and the bounded command line of each heavy command there, so a later session starts with them. With memory off, the queue still protects the machine, but each session measures the commands again and uses the default budget for a command that it did not measure. +Keep project memory on to get the most from `bounding-heavy-commands`. In Claude Code that is auto memory, which is on by default. The skill saves the measured memory budget and the bounded command line of each heavy command there, so a later session starts with them. With memory off, each session measures the commands again, and each first measurement runs alone in the queue, so the sessions wait for each other more often. A command that a session did not measure runs under the default budget, which can be less than the command needs. ## Notes From cd4683b49ae9036d354f145ee87241ae7b447e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86gir=20M=C3=A1ni=20Hauksson?= <54936225+sourcehawk@users.noreply.github.com> Date: Tue, 29 Sep 2026 14:58:49 +0100 Subject: [PATCH 5/6] fix(skills/bounding-heavy-commands): record a budget from a full run only, and dispatch in sequence with no wrapper (#49) An agent recorded the budget of a test suite that stopped at its first failure, in the third of about 200 files. The budget was too small and stayed in the record. The skill now takes a budget only from a run that did its full work, and says that a first measurement takes the whole queue. With no wrapper, no lock makes subagents take turns, and the skills gave the orchestrator no means to keep two heavy commands apart. The subagents that run a heavy command are now dispatched one after the other. Co-Authored-By: Claude Fable 5.1 --- skills/bounding-heavy-commands/SKILL.md | 12 ++++++------ skills/fanning-out-with-worktrees/SKILL.md | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/skills/bounding-heavy-commands/SKILL.md b/skills/bounding-heavy-commands/SKILL.md index 3e9149f..da8dd0b 100644 --- a/skills/bounding-heavy-commands/SKILL.md +++ b/skills/bounding-heavy-commands/SKILL.md @@ -36,10 +36,10 @@ python3 "${CLAUDE_PLUGIN_ROOT}/skills/bounding-heavy-commands/scripts/bounded_ru | Option | Meaning | | --- | --- | -| `--memory ` | Memory the command may use, such as `6G` or `4096M`. Taken from the record. Without it the wrapper uses its default budget, a quarter of the machine's memory. | +| `--memory ` | Memory the command may use, such as `6G` or `4096M`. Taken from the record. Without it the wrapper uses its default budget, a quarter of the machine's memory, or the whole queue for a measurement. | | `--cpus ` | Processor limit, as a whole number. Taken from the record. | | `--exclusive ` | A resource that only one command may hold at a time, such as a fixed port. You choose the name. The wrapper keeps the names of each repository apart, and all worktrees of one repository share them. Repeat the option for each resource. | -| `--measure` | Also print a suggested budget. Discovery uses it. | +| `--measure` | Also print a suggested budget. Discovery uses it. With no `--memory`, the command runs alone in the queue. | The wrapper does four things in sequence. It waits for its turn in the queue. It waits until the memory of its budget is free. It runs the command. It prints the budget and the measured peak on the error stream. Each line that the wrapper prints starts with `bounded-run:`. Its exit code is the command's exit code. Exit code 125, with a `bounded-run:` line that names a fault and with no line for the budget and the peak, means that the wrapper itself failed (see §When the wrapper cannot run). @@ -90,10 +90,10 @@ A part of a recorded command (one test file, one target) uses the bounded comman python3 "${CLAUDE_PLUGIN_ROOT}/skills/bounding-heavy-commands/scripts/bounded_run.py" --measure -- ``` -5. Record the suggested budget that the wrapper prints. It is the peak plus a margin, and the margin is larger where the measurement is approximate. The measurement runs under the default budget. If the hard cap stopped the command during the measurement, run it again with `--memory` at two times the default budget that the wrapper printed. +5. Record the suggested budget that the wrapper prints, but only from a run in which the command did its full work. It is the peak plus a margin, and the margin is larger where the measurement is approximate. A run that stopped early gives a peak that is too small: a suite that stops at its first failure, a command that failed at its start, a run that a signal or the hard cap stopped. Do not record the budget of such a run, and save no record for the command yet. Run the command with `--measure` again each time that you run it, until one run does its full work. A measurement with no `--memory` takes the whole queue, because the peak of the command is not known: it waits until no other bounded command runs, and no other starts while it runs. When it waits, tell the user that a first measurement waits for the other bounded commands to end. If the hard cap stopped a measurement with `--memory`, measure again with two times that budget. If it stopped a measurement with no `--memory`, the command needs more memory than the queue has: tell the user, with the budget that the wrapper printed. 6. Save the record. -The measured run is a real run of the command. Its result counts, so do not run the command a second time to get the result. +The measured run is a real run of the command. Its result counts, also when the run stopped early, so do not run the command a second time to get the result. ## Rules for the wait @@ -127,7 +127,7 @@ On a machine on which the wrapper can run, every dispatch prompt for a subagent 2. This rule, in these words: "Run the bounded commands as written. You can make two changes: a narrower argument at the end of the line, such as one test file, and one more `--exclusive ` option after a collision on a port or a lock, which you name in your report. Do not run the plain form of a bounded command or of a part of it. For a heavy command that is not in this prompt, use the same wrapper with no `--memory` option. If the file of the wrapper does not exist, stop and report that. Set no environment variable whose name starts with `BOUNDED_RUN_`. A command can wait in the queue for minutes before it starts, so run it in the background and do not put a short timeout around it. A long wait means that the machine is full; it is not a fault to repair. Say in your report how long you waited." 3. Each command that an instruction exempts from the wrapper, in its plain form, in a list of its own, with the instruction that exempts it. The rule of item 2 does not apply to that list. An instruction of the user that covers one run goes to the one subagent that does that run, and to no other. -Do not dispatch fewer subagents to protect the machine. The queue protects it. Subagents that wait in the queue cost time, not memory. The one exception is a machine on which the wrapper cannot run (see the next section). +Do not dispatch fewer subagents to protect the machine. The queue protects it. Subagents that wait in the queue cost time, not memory. On a machine on which the wrapper cannot run, the next section says how to dispatch. ## When the wrapper cannot run @@ -137,7 +137,7 @@ When `python3` reports that it cannot open the file of the wrapper, the path in When the wrapper ends with exit code 125, read its `bounded-run:` message. A fault of your call (an option, a name, a command that does not exist) is yours to correct. A fault of the machine (the wrapper cannot make or lock its files) means that the wrapper cannot run here: tell the user once per session, with the message. -When Python is missing or too old, and when the fault is a fault of the machine, continue under these fallback rules. Run one heavy command at a time, never two in parallel, and set the toolchain's parallelism to half the machine's processors or fewer. Your subagents count as your session: no queue protects the machine now, so dispatch them so that only one of them runs a heavy command at a time. Their prompts carry the plain commands and these fallback rules, in place of the three items of §Dispatching subagents. The fallback protects the machine from your session only, not from the other sessions. Tell the user that in your report. +When Python is missing or too old, and when the fault is a fault of the machine, continue under these fallback rules. Run one heavy command at a time, never two in parallel, and set the toolchain's parallelism to half the machine's processors or fewer. Your subagents count as your session: no queue protects the machine now, and no lock makes them take turns. So dispatch one after the other the subagents that run a heavy command, and start the next one only after the one before it gave its report. Subagents that run no heavy command can run together. Their prompts carry the plain commands and these fallback rules, in place of the three items of §Dispatching subagents. The fallback protects the machine from your session only, not from the other sessions. Tell the user that in your report. ## Red flags diff --git a/skills/fanning-out-with-worktrees/SKILL.md b/skills/fanning-out-with-worktrees/SKILL.md index 122f7ec..f692c6d 100644 --- a/skills/fanning-out-with-worktrees/SKILL.md +++ b/skills/fanning-out-with-worktrees/SKILL.md @@ -60,7 +60,7 @@ Each dispatch prompt MUST include: 2. **Context handoff.** State file path, plan path, spec path, the issue number it's working, the relevant contract row(s) (Name + Producer + Consumer + Shape + Realization), **and the plan's `## Conventions` block**. The subagent implements **against the contract and the conventions** — it does not re-discover or re-design either, and it does not invent its own directory layout or naming scheme. A subagent handed contracts but not conventions will name and structure locally, and the merged feature reads as written by a committee (see `feature-dev-workflow:maintaining-architectural-coherence`). 3. **Implementation skills.** `superpowers:test-driven-development` + `feature-dev-workflow:testing-a-feature` for every change, and `feature-dev-workflow:writing-code-comments` for every comment the change adds, edits, or deletes. 4. **PR completion.** A stack layer's subagent skips this item and reports to the orchestrator, which opens the stack's PRs (see the stack paragraph above). A sequential layer's subagent reports its finished branch and head commit without pushing, because the orchestrator pushes the stack's worktree with `gh stack push`. A parallel layer's subagent pushes its branch from its temporary worktree first, then reports. Every other subagent, when the implementation is done and verified, invokes `feature-dev-workflow:opening-a-pull-request`. The base and body keyword depend on `sub_pr_target` in the state file: when `feature-branch`, use `--base /` and `Towards #` in the body (`Fixes`/`Closes` don't fire on non-default-branch merges; `Towards` keeps the issue open until the orchestrator closes it manually after the merge); when `main`, use `--base main` and the type-appropriate closing keyword in the body — `Fixes #` for a bug sub-issue, `Closes #` otherwise; either fires automatically on merge to the default branch (see `feature-dev-workflow:opening-a-pull-request` for the distinction). No sub-PR keyword closes the epic, and in main mode the epic stays open for the user (see Step 7). The subagent reports the PR URL back to the orchestrator. -5. **Bounded commands.** The bounded command line for every heavy command the subagent will run (tests, lint, build, typecheck), copied from the orchestrator's record, and the rule to use no other form. A subagent does not see the orchestrator's project memory, so a prompt without them sends it to the plain commands, and a wave of plain test runs is what freezes the machine. **REQUIRED SUB-SKILL:** `feature-dev-workflow:bounding-heavy-commands` (§Dispatching subagents) before writing the first dispatch prompt of a wave. +5. **Bounded commands.** The bounded command line for every heavy command the subagent will run (tests, lint, build, typecheck), copied from the orchestrator's record, and the rule to use no other form. A subagent does not see the orchestrator's project memory, so a prompt without them sends it to the plain commands, and a wave of plain test runs is what freezes the machine. **REQUIRED SUB-SKILL:** `feature-dev-workflow:bounding-heavy-commands` (§Dispatching subagents) before writing the first dispatch prompt of a wave. When the wrapper cannot run on the machine, its §When the wrapper cannot run decides the prompts and the order of the dispatch. Each dispatch prompt also carries this instruction for the subagent: **OPTIONAL SUB-SKILL:** `simple-english:simple-english` for the prose of your commit bodies, code and doc comments, and PR body. If it is available, load it before you draft and write the sentences under it. Where its formatting rules (headings, bold, lists, or its register for chat replies) differ from the host skill or its template, the host skill and its template win. It sets sentence style only: the commit subject keeps the project's commit convention, and the project's comment rules still decide whether a comment exists and what it may say. If it is not available, do not stop or wait for it: write short, plain, active sentences and say in your report that it was missing. The orchestrator, not the subagent, gives the user the install hint (`/plugin marketplace add AminBlg/SimpleEnglish`, then `/plugin install simple-english@simple-english`), at most once per session. @@ -144,7 +144,7 @@ When every wave is complete (every sub-issue closed, every row `self-merged`, ev - **Orchestrator fixing review findings in place.** The worktree subagent wrote the code and holds the context; it fixes, then the orchestrator re-reviews. A silent orchestrator fix skips the author and erodes the shared understanding the parallel agents run on. - **Letting the worktree subagent review its own PR.** A subagent reviewing the code it just wrote has the same blind spots in review that it had in implementation. The orchestrator owns sub-PR review precisely because it didn't write the code. - **Letting a bubble-up concern die in one subagent.** Propagation is the whole point of the watch loop. -- **Shrinking the wave to spare the machine.** The number of subagents does not decide the load; the commands they run do. Dispatch the wave the plan calls for and hand every subagent the bounded commands (dispatch item 5). Subagents that wait in the queue cost time, not memory. On a machine on which the wrapper cannot run, no queue exists: dispatch the same wave, and let only one subagent at a time run a heavy command, as `feature-dev-workflow:bounding-heavy-commands` says. +- **Shrinking the wave to spare the machine.** The number of subagents does not decide the load; the commands they run do. Dispatch the wave the plan calls for and hand every subagent the bounded commands (dispatch item 5). Subagents that wait in the queue cost time, not memory. On a machine on which the wrapper cannot run, no queue exists: dispatch the subagents of the wave that run a heavy command one after the other, as `feature-dev-workflow:bounding-heavy-commands` says. - **Forgetting to manually close the sub-issue when `sub_pr_target: feature-branch`.** The keyword doesn't fire on non-default-branch merges; the issue page silently shows "open" even though the work shipped. - **Using `Towards #` when `sub_pr_target: main`.** `Closes` fires on merge to the default branch; `Towards` intentionally blocks auto-close. Using the wrong keyword silently leaves sub-issues open after they merge to main and forces a manual cleanup pass. - **Letting the state file go stale.** A resumed session reads it as ground truth. Update every row as reality moves; commit **and push** the state-file diff per phase transition — an unpushed local commit diverges the feature branch the moment the next sub-PR squash-merges on GitHub (see Step 5.4). From a82d391e33194d05acb2a7e89766c8abc56b2391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86gir=20M=C3=A1ni=20Hauksson?= <54936225+sourcehawk@users.noreply.github.com> Date: Tue, 29 Sep 2026 15:04:45 +0100 Subject: [PATCH 6/6] fix(skills/bounding-heavy-commands): keep a stop signal that comes before the capped command runs (#49) The process inside the cap took a stop signal and did nothing with it. A signal that came before the command existed was lost, and the command ran to its end. The process now sends that signal to the command after the start, and SIGKILL when more than one came. Co-Authored-By: Claude Fable 5.1 --- .../scripts/bounded_run.py | 13 +++++++++- .../scripts/tests/test_bounded_run.py | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/skills/bounding-heavy-commands/scripts/bounded_run.py b/skills/bounding-heavy-commands/scripts/bounded_run.py index 988fd7b..85e7167 100755 --- a/skills/bounding-heavy-commands/scripts/bounded_run.py +++ b/skills/bounding-heavy-commands/scripts/bounded_run.py @@ -701,8 +701,13 @@ def inside_cap( The cgroup exists for as long as this process is in it. Thus the peak is readable after the command stops, which is not possible from outside the cgroup. """ + early: List[int] = [] + started: List[int] = [] + def keep_running(signum: int, frame: object) -> None: - pass + # The wrapper sends a signal to the process group, so the command gets its own copy once it runs. + if not started: + early.append(signum) previous = {signum: signal.signal(signum, keep_running) for signum in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP, signal.SIGQUIT)} try: @@ -711,6 +716,12 @@ def keep_running(signum: int, frame: object) -> None: except OSError as error: log("cannot start '%s': %s" % (command[0], error)) return EXIT_WRAPPER + started.append(process.pid) + if early: + try: + os.kill(process.pid, early[0] if len(early) == 1 else signal.SIGKILL) + except (ProcessLookupError, PermissionError): + pass _, status = os.waitpid(process.pid, 0) process.returncode = exit_code_of(status) # After the kernel kills a process of the scope for memory, systemd can stop the scope with SIGTERM. diff --git a/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py b/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py index 5a8da68..1095d51 100644 --- a/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py +++ b/skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py @@ -1000,6 +1000,30 @@ def test_writes_the_peak_after_the_command_stops(self): self.assertEqual(bounded_run.read_peak_file(self.peak_file), 300) self.assertFalse(os.path.exists(self.peak_file)) + def signal_at_start(self, signals): + real = subprocess.Popen + + def start_then_signal(*args, **kwargs): + for signum in signals: + os.kill(os.getpid(), signum) + return real(*args, **kwargs) + + return mock.patch.object(bounded_run.subprocess, "Popen", start_then_signal) + + def test_a_stop_signal_before_the_command_runs_stops_the_command(self): + started = time.monotonic() + with self.signal_at_start([signal.SIGQUIT]): + code = self.inside([sys.executable, "-c", "import time; time.sleep(20)"]) + self.assertEqual(code, 128 + signal.SIGQUIT) + self.assertLess(time.monotonic() - started, 10) + + def test_two_stop_signals_before_the_command_runs_kill_the_command(self): + started = time.monotonic() + with self.signal_at_start([signal.SIGTERM, signal.SIGTERM]): + code = self.inside([sys.executable, "-c", "import time; time.sleep(20)"]) + self.assertEqual(code, 128 + signal.SIGKILL) + self.assertLess(time.monotonic() - started, 10) + def test_writes_nothing_without_the_peak_file_of_the_kernel(self): Path(self.cgroup, "memory.current").write_text("%d\n" % (100 * 1024 * 1024)) self.assertEqual(self.inside([sys.executable, "-c", "pass"]), 0)