@bluewombat/implementer 0.3.0 → 0.4.0
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/SPECS.md +11 -0
- package/dist/child/process-tree.d.ts +19 -0
- package/dist/child/process-tree.d.ts.map +1 -0
- package/dist/child/process-tree.js +137 -0
- package/dist/child/process-tree.js.map +1 -0
- package/dist/child/run-child.d.ts.map +1 -1
- package/dist/child/run-child.js +7 -12
- package/dist/child/run-child.js.map +1 -1
- package/dist/run/run-implementer.d.ts +1 -1
- package/dist/run/run-implementer.d.ts.map +1 -1
- package/package.json +1 -1
package/SPECS.md
CHANGED
|
@@ -129,6 +129,17 @@ runs); each Gate takes the `--gate-timeout-ms` written before it. Reaching one
|
|
|
129
129
|
kills that child and ends the Attempt as `fail-retryable`, which the loop then
|
|
130
130
|
decides on like any other retryable failure.
|
|
131
131
|
|
|
132
|
+
**"Kills that child" means everything it started.** A producer is a chain — a
|
|
133
|
+
script, an agent, the vendor CLI, its shells — and a ceiling that stopped only
|
|
134
|
+
the first would let the rest run on, holding the pipes open, until the agent
|
|
135
|
+
ended by itself: an Attempt would outlive its ceiling and be judged lost while
|
|
136
|
+
its work was done. Every child runs as the leader of its own process group and
|
|
137
|
+
is ended by signalling the group and every descendant `ps` lists under it — a
|
|
138
|
+
vendor CLI may start its shells in groups of their own. After a kill the pipes
|
|
139
|
+
are cut two seconds later, so a process that still escaped cannot hold the
|
|
140
|
+
outcome back. What is
|
|
141
|
+
still running when the invocation itself exits is killed.
|
|
142
|
+
|
|
132
143
|
**Nothing is derived from what another child left behind.** There is no Attempt
|
|
133
144
|
clock and no Task clock. A budget computed from a deadline is how a producer
|
|
134
145
|
that overran left its Gates a millisecond to answer in — they were killed on
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
/** Spread into the options of `spawn`: the child leads its own group. */
|
|
3
|
+
export declare function ownGroup(): {
|
|
4
|
+
detached: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Remember a running child so it does not outlive this process: a group of its
|
|
8
|
+
* own no longer shares the terminal's Ctrl-C, nor dies by accident with us.
|
|
9
|
+
* Forgotten on its own once it closes.
|
|
10
|
+
*/
|
|
11
|
+
export declare function track(child: ChildProcess): void;
|
|
12
|
+
/**
|
|
13
|
+
* SIGKILL to the child's whole group and to every descendant, wherever its
|
|
14
|
+
* group; to the child alone where there are no groups. Once per child.
|
|
15
|
+
*/
|
|
16
|
+
export declare function killTree(child: ChildProcess): void;
|
|
17
|
+
/** `killTree`, then the pipes are cut after the grace period. Once per child. */
|
|
18
|
+
export declare function killAndCut(child: ChildProcess): void;
|
|
19
|
+
//# sourceMappingURL=process-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-tree.d.ts","sourceRoot":"","sources":["../../src/child/process-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,oBAAoB,CAAC;AAoCrE,yEAAyE;AACzE,wBAAgB,QAAQ,IAAI;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAe/C;AAiCD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CA8BlD;AAED,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CASpD"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
// Canonical source of every `process-tree.ts` in this repository. Edit it here,
|
|
3
|
+
// then run `node scripts/check-process-tree.mjs --write`; `npm run lint` fails
|
|
4
|
+
// when a copy differs. A package stands alone, so each carries its own copy.
|
|
5
|
+
//
|
|
6
|
+
// The rule it keeps: whoever starts a child and owns its deadline — a
|
|
7
|
+
// supervisor — starts it as the leader of its own process group, and ends it by
|
|
8
|
+
// signalling that group. A child is rarely alone: a producer is `node producer`
|
|
9
|
+
// → `node agent` → the vendor CLI → its shells. Killing only the first leaves
|
|
10
|
+
// the rest running, holding the pipes open, until they end on their own; the
|
|
11
|
+
// deadline then means nothing and a finished job is reported as lost.
|
|
12
|
+
//
|
|
13
|
+
// A layer in the middle of such a chain (a producer, an agent runner) is not a
|
|
14
|
+
// supervisor: it starts its child in its own group, so the supervisor's signal
|
|
15
|
+
// reaches it too.
|
|
16
|
+
//
|
|
17
|
+
// The group is not the whole tree. A vendor CLI may start each shell command
|
|
18
|
+
// in a group of its own (cursor-agent does), out of the group's reach. So the
|
|
19
|
+
// descendants are read from `ps` first — once their parent dies they are
|
|
20
|
+
// re-parented and the link is lost — and each is killed too.
|
|
21
|
+
/** Windows has no process groups: there a child is killed alone. */
|
|
22
|
+
const OWN_GROUP = process.platform !== "win32";
|
|
23
|
+
/**
|
|
24
|
+
* After a kill the pipes are cut this long afterwards, so a grandchild that
|
|
25
|
+
* left the group (setsid) and still holds one cannot hold the outcome back.
|
|
26
|
+
*/
|
|
27
|
+
const PIPE_GRACE_MS = 2_000;
|
|
28
|
+
const live = new Set();
|
|
29
|
+
/** Already killed: a supervisor polling its interrupt asks again every tick. */
|
|
30
|
+
const ended = new WeakSet();
|
|
31
|
+
let exitHookInstalled = false;
|
|
32
|
+
/** Spread into the options of `spawn`: the child leads its own group. */
|
|
33
|
+
export function ownGroup() {
|
|
34
|
+
return { detached: OWN_GROUP };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Remember a running child so it does not outlive this process: a group of its
|
|
38
|
+
* own no longer shares the terminal's Ctrl-C, nor dies by accident with us.
|
|
39
|
+
* Forgotten on its own once it closes.
|
|
40
|
+
*/
|
|
41
|
+
export function track(child) {
|
|
42
|
+
if (OWN_GROUP && !exitHookInstalled) {
|
|
43
|
+
exitHookInstalled = true;
|
|
44
|
+
process.on("exit", () => {
|
|
45
|
+
for (const running of live) {
|
|
46
|
+
killTree(running);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
live.add(child);
|
|
51
|
+
const forget = () => {
|
|
52
|
+
live.delete(child);
|
|
53
|
+
};
|
|
54
|
+
child.once("close", forget);
|
|
55
|
+
child.once("error", forget);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Every process below `pid`, as `ps` lists them now. Empty where `ps` cannot be
|
|
59
|
+
* read: the group kill still stands.
|
|
60
|
+
*/
|
|
61
|
+
function descendants(pid) {
|
|
62
|
+
let table;
|
|
63
|
+
try {
|
|
64
|
+
table = execFileSync("ps", ["-A", "-o", "pid=,ppid="], {
|
|
65
|
+
encoding: "utf8",
|
|
66
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const childrenOf = new Map();
|
|
73
|
+
for (const line of table.split("\n")) {
|
|
74
|
+
const match = /^\s*(\d+)\s+(\d+)\s*$/.exec(line);
|
|
75
|
+
if (match !== null) {
|
|
76
|
+
const parent = Number(match[2]);
|
|
77
|
+
childrenOf.set(parent, [...(childrenOf.get(parent) ?? []), Number(match[1])]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const found = [];
|
|
81
|
+
let frontier = [pid];
|
|
82
|
+
while (frontier.length > 0) {
|
|
83
|
+
frontier = frontier.flatMap((each) => childrenOf.get(each) ?? []);
|
|
84
|
+
found.push(...frontier);
|
|
85
|
+
}
|
|
86
|
+
return found;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* SIGKILL to the child's whole group and to every descendant, wherever its
|
|
90
|
+
* group; to the child alone where there are no groups. Once per child.
|
|
91
|
+
*/
|
|
92
|
+
export function killTree(child) {
|
|
93
|
+
if (ended.has(child)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
ended.add(child);
|
|
97
|
+
if (OWN_GROUP && child.pid !== undefined) {
|
|
98
|
+
const below = descendants(child.pid);
|
|
99
|
+
let grouped = true;
|
|
100
|
+
try {
|
|
101
|
+
process.kill(-child.pid, "SIGKILL");
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// no such group: the child itself, below
|
|
105
|
+
grouped = false;
|
|
106
|
+
}
|
|
107
|
+
for (const pid of below) {
|
|
108
|
+
try {
|
|
109
|
+
process.kill(pid, "SIGKILL");
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// already gone, with the group
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (grouped) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
child.kill("SIGKILL");
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// already gone
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/** `killTree`, then the pipes are cut after the grace period. Once per child. */
|
|
127
|
+
export function killAndCut(child) {
|
|
128
|
+
if (ended.has(child)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
killTree(child);
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
child.stdout?.destroy();
|
|
134
|
+
child.stderr?.destroy();
|
|
135
|
+
}, PIPE_GRACE_MS).unref();
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=process-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-tree.js","sourceRoot":"","sources":["../../src/child/process-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAErE,gFAAgF;AAChF,+EAA+E;AAC/E,6EAA6E;AAC7E,EAAE;AACF,sEAAsE;AACtE,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,6EAA6E;AAC7E,sEAAsE;AACtE,EAAE;AACF,+EAA+E;AAC/E,+EAA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M,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGrE"}
|
package/dist/child/run-child.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { killAndCut, ownGroup, track } from "./process-tree.js";
|
|
2
3
|
// Two bounds, for two different things.
|
|
3
4
|
//
|
|
4
5
|
// The first protects this process: a child that writes without end is not one
|
|
@@ -15,14 +16,6 @@ function keepEnd(text) {
|
|
|
15
16
|
}
|
|
16
17
|
return `[…${text.length - REPORT_KEEP_CHARS} characters cut]${text.slice(-REPORT_KEEP_CHARS)}`;
|
|
17
18
|
}
|
|
18
|
-
function killProcessTree(child) {
|
|
19
|
-
try {
|
|
20
|
-
child.kill("SIGKILL");
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
// already gone
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
19
|
/**
|
|
27
20
|
* Run one child with a wall-clock timeout. Does not inherit Implementer stdin.
|
|
28
21
|
*/
|
|
@@ -63,6 +56,7 @@ export function runChild(request) {
|
|
|
63
56
|
cwd: request.cwd,
|
|
64
57
|
env: request.env,
|
|
65
58
|
stdio: ["ignore", "pipe", "pipe"],
|
|
59
|
+
...ownGroup(),
|
|
66
60
|
});
|
|
67
61
|
}
|
|
68
62
|
catch (error) {
|
|
@@ -70,6 +64,7 @@ export function runChild(request) {
|
|
|
70
64
|
finish({ kind: "spawn_error", detail });
|
|
71
65
|
return;
|
|
72
66
|
}
|
|
67
|
+
track(child);
|
|
73
68
|
if (!child.stdout || !child.stderr) {
|
|
74
69
|
finish({ kind: "spawn_error", detail: "Child stdout/stderr pipes unavailable." });
|
|
75
70
|
return;
|
|
@@ -86,7 +81,7 @@ export function runChild(request) {
|
|
|
86
81
|
}
|
|
87
82
|
if (stdout.length + stderr.length + chunk.length > OUTPUT_LIMIT_CHARS) {
|
|
88
83
|
overflowed = true;
|
|
89
|
-
|
|
84
|
+
killAndCut(child);
|
|
90
85
|
return false;
|
|
91
86
|
}
|
|
92
87
|
return true;
|
|
@@ -112,17 +107,17 @@ export function runChild(request) {
|
|
|
112
107
|
});
|
|
113
108
|
timer = setTimeout(() => {
|
|
114
109
|
timedOut = true;
|
|
115
|
-
|
|
110
|
+
killAndCut(child);
|
|
116
111
|
}, Math.max(1, request.timeoutMs));
|
|
117
112
|
interruptPoll = setInterval(() => {
|
|
118
113
|
if (request.shouldInterrupt()) {
|
|
119
114
|
interrupted = true;
|
|
120
|
-
|
|
115
|
+
killAndCut(child);
|
|
121
116
|
}
|
|
122
117
|
}, 20);
|
|
123
118
|
if (request.shouldInterrupt()) {
|
|
124
119
|
interrupted = true;
|
|
125
|
-
|
|
120
|
+
killAndCut(child);
|
|
126
121
|
}
|
|
127
122
|
child.on("close", (exitCode, signal) => {
|
|
128
123
|
const out = stdout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-child.js","sourceRoot":"","sources":["../../src/child/run-child.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"run-child.js","sourceRoot":"","sources":["../../src/child/run-child.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEhE,wCAAwC;AACxC,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3C,0EAA0E;AAC1E,+EAA+E;AAC/E,6DAA6D;AAC7D,MAAM,iBAAiB,GAAG,KAAK,CAAC;AA0ChC,SAAS,OAAO,CAAC,IAAY;IAC3B,IAAI,IAAI,CAAC,MAAM,IAAI,iBAAiB,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;I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AC,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -8,7 +8,7 @@ export type RunResult = {
|
|
|
8
8
|
export type RunOptions = {
|
|
9
9
|
invocation: Invocation;
|
|
10
10
|
write?: ProgressWriter;
|
|
11
|
-
/**
|
|
11
|
+
/** Polled for interrupt; absent, never interrupted. Its owner — the CLI or a Host — flips it. */
|
|
12
12
|
interruptFlag?: {
|
|
13
13
|
interrupted: boolean;
|
|
14
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-implementer.d.ts","sourceRoot":"","sources":["../../src/run/run-implementer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,KAAK,EAGV,UAAU,EACV,aAAa,EACb,UAAU,EACV,KAAK,EACN,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,
|
|
1
|
+
{"version":3,"file":"run-implementer.d.ts","sourceRoot":"","sources":["../../src/run/run-implementer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,KAAK,EAGV,UAAU,EACV,aAAa,EACb,UAAU,EACV,KAAK,EACN,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,cAAc,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