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
feat(skills/bounding-heavy-commands): measure every heavy command of a project in one run before agents need them - #63
Heavy commands were measured one at a time, when an agent first needed each one, in the middle of feature work on a busy machine. Each first measurement took the whole queue at a random moment, and a project's record filled up unevenly. When a project has no record, discovery now covers every heavy command of the project, and the agent writes one command line that measures all of them at several --cpus values and asks the user to run it. The wrapper gets --measure-rows, which measures one command's rows largest first and passes each row's suggested budget to the next, so that line needs no state between calls.
Changes
--measure-rows N,N,... measures one command at each --cpus value, largest first. The largest row uses the call's --memory, and each smaller row uses the suggested budget of the row before it. After a failed row, the next row keeps the failed row's --memory, so a failed run's peak is never used as a budget.
--label NAME tags the output. Each measurement prints one row line in a fixed form: bounded-run: row label=<name> cpus=<n> budget=<n>M peak=<n>M exact=<yes|no> exit=<code>.
Discovery: with no record, find every heavy command, plan rows at all, half, and a quarter of the processors (half is the default row, and a command with self-bound: none, or one that reuses its own output such as a build, gets that row only), and write one ;-joined line with a --measure-rows call per command, each with a label of its own. The agent asks the user to run it, and does not run it unasked. When the user ran it in a terminal, the agent asks for the row lines and the end of each command's output.
While the user decides, a heavy command the agent needs runs at half --cpus with no --memory. If the user declines, discovery falls back to measuring on demand, as before.
Two new red-flag rows: measuring only the command needed now, and running the measurements unasked.
Challenges
A row that exits with a stop code (129, 130, 131, 143) ends the remaining rows of that call. But Ctrl-C on the ;-joined line ends only the current wrapper call: the wrapper exits normally with 130 rather than dying from the signal, so the shell moves on to the next command, and the user presses Ctrl-C once per command.
Follow-up: make the wrapper die from SIGINT after its cleanup, so that one Ctrl-C ends a joined line.
Testing
TDD for the script. The tests cover parsing (rows sorted largest first and deduplicated, and bad rows, including digits that are not ASCII, labels, and option combinations rejected), the exact row line, the chain of budgets between rows, a failed row, a stop signal ending the rows, and a stop after a failed row keeping the first failed exit code. They also run a real process over two rows. In the RED baseline, an agent in a project with six heavy commands measured only the unit tests at a --cpus it picked, and left five commands without an entry. With the change, a fresh agent wrote one line that measured all six commands at three --cpus values, with the port name of the integration suite. It asked the user to run it, ran the unit tests meanwhile, and wrote the rows from sample output, with no row for a run that stopped early.
Comment gate (comment_growth.py): the recorded review base left the history in the rebase after the #58 fix, so the gate compared with the parent branch. The self-evaluated fallback applies: this session could not dispatch an agent. This round added, changed, or removed no code comment, so there is no flag of this round. The only flag on #64 is the module usage text, which the PR grew before the review to document --check. That is text that users read, and it stays as it is.
Review round on 8fd82bd (review 5360279500). No suppressed findings.
Require unique labels for commands in joined lines: applied in c0c5270.
Preserve first nonzero exit code after interruption: fixed in 5fcc183, with a test.
Measure all CPU quota rows for self-bound none commands: declined. See the thread: a CPU quota does not change the number of things that the tool runs at once, and the extra rows cost two full runs each.
Request complete output when external terminal output is unavailable: applied in c0c5270.
Comment gate: this round added, changed, or removed no code comment on this layer. Self-evaluated fallback: this session could not dispatch an agent.
Review round on c0c5270 (review 5360361217). No suppressed findings.
Handle oversized numeric row values without traceback: fixed in ccc0be2, with a test.
Correct documented fixed-form row syntax: fixed in 3937e25.
Comment gate: one new inline comment in parse_arguments, "int() refuses a number with more digits than its limit." It stays, because it gives the reason for the except, which the code cannot show. Self-evaluated: this session could not dispatch an agent.
Pending measurements can be bypassed by cached generator output
skills/bounding-heavy-commands/SKILL.md:127
This single-row exception only prevents later rows in the same call from reusing output. The new instructions at lines 92 and 137 still allow an agent to run this same build/generator while the measurement is pending; its subsequent single measurement can then be a cached no-op and record an undersized budget. Ensure a pending stateful command is measured before any needed run that warms its output, or otherwise restore/force equivalent work before its measurement.
Review round on 0e6a215 (review 5360737970). The review has no inline findings.
Previously missed, on SKILL.md:127, "Pending measurements can be bypassed by cached generator output" (no thread): declined, no change. The one-row rule of 4e4f754 exists because rows in one --measure-rows call run back to back, so every row after the first would measure a warm command against a cold one. A single measurement of a build after an earlier build is the normal state of a project, not a fault of the pending line: the agents' later runs are warm too, so the recorded budget fits the runs it is used for. When a cold run does need more, the hard cap stops it with exit 137, and the existing rule (step 5 of §Discovery) measures it again at two times the budget. A rule that orders every run of a stateful command around a pending measurement would add text to tuned skill prose for a case that the cap already corrects.
Follow-up round, from a finding on #71 (review 5363805257, thread r4142652768) about code of this PR.
A SIGTERM, SIGHUP, or SIGQUIT between two rows, or after the list, ended the wrapper with a traceback. Fixed in 5b94bc0: _bounded_rows catches the signal around the whole list, and main() catches _Stopped. New test: test_a_stop_signal_outside_a_row_ends_main_with_its_code.
Comment gate, self-evaluated: the rows-loop comment changed to "A signal while a row runs comes back as its exit code. A signal at any other time in the list raises." A new comment in main() reads "The handlers of --measure-rows can fire after its list ends, before they are put back." Both stay, because they give reasons that the code here cannot show.
…a project in one run that the user starts
A project with no record got its measurements one command at a time, when an agent first needed each command. An agent asked to fix a bug and run the unit tests measured only the unit tests, at a --cpus that it picked, asked the user nothing, and left the other heavy commands without an entry. Each of those later first measurements holds the whole queue in the middle of someone's work, and the rows of the record come out at whichever --cpus each session picked.
When the record does not exist, discovery now covers every heavy command of the project. The agent writes one command line that measures each command at all, half, and a quarter of the machine's processors, and asks the user to run it when the machine is quiet, or to tell the agent to run it. It then reads the row lines into the record, and writes a row only from a run that did its full work. If the user declines, the agent measures the command that it needs, as before. A command that the project adds later is still measured when an agent first needs it.
The wrapper gets two options for this. --measure-rows N,N,... measures the command at each --cpus of the list, the largest first, and gives each smaller row the suggested budget of the row before it as its --memory, so that only the first row of a command holds the whole queue. --label names the command in a new fixed-form row line that each measurement prints, so that the agent reads the output without guessing.
Closes#56
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at is not ASCII digits
str.isdigit() accepts characters such as a superscript two, which int() cannot read, so such a value ended the wrapper with a traceback in place of its option error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and measure the rows that step 1 chose
The skill said that the largest row of --measure-rows runs with no --memory, but the wrapper takes a --memory for it, as its usage text shows. The whole-project line also told each command to use all, half, and a quarter of the processors, while step 1 gives a command with self-bound none the row at half only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…when a stop signal ends the rows
The usage text and the skill say that the exit code of --measure-rows is the first exit code of a row that is not 0. When a row failed and a later row was stopped by a signal, the wrapper returned the code of the stop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s own label, and ask for output from a terminal
Step 5 puts each row line into the entry of its label, so two commands with one label made their rows ambiguous. And when the user runs the line in a terminal, the agent cannot see its output, so it now asks the user for the row lines and the end of the output of each command.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…th too many digits for int()
int() refuses a number with more digits than its limit and raises ValueError, which ended the wrapper with a traceback in place of its option error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…text as the wrapper prints it
The usage text wrote each size field as MIBM, which reads as a literal value. The wrapper prints a number followed by M, as the skill shows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a line break
The check used re.match with $, which also matches before a final line break, so a label such as "lint" with a line break passed and split the row line in two. It now uses re.fullmatch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a letter or a digit
The wrapper rejects a label that starts with '.', '_' or '-', and the option table did not say so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to six digits
The last fix relied on int() refusing a number with too many digits, but Python 3.9 has no such limit, so the new test failed there. Each value now has at most six digits, which the parser checks itself on every version, and the option error names the range.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…when an interrupt ends the wait of a later row
A signal while a row runs comes back as that row's exit code, but a signal while a row waits in the queue raises KeyboardInterrupt. That went past the rows loop to main(), which returned 130 and lost the failure of an earlier row. The loop now catches it and returns the first failed code, or 130.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s own output at one row only
--measure-rows runs a command once for each row, one after the other. A build, a generator, or an install reuses the output of the run before, so its smaller rows did less work and recorded a peak that was too small. Such a command now gets the row at half only, like a command with self-bound none.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…for each stop signal between the rows
The last fix covered SIGINT only. SIGTERM, SIGHUP, or SIGQUIT while a later row waited in the queue still ended the wrapper with the default action of the signal, and the failure of an earlier row was lost. --measure-rows now handles the three signals for the whole list and returns the first failed code, or 128 plus the signal. The handlers of the caller come back when the list ends.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the list of rows
The handlers of --measure-rows raise at any point of the list, but the rows loop caught the signal only while a row waited, and main() caught SIGINT only. A SIGTERM, SIGHUP, or SIGQUIT between two rows, or after the list before the handlers were put back, ended the wrapper with a traceback. The loop now catches it for the whole list and keeps the first failed code, and main() catches it after the list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Closes #56
Heavy commands were measured one at a time, when an agent first needed each one, in the middle of feature work on a busy machine. Each first measurement took the whole queue at a random moment, and a project's record filled up unevenly. When a project has no record, discovery now covers every heavy command of the project, and the agent writes one command line that measures all of them at several
--cpusvalues and asks the user to run it. The wrapper gets--measure-rows, which measures one command's rows largest first and passes each row's suggested budget to the next, so that line needs no state between calls.Changes
--measure-rows N,N,...measures one command at each--cpusvalue, largest first. The largest row uses the call's--memory, and each smaller row uses the suggested budget of the row before it. After a failed row, the next row keeps the failed row's--memory, so a failed run's peak is never used as a budget.--label NAMEtags the output. Each measurement prints one row line in a fixed form:bounded-run: row label=<name> cpus=<n> budget=<n>M peak=<n>M exact=<yes|no> exit=<code>.self-bound: none, or one that reuses its own output such as a build, gets that row only), and write one;-joined line with a--measure-rowscall per command, each with a label of its own. The agent asks the user to run it, and does not run it unasked. When the user ran it in a terminal, the agent asks for the row lines and the end of each command's output.--cpuswith no--memory. If the user declines, discovery falls back to measuring on demand, as before.Challenges
A row that exits with a stop code (129, 130, 131, 143) ends the remaining rows of that call. But Ctrl-C on the
;-joined line ends only the current wrapper call: the wrapper exits normally with 130 rather than dying from the signal, so the shell moves on to the next command, and the user presses Ctrl-C once per command.Related
Testing
TDD for the script. The tests cover parsing (rows sorted largest first and deduplicated, and bad rows, including digits that are not ASCII, labels, and option combinations rejected), the exact row line, the chain of budgets between rows, a failed row, a stop signal ending the rows, and a stop after a failed row keeping the first failed exit code. They also run a real process over two rows. In the RED baseline, an agent in a project with six heavy commands measured only the unit tests at a
--cpusit picked, and left five commands without an entry. With the change, a fresh agent wrote one line that measured all six commands at three--cpusvalues, with the port name of the integration suite. It asked the user to run it, ran the unit tests meanwhile, and wrote the rows from sample output, with no row for a run that stopped early.🤖 Generated with Claude Code