amsd-pipeline-workflow 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cpu-bound +22 -0
- package/driver/runtime.js +2 -1
- package/package.json +1 -1
package/bin/cpu-bound
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# cpu-bound <command...> — the live session's tools may not size their pools from the whole machine.
|
|
3
|
+
#
|
|
4
|
+
# Run 11, 2026-10-20 23:07 UTC: the Writer agent ran the codeline's whole jest suite; jest sized 15 workers from the host's 16 cores
|
|
5
|
+
# (~270 MB each) inside the session's 4096 MB memory scope, and the kernel OOM-killed the session. The Bash pipeline fixed exactly this in
|
|
6
|
+
# run 9 (lib/bounded-exec.sh): the number of workers is DERIVED from the tightest cgroup memory limit (resolve_test_workers), and the
|
|
7
|
+
# process's CPU affinity is restricted to that many CPUs (bound_self_affinity) — everything it starts, the agent's own tool commands
|
|
8
|
+
# included, inherits it and sizes its pool from it; a preload (lib/node-cpu-bound.js) makes runners that count os.cpus() see the bound too.
|
|
9
|
+
# Those are the PIPELINE's functions, sourced from the install (SCRIPT_DIR); nothing is copied here.
|
|
10
|
+
#
|
|
11
|
+
# Placed INSIDE the memory scope (bin/bounded), so the cgroup it reads is the one the session lives in: bounded cpu-bound claude -p …
|
|
12
|
+
# A bound that cannot be applied is SAID (stderr) and the command still runs — as the pipeline's own wrapper does.
|
|
13
|
+
set -u
|
|
14
|
+
[ $# -gt 0 ] || { echo "cpu-bound: no command" >&2; exit 64; }
|
|
15
|
+
if [ -n "${SCRIPT_DIR:-}" ] && [ -f "$SCRIPT_DIR/lib/bounded-exec.sh" ]; then
|
|
16
|
+
# shellcheck source=/dev/null
|
|
17
|
+
. "$SCRIPT_DIR/lib/bounded-exec.sh"
|
|
18
|
+
bound_self_affinity "$(resolve_test_workers)"
|
|
19
|
+
else
|
|
20
|
+
echo "[cpu-bound] WARNING: the pipeline's lib/bounded-exec.sh was not found (SCRIPT_DIR='${SCRIPT_DIR:-}') — this session's tools run UNBOUNDED" >&2
|
|
21
|
+
fi
|
|
22
|
+
exec "$@"
|
package/driver/runtime.js
CHANGED
|
@@ -71,7 +71,8 @@ function liveCommand({ name, script, agentsJson, args, sessionDir, env, cwd }) {
|
|
|
71
71
|
// the session itself waits for its workflow (CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=0 below); the runner has no task-wait tool
|
|
72
72
|
const prompt = `Run the workflow "${name}" with these args, exactly: ${JSON.stringify(args || {})}. When it has finished, reply with its result as JSON and nothing else.`;
|
|
73
73
|
const claude = (env && env.CLAUDE_BIN) || 'claude';
|
|
74
|
-
|
|
74
|
+
// memory scope (bin/bounded) → CPU bound derived from that scope (bin/cpu-bound, the pipeline's own bound_self_affinity) → the session: its tools (jest included) cannot out-size the scope (run 11 OOM)
|
|
75
|
+
const argv = [path.join(__dirname, '..', 'bin', 'bounded'), path.join(__dirname, '..', 'bin', 'cpu-bound'), claude, '-p', prompt, '--output-format', 'json',
|
|
75
76
|
'--setting-sources', 'project', '--permission-mode', 'bypassPermissions'];
|
|
76
77
|
return { cwd: home, argv, agents: Object.keys(defs).length, workflow: path.join(wfDir, `${name}.js`) };
|
|
77
78
|
}
|
package/package.json
CHANGED