Skip to content

Commit 0632eb3

Browse files
sourcehawkclaude
andcommitted
fix(skills/bounding-heavy-commands): count the scope that a check runs in among the unused budgets
A check run from inside a bounded command left that command's unused budget out, so it could answer starts=yes where a wrapper that starts on its own counts that budget and waits. The check now counts every bounded scope. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 59816d4 commit 0632eb3

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎skills/bounding-heavy-commands/scripts/bounded_run.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,10 +1347,10 @@ def check(
13471347
if line is not None:
13481348
os.close(line)
13491349
scopes = scope_parent_directory(choice[1]) if choice is not None else None
1350-
skip = [name for name in (own_scope_name(),) if name is not None]
13511350
if read_outstanding is None:
1351+
# A wrapper that starts on its own counts every bounded scope, also the one that this check runs in.
13521352
def read_outstanding() -> Optional[int]:
1353-
return None if scopes is None else unused_budget_mib(scopes, skip)
1353+
return None if scopes is None else unused_budget_mib(scopes, ())
13541354

13551355
if settings.free_mib is None:
13561356
before = read_outstanding()

‎skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,23 @@ def held(parent, skip):
21032103
self.assertEqual(self.lines[1], "check held unit=bounded-run-7-abcdef budget=4096M used=100M age=5s dir=/w command=tool")
21042104
self.assertTrue(self.lines[2].startswith("check budget=2048M "), self.lines)
21052105

2106+
def test_a_check_inside_a_bounded_command_counts_its_unused_budget_too(self):
2107+
self.environ.pop("BOUNDED_RUN_NO_CAP")
2108+
output = "0::/user.slice/app.slice/bounded-run-1-000000-probe.scope\n"
2109+
skips = []
2110+
2111+
def unused(parent, skip):
2112+
skips.append(list(skip))
2113+
return 0
2114+
2115+
options = bounded_run.parse_arguments(["--check"])
2116+
with mock.patch.object(bounded_run, "probe_cap", return_value=output), \
2117+
mock.patch.object(bounded_run, "own_scope_name", return_value="bounded-run-2-111111.scope"), \
2118+
mock.patch.object(bounded_run, "unused_budget_mib", unused), \
2119+
mock.patch.object(bounded_run, "held_commands", return_value=[]):
2120+
bounded_run.check(options.budgets, self.environ, read_available=lambda: 9000)
2121+
self.assertEqual(skips, [[], []])
2122+
21062123
def test_a_check_inside_a_bounded_command_names_that_command_too(self):
21072124
self.environ.pop("BOUNDED_RUN_NO_CAP")
21082125
output = "0::/user.slice/app.slice/bounded-run-1-000000-probe.scope\n"

0 commit comments

Comments
 (0)