S3 ask-once-ts: the TypeScript stdio asks once; the kind stopping goes

Builds: design 47 H2 H-A-570 (2) (3) (4)
This commit is contained in:
2026-11-25 17:05:11 +01:00
parent e5b66a77ba
commit a123ebd643
4 changed files with 53 additions and 79 deletions
+12 -12
View File
@@ -379,10 +379,10 @@ async function aBundlesFindingWriter(): Promise<void> {
}
}
test("a call a stopping tool runner did not take is asked again after a pause until the new runner answers or the bound ends; a plain refusal and a bare timeout are not (design 47 H2 H-A-542, H-A-544, H-A-549)", async () => {
const child = spawn(process.execPath, [fileURLToPath(new URL("./fixtures/stdio-stopping.mjs", import.meta.url))],
test("a call is made once: no responders is returned after one ask, a reply of the withdrawn kind stopping is a refusal, and at the bound the fault is no answer within <bound> (design 47 H2 H-A-570 (2), (4))", async () => {
const child = spawn(process.execPath, [fileURLToPath(new URL("./fixtures/stdio-ask.mjs", import.meta.url))],
{ stdio: ["pipe", "pipe", "pipe"], env: { ...process.env, MESH_SERVED_MODULE: "builder",
MESH_CONFIG_KEPT_CALL_PACE_FIRST: "2s", MESH_CONFIG_KEPT_CALL_PACE_MAX: "4s", MESH_CONFIG_ASK_BOUND: "10s" } });
MESH_CONFIG_ASK_BOUND: "50ms" } });
const seen: any[] = [];
let buffered = "";
let said = "";
@@ -404,16 +404,16 @@ test("a call a stopping tool runner did not take is asked again after a pause un
try {
send({ jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "2025-03-26", capabilities: {} } });
await until((m) => m.id === 1);
const noResponders = { code: -32000, message: "nats: no responders available for request" };
for (const row of [
// The pace and the bound are the settings (2 s doubling to 4 s, a bound of 10 s, H-A-549); the pause moves a clock.
{ id: 2, answers: [{ error: stopping }, { error: stopping }, { result: { published: true } }],
want: { answer: { published: true }, paused: [2000, 4000] } },
{ id: 3, answers: [{ error: stopping }, { error: stopping }, { error: stopping }],
want: { stopping: true, words: `seat:go-package-registry.publish: the tool runner was stopping, asked again until the bound of 10000ms: ${stopping.message}`, paused: [2000, 4000] } },
{ id: 4, answers: [{ error: { code: -32000, message: "refused" } }], want: { stopping: false, words: "refused", paused: [] } },
{ id: 5, answers: [{ error: { code: -32000, message: "timeout" } }], want: { stopping: false, words: "timeout", paused: [] } },
{ id: 2, answers: [{ result: { published: true } }], want: { answer: { published: true } } },
{ id: 3, answers: [{ error: noResponders }], want: { words: noResponders.message } },
{ id: 4, answers: [{ error: stopping }], want: { words: stopping.message } },
{ id: 5, answers: [{ error: { code: -32000, message: "refused" } }], want: { words: "refused" } },
{ id: 6, answers: [], want: { words: "no answer within 50ms" } },
]) {
send({ jsonrpc: "2.0", id: row.id, method: "tools/call", params: { name: "publish", arguments: {} } });
if (row.answers.length === 0) await until((m) => m.method === "mesh/ask" && !m.answered).then((m) => { m.answered = true; });
for (const a of row.answers) {
const asked = await until((m) => m.method === "mesh/ask" && !m.answered);
assert.ok(asked, `the bundle did not ask again (row ${row.id})`);
@@ -422,9 +422,9 @@ test("a call a stopping tool runner did not take is asked again after a pause un
}
const done = await until((m) => m.id === row.id);
assert.deepEqual(JSON.parse(done.result.content[0].text), row.want);
assert.equal(seen.filter((m) => m.method === "mesh/ask" && !m.answered).length, 0, `asked more than ${row.answers.length} times`);
assert.equal(seen.filter((m) => m.method === "mesh/ask" && !m.answered).length, 0, `asked more than ${Math.max(row.answers.length, 1)} times`);
}
assert.match(said, /the tool runner is stopping/);
assert.doesNotMatch(said, /asked again/);
} finally {
child.kill();
}