From 738de42648a5e6629ede06dee72a9be72deac5f3 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Fri, 20 Nov 2026 22:24:03 +0000 Subject: [PATCH 1/2] fix(formal): run tsc and ajs through this Node, which needs no shell on Windows --- .../formal-json-value-identity/check.mjs | 7 ++++--- .../formal-merge-repeated-keys/check.mjs | 7 ++++--- .../skills/formal-pipeline-chains/check.mjs | 21 ++++++++++--------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.agents/skills/formal-json-value-identity/check.mjs b/.agents/skills/formal-json-value-identity/check.mjs index b5b20db..b6c0f8e 100755 --- a/.agents/skills/formal-json-value-identity/check.mjs +++ b/.agents/skills/formal-json-value-identity/check.mjs @@ -33,13 +33,14 @@ if (args.includes("--full")) { env.FORMAL_RUNS = value("--runs") ?? env.FORMAL_RUNS; env.FORMAL_SEED = value("--seed") ?? env.FORMAL_SEED; -const build = spawnSync("pnpm", ["run", "--silent", "build"], { cwd: root, encoding: "utf8" }); +const tsc = path.join(root, "node_modules", "typescript", "bin", "tsc"); +const build = spawnSync(process.execPath, [tsc], { cwd: root, encoding: "utf8" }); if (build.status !== 0) { console.error(`${build.stdout}${build.stderr}`); process.exit(TOOL_ERROR); } -const ajs = path.join(root, "node_modules", ".bin", "ajs"); -const test = spawnSync(ajs, ["module", "test", ".", "-f", "dist/test/formal-json-value-identity.test.js"], { +const ajs = path.join(root, "node_modules", "@antelopejs", "core", "dist", "core", "cli", "index.js"); +const test = spawnSync(process.execPath, [ajs, "module", "test", ".", "-f", "dist/test/formal-json-value-identity.test.js"], { cwd: root, env, encoding: "utf8", diff --git a/.agents/skills/formal-merge-repeated-keys/check.mjs b/.agents/skills/formal-merge-repeated-keys/check.mjs index 9b9d2e5..661bf75 100755 --- a/.agents/skills/formal-merge-repeated-keys/check.mjs +++ b/.agents/skills/formal-merge-repeated-keys/check.mjs @@ -33,13 +33,14 @@ if (args.includes("--full")) { env.FORMAL_RUNS = value("--runs") ?? env.FORMAL_RUNS; env.FORMAL_SEED = value("--seed") ?? env.FORMAL_SEED; -const build = spawnSync("pnpm", ["run", "--silent", "build"], { cwd: root, encoding: "utf8" }); +const tsc = path.join(root, "node_modules", "typescript", "bin", "tsc"); +const build = spawnSync(process.execPath, [tsc], { cwd: root, encoding: "utf8" }); if (build.status !== 0) { console.error(`${build.stdout}${build.stderr}`); process.exit(TOOL_ERROR); } -const ajs = path.join(root, "node_modules", ".bin", "ajs"); -const test = spawnSync(ajs, ["module", "test", ".", "-f", "dist/test/formal-key-merge.test.js"], { +const ajs = path.join(root, "node_modules", "@antelopejs", "core", "dist", "core", "cli", "index.js"); +const test = spawnSync(process.execPath, [ajs, "module", "test", ".", "-f", "dist/test/formal-key-merge.test.js"], { cwd: root, env, encoding: "utf8", diff --git a/.agents/skills/formal-pipeline-chains/check.mjs b/.agents/skills/formal-pipeline-chains/check.mjs index d178db7..24a7f9a 100644 --- a/.agents/skills/formal-pipeline-chains/check.mjs +++ b/.agents/skills/formal-pipeline-chains/check.mjs @@ -12,6 +12,8 @@ import { parseArgs } from "node:util"; const TOOL_ERROR = 2; const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../.."); +const tsc = path.join(root, "node_modules", "typescript", "bin", "tsc"); +const ajs = path.join(root, "node_modules", "@antelopejs", "core", "dist", "core", "cli", "index.js"); const PROPERTIES = [ { name: "ChainsMatchReference", file: "dist/formal-pipeline-chains/pipeline-chains.test.js", runs: "CHAINS_RUNS", ci: 1000, full: 10_000 }, @@ -28,15 +30,16 @@ const { values } = parseArgs({ }); /** - * Runs a command to its end and answers its exit code and everything it printed. - * @param {string} command + * Runs a Node script to its end in this Node, which needs no shell on Windows, and answers its exit + * code and everything it printed. + * @param {string} script * @param {string[]} args * @param {Record} [env] * @returns {Promise<{ code: number, output: string }>} */ -function run(command, args, env = {}) { +function run(script, args, env = {}) { return new Promise((resolve) => { - const child = spawn(command, args, { cwd: root, env: { ...process.env, ...env } }); + const child = spawn(process.execPath, [script, ...args], { cwd: root, env: { ...process.env, ...env } }); let output = ""; child.stdout.on("data", (chunk) => (output += chunk)); child.stderr.on("data", (chunk) => (output += chunk)); @@ -64,16 +67,14 @@ function counterexample(output) { } if (!values["no-build"]) { - const built = await run("pnpm", ["run", "build"]); + const built = await run(tsc, []); if (built.code !== 0) { - console.error(`pnpm run build failed\n${built.output}`); + console.error(`tsc failed on the module\n${built.output}`); process.exit(TOOL_ERROR); } } -const compiled = await run("pnpm", [ - "exec", - "tsc", +const compiled = await run(tsc, [ "-p", ".agents/skills/formal-pipeline-chains/tsconfig.json", "--outDir", @@ -90,7 +91,7 @@ for (const property of PROPERTIES) { if (values.seed) { env.CHAINS_SEED = values.seed; } - const { code, output } = await run("pnpm", ["exec", "ajs", "module", "test", ".", "-f", property.file], env); + const { code, output } = await run(ajs, ["module", "test", ".", "-f", property.file], env); if (code === 0) { continue; } From d2adada4ea6015bd0281a5f96d81e21e2b8bd06b Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Fri, 20 Nov 2026 22:24:05 +0000 Subject: [PATCH 2/2] test: size probe timeouts, the dedup budget and the chains feed open for a loaded host --- .../pipeline-chains-feeds.test.ts | 4 +++- src/test-external/distinct-large.test.ts | 20 +++++++++---------- src/test/probe-many.test.ts | 10 +++++++--- src/test/probe-steps.test.ts | 7 +++++-- src/test/unit/probe-fixture.ts | 8 ++++++-- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.agents/skills/formal-pipeline-chains/pipeline-chains-feeds.test.ts b/.agents/skills/formal-pipeline-chains/pipeline-chains-feeds.test.ts index 895e61a..d5563fa 100644 --- a/.agents/skills/formal-pipeline-chains/pipeline-chains-feeds.test.ts +++ b/.agents/skills/formal-pipeline-chains/pipeline-chains-feeds.test.ts @@ -59,7 +59,8 @@ async function Cleared(): Promise { /** * Waits until the feed is open. A feed opens when it is first read, and a write before that is not - * delivered, so a document the chain passes is written until one is delivered. With no such + * delivered, so a document the chain passes is written until one is delivered, then deleted, and + * its removal awaited however late a loaded host delivers it. With no such * document no write of the script is delivered either, and a pause is as good. */ async function Opened(reader: Reader, stages: readonly Stage[]): Promise { @@ -72,6 +73,7 @@ async function Opened(reader: Reader, stages: readonly Stage[]): Promise { await fixture.handles.items().insert(probe).run(); if (await reader.next(QUIET_MS)) { await Cleared(); + await reader.next(DELIVERY_MS); await reader.drain(QUIET_MS); return; } diff --git a/src/test-external/distinct-large.test.ts b/src/test-external/distinct-large.test.ts index b52f7b5..69fb0ed 100644 --- a/src/test-external/distinct-large.test.ts +++ b/src/test-external/distinct-large.test.ts @@ -8,18 +8,16 @@ import { NativeWrite, RegisterSales, type SalesTables } from "./sales"; /** The bytes of JSON text each document holds. */ const DOCUMENT_BYTES = 400 * 1024; -/** The longest a dedup may take per row it reads, of a document whose numbers have at most 15 digits and no exponent. */ -const MS_PER_ROW = 100; +/** + * The longest a dedup may take per row it reads, of a document whose numbers have at most 15 digits + * and no exponent. A respell quadratic in the text took over 1.1 s a row on an idle host, and the + * linear one up to 250 ms a row beside 4 busy loops per CPU. + */ +const MS_PER_ROW = 400; /** The runs a dedup gets to come in under its budget, since a busy host only adds to its time. */ const ATTEMPTS = 3; -/** - * How many times the top-level budget a group's dedup gets: its numbering join and the unwrap of its - * keyed `JSON_OBJECTAGG` took 327 and 357 ms on the Windows runner, against 157 to 187 ms locally. - */ -const GROUP_BUDGETS = 2; - /** How many times `part` and a comma fill {@link DOCUMENT_BYTES}. */ function Fitting(part: string): number { return Math.ceil(DOCUMENT_BYTES / (part.length + 1)); @@ -108,7 +106,7 @@ describe("a dedup of large external JSON documents", function () { await NativeWrite(sql`DELETE FROM sales.w_accounts WHERE code LIKE 'jl%'`); }); - it("keeps one value per document at the top in under 0.1 s a row", async () => { + it("keeps one value per document at the top in under 0.4 s a row", async () => { const budget = MS_PER_ROW * DOCUMENTS.length; const [values, ms] = await Fastest( () => Large().distinct("raw").run(), @@ -130,8 +128,8 @@ describe("a dedup of large external JSON documents", function () { expect(await SortBuffer()).to.equal(before); }); - it("keeps one value per document in a group in under 0.2 s a row, which 327 and 357 ms on Windows need", async () => { - const budget = MS_PER_ROW * DOCUMENTS.length * GROUP_BUDGETS; + it("keeps one value per document in a group in under 0.4 s a row", async () => { + const budget = MS_PER_ROW * DOCUMENTS.length; const [groups, ms] = await Fastest( () => Large() diff --git a/src/test/probe-many.test.ts b/src/test/probe-many.test.ts index a296fbc..209141b 100644 --- a/src/test/probe-many.test.ts +++ b/src/test/probe-many.test.ts @@ -4,14 +4,18 @@ import { randomBytes } from "node:crypto"; import { GetOptions } from "../config"; import { probe } from "../probe"; -import { CommandCounter, PREPARE_COMMAND, Relay } from "./unit/probe-fixture"; +import { + CommandCounter, + PREPARE_COMMAND, + Relay, + TIMEOUT_MS, +} from "./unit/probe-fixture"; const DATABASE = "probe_many"; const RELATIONS = 1000; const READER = "probe_many_reader"; const SECRET = randomBytes(6).toString("hex"); -/** A timeout the probe meets on each answer; the DMS check gives up after three of them. */ -const TIMEOUT_MS = 400; +/** How many probe timeouts the DMS check waits before it gives up. */ const DEADLINE_IN_TIMEOUTS = 3; /** What the probe prepares besides one statement per relation: the listing, one confirmed read and the `CREATE TABLE` check. */ const FIXED_PREPARES = 3; diff --git a/src/test/probe-steps.test.ts b/src/test/probe-steps.test.ts index 9a4e820..e7b1e42 100644 --- a/src/test/probe-steps.test.ts +++ b/src/test/probe-steps.test.ts @@ -19,8 +19,11 @@ const DATABASE = "probe_steps"; /** `ER_MAX_PREPARED_STMT_COUNT_REACHED`: the server's cap on prepared statements, whatever the account may do. */ const MAX_PREPARED_STATEMENTS = 1461; -/** How long the relay holds each chunk from the server, so a round trip takes at least that. */ -const DELAY_MS = 100; +/** + * How long the relay holds each chunk from the server, so a round trip takes at least that. A + * loaded host adds over 100 ms to a round trip, which must stay under this. + */ +const DELAY_MS = 500; /** Each step the probe takes after the sign-in, by the command that starts it. */ const STEPS = [ diff --git a/src/test/unit/probe-fixture.ts b/src/test/unit/probe-fixture.ts index 0e81244..c801a2e 100644 --- a/src/test/unit/probe-fixture.ts +++ b/src/test/unit/probe-fixture.ts @@ -5,8 +5,12 @@ import path from "node:path"; import { IsString } from "../../implementations/database/guards"; -/** How long a probe in these tests waits to connect and for each answer. */ -export const TIMEOUT_MS = 1000; +/** + * How long a probe in these tests waits to connect and for each answer. Beside 4 busy loops per + * CPU, a probe took up to 4.7 s past a 1 s timeout to give up on a server that stopped answering, + * so a bound of twice this one holds on a loaded host. + */ +export const TIMEOUT_MS = 5000; /** How long a test lets sockets settle before it counts the ones still open. */ export const CLOSE_SETTLE_MS = 1000;